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.yangtools.yang.model.spi.source;
10 import static java.util.Objects.requireNonNull;
12 import java.io.Reader;
13 import java.io.StringReader;
14 import org.eclipse.jdt.annotation.NonNull;
15 import org.eclipse.jdt.annotation.Nullable;
16 import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
19 * A {@link YangTextSource} with content readily available.
21 public class StringYangTextSource extends YangTextSource {
22 private final @Nullable String symbolicName;
23 private final @NonNull String content;
25 public StringYangTextSource(final SourceIdentifier sourceId, final String content) {
26 this(sourceId, content, null);
29 public StringYangTextSource(final SourceIdentifier sourceId, final String content,
30 final @Nullable String symbolicName) {
32 this.content = requireNonNull(content);
33 this.symbolicName = symbolicName;
37 public final String symbolicName() {
42 public final Reader openStream() {
43 return new StringReader(content);