2 * Copyright (c) 2023 PANTHEON.tech, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.netconf.client.mdsal;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.base.MoreObjects;
13 import java.io.Reader;
14 import java.io.StringReader;
15 import java.util.Optional;
16 import org.opendaylight.netconf.client.mdsal.api.RemoteDeviceId;
17 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
18 import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
21 * A {@link YangTextSchemaSource} cached from a remote service.
23 public final class CachedYangTextSchemaSource extends YangTextSchemaSource {
24 private final RemoteDeviceId id;
25 private final String schemaString;
26 private final String symbolicName;
28 public CachedYangTextSchemaSource(final RemoteDeviceId id, final SourceIdentifier sourceIdentifier,
29 final String symbolicName, final String schemaString) {
30 super(sourceIdentifier);
31 this.symbolicName = requireNonNull(symbolicName);
32 this.id = requireNonNull(id);
33 this.schemaString = requireNonNull(schemaString);
37 protected MoreObjects.ToStringHelper addToStringAttributes(final MoreObjects.ToStringHelper toStringHelper) {
38 return toStringHelper.add("device", id);
42 public Reader openStream() {
43 return new StringReader(schemaString);
47 public Optional<String> getSymbolicName() {
48 return Optional.of(symbolicName);