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 org.eclipse.jdt.annotation.NonNull;
16 import org.opendaylight.netconf.client.mdsal.api.RemoteDeviceId;
17 import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
18 import org.opendaylight.yangtools.yang.model.api.source.YangTextSource;
21 * A {@link YangTextSource} cached from a remote service.
23 // FIXME: subclass StringYangTextSource and cleanup addToStringAttributes()
24 public final class CachedYangTextSchemaSource extends YangTextSource {
25 private final @NonNull SourceIdentifier sourceId;
26 private final @NonNull RemoteDeviceId id;
27 private final @NonNull String symbolicName;
28 private final @NonNull String schemaString;
30 public CachedYangTextSchemaSource(final RemoteDeviceId id, final SourceIdentifier sourceId,
31 final String symbolicName, final String schemaString) {
32 this.id = requireNonNull(id);
33 this.sourceId = requireNonNull(sourceId);
34 this.symbolicName = requireNonNull(symbolicName);
35 this.schemaString = requireNonNull(schemaString);
39 public Reader openStream() {
40 return new StringReader(schemaString);
44 public SourceIdentifier sourceId() {
49 public String symbolicName() {
54 protected MoreObjects.ToStringHelper addToStringAttributes(final MoreObjects.ToStringHelper toStringHelper) {
55 return toStringHelper.add("device", id);