Promote SchemaSourceRepresentation 85/109585/11
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 2 Jan 2024 09:04:51 +0000 (10:04 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 2 Jan 2024 13:40:58 +0000 (14:40 +0100)
SchemaSourceRepresentation is an extensible framework for identifying
and working with sources of YANG schema, which eventually can become
yang.model.api constructs.

SchemaSourceRepresentation and its two immediate specializations are
landing in yang.mode.api.source, the actual implementations in
yang.model.spi.source.

JIRA: YANGTOOLS-1150
Change-Id: I10d0b3afd29f6b96b98ea8ffca0ca1c0b8ec44f6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
125 files changed:
model/yang-model-api/src/main/java/module-info.java
model/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/source/SourceIdentifier.java [moved from yang/yang-repo-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/SourceIdentifier.java with 98% similarity]
model/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/source/SourceRepresentation.java [moved from yang/yang-repo-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/SchemaSourceRepresentation.java with 64% similarity]
model/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/source/YangSourceRepresentation.java [moved from yang/yang-repo-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/YinSchemaSourceRepresentation.java with 56% similarity]
model/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/source/YinSourceRepresentation.java [moved from yang/yang-repo-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/YangSchemaSourceRepresentation.java with 56% similarity]
model/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/source/package-info.java [new file with mode: 0644]
model/yang-model-export/src/test/java/org/opendaylight/yangtools/yang/model/export/SimpleModuleTest.java
model/yang-model-ri/src/main/java/org/opendaylight/yangtools/yang/model/ri/stmt/EffectiveStatements.java
model/yang-model-ri/src/main/java/org/opendaylight/yangtools/yang/model/ri/stmt/impl/eff/ImportEffectiveStatementImpl.java
model/yang-model-spi/src/main/java/module-info.java
model/yang-model-spi/src/main/java/org/opendaylight/yangtools/yang/model/spi/source/DelegatedYangTextSource.java [moved from yang/yang-repo-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/DelegatedYangTextSchemaSource.java with 72% similarity]
model/yang-model-spi/src/main/java/org/opendaylight/yangtools/yang/model/spi/source/DelegatedYinTextSource.java [moved from yang/yang-repo-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/DelegatedYinTextSchemaSource.java with 73% similarity]
model/yang-model-spi/src/main/java/org/opendaylight/yangtools/yang/model/spi/source/ResourceYangTextSource.java [moved from yang/yang-repo-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/ResourceYangTextSchemaSource.java with 73% similarity]
model/yang-model-spi/src/main/java/org/opendaylight/yangtools/yang/model/spi/source/ResourceYinTextSource.java [moved from yang/yang-repo-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/ResourceYinTextSchemaSource.java with 71% similarity]
model/yang-model-spi/src/main/java/org/opendaylight/yangtools/yang/model/spi/source/StringYangTextSource.java [moved from yang/yang-repo-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/StringYangTextSchemaSource.java with 60% similarity]
model/yang-model-spi/src/main/java/org/opendaylight/yangtools/yang/model/spi/source/YangTextFileSource.java [moved from yang/yang-repo-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/YangTextFileSchemaSource.java with 75% similarity]
model/yang-model-spi/src/main/java/org/opendaylight/yangtools/yang/model/spi/source/YangTextSource.java [moved from yang/yang-repo-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/YangTextSchemaSource.java with 73% similarity]
model/yang-model-spi/src/main/java/org/opendaylight/yangtools/yang/model/spi/source/YinDomSource.java [moved from yang/yang-repo-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/YinDomSchemaSource.java with 72% similarity]
model/yang-model-spi/src/main/java/org/opendaylight/yangtools/yang/model/spi/source/YinTextFileSource.java [moved from yang/yang-repo-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/YinTextFileSchemaSource.java with 70% similarity]
model/yang-model-spi/src/main/java/org/opendaylight/yangtools/yang/model/spi/source/YinTextSource.java [moved from yang/yang-repo-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/YinTextSchemaSource.java with 73% similarity]
model/yang-model-spi/src/main/java/org/opendaylight/yangtools/yang/model/spi/source/YinXmlSource.java [moved from yang/yang-repo-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/YinXmlSchemaSource.java with 73% similarity]
model/yang-model-spi/src/main/java/org/opendaylight/yangtools/yang/model/spi/source/package-info.java [new file with mode: 0644]
model/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/SchemaContextUtil.java
model/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/YT691Test.java
parser/odlext-parser-support/src/test/java/org/opendaylight/yangtools/odlext/parser/ContextReferenceTest.java
parser/odlext-parser-support/src/test/java/org/opendaylight/yangtools/odlext/parser/MountTest.java
parser/rfc6241-parser-support/src/test/java/org/opendaylight/yangtools/rfc6241/parser/NetconfTest.java
parser/rfc6536-parser-support/src/test/java/org/opendaylight/yangtools/rfc6536/parser/NACMTest.java
parser/rfc6643-parser-support/src/test/java/org/opendaylight/yangtools/rfc6643/parser/IetfYangSmiv2ExtensionPluginTest.java
parser/rfc7952-parser-support/src/test/java/org/opendaylight/yangtools/rfc7952/parser/AnnotationTest.java
parser/rfc8040-parser-support/src/test/java/org/opendaylight/yangtools/rfc8040/parser/AbstractYangDataTest.java
parser/rfc8528-parser-support/src/test/java/org/opendaylight/yangtools/rfc8528/parser/MountPointTest.java
parser/rfc8639-parser-support/src/test/java/org/opendaylight/yangtools/rfc8639/parser/SubscribedNotificationsTest.java
parser/rfc8819-parser-support/src/test/java/org/opendaylight/yangtools/rfc8819/parser/ModuleTagTest.java
parser/yang-ir/pom.xml
parser/yang-ir/src/main/java/module-info.java
parser/yang-ir/src/main/java/org/opendaylight/yangtools/yang/ir/YangIRSchemaSource.java [moved from yang/yang-repo-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/YangIRSchemaSource.java with 71% similarity]
parser/yang-parser-api/src/main/java/org/opendaylight/yangtools/yang/parser/api/YangLibModule.java
parser/yang-parser-api/src/main/java/org/opendaylight/yangtools/yang/parser/api/YangLibModuleSet.java
parser/yang-parser-api/src/main/java/org/opendaylight/yangtools/yang/parser/api/YangLibResolver.java
parser/yang-parser-api/src/main/java/org/opendaylight/yangtools/yang/parser/api/YangLibSubmodule.java
parser/yang-parser-api/src/main/java/org/opendaylight/yangtools/yang/parser/api/YangParser.java
parser/yang-parser-api/src/main/java/org/opendaylight/yangtools/yang/parser/api/YangSyntaxErrorException.java
parser/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/DefaultYangLibResolver.java
parser/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/DefaultYangParser.java
parser/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/repo/AssembleSources.java
parser/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/repo/DependencyResolver.java
parser/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/repo/RevisionDependencyResolver.java
parser/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/repo/SharedEffectiveModelContextFactory.java
parser/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/repo/SharedSchemaRepository.java
parser/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/repo/SourceIdMismatchDetector.java
parser/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/repo/YangTextSchemaContextResolver.java
parser/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/impl/YT1193Test.java
parser/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/AbstractSchemaRepositoryTest.java
parser/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/DependencyResolverTest.java
parser/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/MultipleRevImportBug6875Test.java
parser/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/OpenconfigVerSharedSchemaRepositoryTest.java
parser/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/SettableSchemaProvider.java
parser/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/SharedEffectiveModelContextFactoryTest.java
parser/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/SharedSchemaRepositoryTest.java
parser/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/SharedSchemaRepositoryWithFeaturesTest.java
parser/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/YT1428Test.java
parser/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/YangTextSchemaContextResolverTest.java
parser/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/BuildGlobalContext.java
parser/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/ReactorStmtCtx.java
parser/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/RootStatementContext.java
parser/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/SourceSpecificContext.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/repo/TextToIRTransformer.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/repo/YangErrorListener.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/repo/YangModelDependencyInfo.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/repo/YangStatementStreamSource.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/repo/YinStatementStreamSource.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/repo/YinTextToDomTransformer.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/import_/ImportStatementSupport.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/import_/ImportedVersionNamespace.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/import_/RevisionImport.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/BelongsToStatementSupport.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/IncludeStatementSupport.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/module/ModuleStatementSupport.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/submodule/SubmoduleStatementSupport.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/parser/rfc7950/antlr/IOSupportTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/StmtTestUtils.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/TestUtils.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileStmtTest.java
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/ParserNamespaces.java
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/NamespaceKeyCriterion.java
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/ReactorException.java
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/SomeModifiersUnresolvedException.java
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/StmtContext.java
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/StatementStreamSource.java
parser/yang-test-util/src/main/java/org/opendaylight/yangtools/yang/test/util/LiteralYangTextSource.java [moved from parser/yang-test-util/src/main/java/org/opendaylight/yangtools/yang/test/util/LiteralYangTextSchemaSource.java with 71% similarity]
parser/yang-test-util/src/main/java/org/opendaylight/yangtools/yang/test/util/YangParserTestUtils.java
plugin/plugin-generator-api/src/main/java/module-info.java
plugin/plugin-generator-api/src/main/java/org/opendaylight/yangtools/plugin/generator/api/ModuleResourceResolver.java
plugin/yang-maven-plugin/src/main/java/org/opendaylight/yangtools/yang2sources/plugin/ContextHolder.java
plugin/yang-maven-plugin/src/main/java/org/opendaylight/yangtools/yang2sources/plugin/ProcessorModuleReactor.java
plugin/yang-maven-plugin/src/main/java/org/opendaylight/yangtools/yang2sources/plugin/ScannedDependency.java
plugin/yang-maven-plugin/src/main/java/org/opendaylight/yangtools/yang2sources/plugin/Util.java
plugin/yang-maven-plugin/src/main/java/org/opendaylight/yangtools/yang2sources/plugin/YangProvider.java
plugin/yang-maven-plugin/src/main/java/org/opendaylight/yangtools/yang2sources/plugin/YangToSourcesProcessor.java
plugin/yang-maven-plugin/src/test/java/org/opendaylight/yangtools/yang2sources/plugin/FilenameResolutionTest.java
tools/yang-model-validator/src/main/java/org/opendaylight/yangtools/yang/validator/SystemTestUtils.java
yang/yang-repo-api/pom.xml
yang/yang-repo-api/src/main/java/module-info.java
yang/yang-repo-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/EffectiveModelContextFactory.java
yang/yang-repo-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/MissingSchemaSourceException.java
yang/yang-repo-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/SchemaRepository.java
yang/yang-repo-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/SchemaResolutionException.java
yang/yang-repo-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/SchemaSourceFilter.java
yang/yang-repo-fs/src/main/java/org/opendaylight/yangtools/yang/model/repo/fs/FilesystemSchemaSourceCache.java
yang/yang-repo-fs/src/test/java/org/opendaylight/yangtools/yang/model/repo/fs/FilesystemSchemaSourceCacheIntegrationTest.java
yang/yang-repo-fs/src/test/java/org/opendaylight/yangtools/yang/model/repo/fs/FilesystemSchemaSourceCacheTest.java
yang/yang-repo-spi/src/main/java/org/opendaylight/yangtools/yang/model/repo/spi/AbstractSchemaRepository.java
yang/yang-repo-spi/src/main/java/org/opendaylight/yangtools/yang/model/repo/spi/AbstractSchemaSourceCache.java
yang/yang-repo-spi/src/main/java/org/opendaylight/yangtools/yang/model/repo/spi/GuavaSchemaSourceCache.java
yang/yang-repo-spi/src/main/java/org/opendaylight/yangtools/yang/model/repo/spi/PotentialSchemaSource.java
yang/yang-repo-spi/src/main/java/org/opendaylight/yangtools/yang/model/repo/spi/SchemaSourceListener.java
yang/yang-repo-spi/src/main/java/org/opendaylight/yangtools/yang/model/repo/spi/SchemaSourceProvider.java
yang/yang-repo-spi/src/main/java/org/opendaylight/yangtools/yang/model/repo/spi/SchemaSourceRegistry.java
yang/yang-repo-spi/src/main/java/org/opendaylight/yangtools/yang/model/repo/spi/SchemaSourceTransformer.java
yang/yang-repo-spi/src/main/java/org/opendaylight/yangtools/yang/model/repo/spi/SoftSchemaSourceCache.java
yang/yang-repo-spi/src/test/java/org/opendaylight/yangtools/yang/model/repo/spi/GuavaSchemaSourceCacheTest.java
yang/yang-repo-spi/src/test/java/org/opendaylight/yangtools/yang/model/repo/spi/PotentialSchemaSourceTest.java
yang/yang-repo-spi/src/test/java/org/opendaylight/yangtools/yang/model/repo/spi/SchemaSourceTransformerTest.java
yang/yang-repo-spi/src/test/java/org/opendaylight/yangtools/yang/model/repo/spi/SoftSchemaSourceCacheTest.java

index abf5544729dcc768c121834d421ff52781d2fea4..99e72e9e8e57d47d4488a5aea4393709d0870450 100644 (file)
@@ -8,6 +8,7 @@
 module org.opendaylight.yangtools.yang.model.api {
     exports org.opendaylight.yangtools.yang.model.api;
     exports org.opendaylight.yangtools.yang.model.api.meta;
+    exports org.opendaylight.yangtools.yang.model.api.source;
     exports org.opendaylight.yangtools.yang.model.api.stmt;
     exports org.opendaylight.yangtools.yang.model.api.stmt.compat;
     exports org.opendaylight.yangtools.yang.model.api.type;
similarity index 98%
rename from yang/yang-repo-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/SourceIdentifier.java
rename to model/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/source/SourceIdentifier.java
index 05b1da6f823d484481bb4a749aea4896411689ff..1293220de778ae0bc79dd1d7c65c6224168f3d0d 100644 (file)
@@ -5,7 +5,7 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-package org.opendaylight.yangtools.yang.model.repo.api;
+package org.opendaylight.yangtools.yang.model.api.source;
 
 import static java.util.Objects.requireNonNull;
 
similarity index 64%
rename from yang/yang-repo-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/SchemaSourceRepresentation.java
rename to model/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/source/SourceRepresentation.java
index 7b923dc7fe6e6bf992f81d8e0c736bd719de4c38..b0058e3be0cf0b68941166d888bb8a2f9c390ec1 100644 (file)
@@ -5,12 +5,10 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-package org.opendaylight.yangtools.yang.model.repo.api;
+package org.opendaylight.yangtools.yang.model.api.source;
 
-import com.google.common.annotations.Beta;
-import java.util.Optional;
 import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.yangtools.concepts.Identifiable;
+import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.yangtools.concepts.Immutable;
 
 /**
@@ -26,28 +24,30 @@ import org.opendaylight.yangtools.concepts.Immutable;
  * <p>
  * Typical examples of a schema source representation include:
  * <ul>
- * <li>a {@link java.lang.String} - textual representation of source code
- * <li>a {@link java.io.InputStream} - input stream containing source code
- * <li>a {@link com.google.common.io.ByteSource} - source for input streams
- * containing source code
- * <li>Parsed abstract syntax tree (AST), which is the result of a syntactic parser
+ *   <li>a {@link java.lang.String} - textual representation of source code</li>
+ *   <li>a {@link java.io.InputStream} - input stream containing source code</li>
+ *   <li>a {@link com.google.common.io.ByteSource} - source for input streams containing source code</li>
+ *   <li>Parsed abstract syntax tree (AST), which is the result of a syntactic parser</li>
  * </ul>
  *
  * <p>
  * Implementations of this interface expected to comply with the {@link Immutable} contract.
  */
-@Beta
-public sealed interface SchemaSourceRepresentation extends Identifiable<SourceIdentifier>, Immutable
-        permits YangSchemaSourceRepresentation, YinSchemaSourceRepresentation {
-    @Override
-    SourceIdentifier getIdentifier();
+public sealed interface SourceRepresentation extends Immutable
+        permits YangSourceRepresentation, YinSourceRepresentation {
+    /**
+     * The {@link SourceIdentifier} of this source.
+     *
+     * @return {@link SourceIdentifier} of this source
+     */
+    @NonNull SourceIdentifier sourceId();
 
     /**
      * Return the concrete representation type.
      *
      * @return The type of representation.
      */
-    @NonNull Class<? extends SchemaSourceRepresentation> getType();
+    @NonNull Class<? extends SourceRepresentation> getType();
 
     /**
      * Return the symbolic name, if available. This name has no semantic meaning beyond being useful for debugging
@@ -55,5 +55,5 @@ public sealed interface SchemaSourceRepresentation extends Identifiable<SourceId
      *
      * @return Symbolic name, if available
      */
-    Optional<String> getSymbolicName();
+    @Nullable String symbolicName();
 }
@@ -5,12 +5,12 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-package org.opendaylight.yangtools.yang.model.repo.api;
+package org.opendaylight.yangtools.yang.model.api.source;
 
 /**
- * A YIN {@link SchemaSourceRepresentation}.
+ * A YANG {@link SourceRepresentation}.
  */
-public non-sealed interface YinSchemaSourceRepresentation extends SchemaSourceRepresentation {
+public non-sealed interface YangSourceRepresentation extends SourceRepresentation {
     @Override
-    Class<? extends YinSchemaSourceRepresentation> getType();
+    Class<? extends YangSourceRepresentation> getType();
 }
@@ -5,12 +5,12 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-package org.opendaylight.yangtools.yang.model.repo.api;
+package org.opendaylight.yangtools.yang.model.api.source;
 
 /**
- * A YANG {@link SchemaSourceRepresentation}.
+ * A YIN {@link SourceRepresentation}.
  */
-public non-sealed interface YangSchemaSourceRepresentation extends SchemaSourceRepresentation {
+public non-sealed interface YinSourceRepresentation extends SourceRepresentation {
     @Override
-    Class<? extends YangSchemaSourceRepresentation> getType();
+    Class<? extends YinSourceRepresentation> getType();
 }
diff --git a/model/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/source/package-info.java b/model/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/source/package-info.java
new file mode 100644 (file)
index 0000000..456dd68
--- /dev/null
@@ -0,0 +1,15 @@
+/*
+ * Copyright (c) 2024 PANTHEON.tech, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+/**
+ * Base interfaces for identifying and source of YANG and YIN models. Two main entry points are
+ * <ol>
+ *   <li>{@link SourceIdentifier}, i.e. how a model source is known</li>
+ *   <li>{@link SourceRepresentation}, i.e. its format</li>
+ * </ol>
+ */
+package org.opendaylight.yangtools.yang.model.api.source;
\ No newline at end of file
index a236b676777c6a9cf27d2639e9f78a7a31fc868e..1e461e66c5410c645f18197f95b12665007a5e9c 100644 (file)
@@ -14,9 +14,9 @@ import java.util.Set;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.SourceRepresentation;
 import org.opendaylight.yangtools.yang.model.repo.api.EffectiveModelContextFactory;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.spi.PotentialSchemaSource;
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceListener;
 import org.opendaylight.yangtools.yang.parser.repo.SharedSchemaRepository;
@@ -50,7 +50,7 @@ public class SimpleModuleTest {
                 }
 
                 @Override
-                public void schemaSourceEncountered(final SchemaSourceRepresentation source) {
+                public void schemaSourceEncountered(final SourceRepresentation source) {
                     // NOOP
                 }
             })) {
index cfafe51912be4ede51055bc51aed42fdc3d829b2..2f7d3b13c8b354260c5b7c7558705039752a4c20 100644 (file)
@@ -19,6 +19,7 @@ import org.opendaylight.yangtools.yang.model.api.CaseSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ElementCountConstraint;
 import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.api.stmt.ActionEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ActionStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.AnydataEffectiveStatement;
@@ -148,7 +149,6 @@ import org.opendaylight.yangtools.yang.model.api.stmt.YangVersionEffectiveStatem
 import org.opendaylight.yangtools.yang.model.api.stmt.YangVersionStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.YinElementEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.YinElementStatement;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.ri.stmt.impl.decl.EmptyRequireInstanceStatement;
 import org.opendaylight.yangtools.yang.model.ri.stmt.impl.decl.EmptyStatusStatement;
 import org.opendaylight.yangtools.yang.model.ri.stmt.impl.decl.EmptyYangVersionStatement;
@@ -524,7 +524,7 @@ public final class EffectiveStatements {
     public static ImportEffectiveStatement createImport(final ImportStatement declared,
             final ImmutableList<? extends EffectiveStatement<?, ?>> substatements,
             final SourceIdentifier importedSource) {
-        return new ImportEffectiveStatementImpl(declared, substatements, importedSource);
+        return new ImportEffectiveStatementImpl(declared, substatements, importedSource.revision());
     }
 
     public static IncludeEffectiveStatement createInclude(final IncludeStatement declared,
index 09aad9b3cf821dad86cbbff7f6d1cebabef8b3db..f5af6c869fd6376d00e8fc990ad705ed4d61e9da 100644 (file)
@@ -17,7 +17,6 @@ import org.opendaylight.yangtools.yang.model.api.ModuleImport;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ImportEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ImportStatement;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.spi.meta.AbstractDeclaredEffectiveStatement.DefaultArgument.WithSubstatements;
 import org.opendaylight.yangtools.yang.model.spi.meta.EffectiveStatementMixins.DocumentedNodeMixin;
 
@@ -26,10 +25,9 @@ public final class ImportEffectiveStatementImpl extends WithSubstatements<Unqual
     private final @Nullable Revision revision;
 
     public ImportEffectiveStatementImpl(final ImportStatement declared,
-            final ImmutableList<? extends EffectiveStatement<?, ?>> substatements,
-            final @NonNull SourceIdentifier importedSource) {
+            final ImmutableList<? extends EffectiveStatement<?, ?>> substatements, final @NonNull Revision revision) {
         super(declared, substatements);
-        revision = importedSource.revision();
+        this.revision = revision;
     }
 
     @Override
index 4a54a3f500b3394aba46e18e380c5141f3dfeea8..db7d860963e5459747079eff45b413a034d27802 100644 (file)
@@ -8,6 +8,7 @@
 module org.opendaylight.yangtools.yang.model.spi {
     exports org.opendaylight.yangtools.yang.model.spi;
     exports org.opendaylight.yangtools.yang.model.spi.meta;
+    exports org.opendaylight.yangtools.yang.model.spi.source;
 
     requires transitive com.google.common;
     requires transitive org.opendaylight.yangtools.concepts;
@@ -5,7 +5,7 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-package org.opendaylight.yangtools.yang.model.repo.api;
+package org.opendaylight.yangtools.yang.model.spi.source;
 
 import static java.util.Objects.requireNonNull;
 
@@ -13,15 +13,15 @@ import com.google.common.base.MoreObjects.ToStringHelper;
 import com.google.common.io.CharSource;
 import java.io.IOException;
 import java.io.Reader;
-import java.util.Optional;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.concepts.Delegator;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 
-final class DelegatedYangTextSchemaSource extends YangTextSchemaSource implements Delegator<CharSource> {
+final class DelegatedYangTextSource extends YangTextSource implements Delegator<CharSource> {
     private final @NonNull CharSource delegate;
 
-    DelegatedYangTextSchemaSource(final SourceIdentifier identifier, final CharSource delegate) {
-        super(identifier);
+    DelegatedYangTextSource(final SourceIdentifier sourceId, final CharSource delegate) {
+        super(sourceId);
         this.delegate = requireNonNull(delegate);
     }
 
@@ -36,8 +36,8 @@ final class DelegatedYangTextSchemaSource extends YangTextSchemaSource implement
     }
 
     @Override
-    public Optional<String> getSymbolicName() {
-        return Optional.of("[" + delegate.toString() + "]");
+    public String symbolicName() {
+        return "[" + delegate.toString() + "]";
     }
 
     @Override
@@ -5,7 +5,7 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-package org.opendaylight.yangtools.yang.model.repo.api;
+package org.opendaylight.yangtools.yang.model.spi.source;
 
 import static java.util.Objects.requireNonNull;
 
@@ -13,15 +13,15 @@ import com.google.common.base.MoreObjects.ToStringHelper;
 import com.google.common.io.ByteSource;
 import java.io.IOException;
 import java.io.InputStream;
-import java.util.Optional;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.concepts.Delegator;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 
-final class DelegatedYinTextSchemaSource extends YinTextSchemaSource implements Delegator<ByteSource> {
+final class DelegatedYinTextSource extends YinTextSource implements Delegator<ByteSource> {
     private final @NonNull ByteSource delegate;
 
-    DelegatedYinTextSchemaSource(final SourceIdentifier identifier, final ByteSource delegate) {
-        super(identifier);
+    DelegatedYinTextSource(final SourceIdentifier sourceId, final ByteSource delegate) {
+        super(sourceId);
         this.delegate = requireNonNull(delegate);
     }
 
@@ -36,8 +36,8 @@ final class DelegatedYinTextSchemaSource extends YinTextSchemaSource implements
     }
 
     @Override
-    public Optional<String> getSymbolicName() {
-        return Optional.of("[" + delegate.toString() + "]");
+    public String symbolicName() {
+        return "[" + delegate.toString() + "]";
     }
 
     @Override
@@ -5,7 +5,7 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-package org.opendaylight.yangtools.yang.model.repo.api;
+package org.opendaylight.yangtools.yang.model.spi.source;
 
 import static java.util.Objects.requireNonNull;
 
@@ -15,19 +15,19 @@ import java.io.InputStreamReader;
 import java.io.Reader;
 import java.net.URL;
 import java.nio.charset.Charset;
-import java.util.Optional;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.concepts.Delegator;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 
 /**
- * A resource-backed {@link YinTextSchemaSource}.
+ * A resource-backed {@link YangTextSource}.
  */
-final class ResourceYangTextSchemaSource extends YangTextSchemaSource implements Delegator<URL> {
+final class ResourceYangTextSource extends YangTextSource implements Delegator<URL> {
     private final @NonNull URL url;
     private final @NonNull Charset charset;
 
-    ResourceYangTextSchemaSource(final SourceIdentifier identifier, final URL url, final Charset charset) {
-        super(identifier);
+    ResourceYangTextSource(final SourceIdentifier sourceId, final URL url, final Charset charset) {
+        super(sourceId);
         this.url = requireNonNull(url);
         this.charset = requireNonNull(charset);
     }
@@ -48,7 +48,7 @@ final class ResourceYangTextSchemaSource extends YangTextSchemaSource implements
     }
 
     @Override
-    public Optional<String> getSymbolicName() {
-        return Optional.of(url.toString());
+    public String symbolicName() {
+        return url.toString();
     }
 }
similarity index 71%
rename from yang/yang-repo-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/ResourceYinTextSchemaSource.java
rename to model/yang-model-spi/src/main/java/org/opendaylight/yangtools/yang/model/spi/source/ResourceYinTextSource.java
index 0713ff9b799b9f11f9337372ae9c8ad429df4e30..3c9b1b1dcefc03f01095fe2dc2a7ed3b3736b667 100644 (file)
@@ -5,7 +5,7 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-package org.opendaylight.yangtools.yang.model.repo.api;
+package org.opendaylight.yangtools.yang.model.spi.source;
 
 import static java.util.Objects.requireNonNull;
 
@@ -13,18 +13,18 @@ import com.google.common.base.MoreObjects.ToStringHelper;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
-import java.util.Optional;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.concepts.Delegator;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 
 /**
- * A resource-backed {@link YangTextSchemaSource}.
+ * A resource-backed {@link YinTextSource}.
  */
-final class ResourceYinTextSchemaSource extends YinTextSchemaSource implements Delegator<URL> {
+final class ResourceYinTextSource extends YinTextSource implements Delegator<URL> {
     private final @NonNull URL url;
 
-    ResourceYinTextSchemaSource(final SourceIdentifier identifier, final URL url) {
-        super(identifier);
+    ResourceYinTextSource(final SourceIdentifier sourceId, final URL url) {
+        super(sourceId);
         this.url = requireNonNull(url);
     }
 
@@ -44,7 +44,7 @@ final class ResourceYinTextSchemaSource extends YinTextSchemaSource implements D
     }
 
     @Override
-    public Optional<String> getSymbolicName() {
-        return Optional.of(url.toString());
+    public String symbolicName() {
+        return url.toString();
     }
 }
similarity index 60%
rename from yang/yang-repo-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/StringYangTextSchemaSource.java
rename to model/yang-model-spi/src/main/java/org/opendaylight/yangtools/yang/model/spi/source/StringYangTextSource.java
index 9ac1d59c538d00f75d148c714ce6af1a22cdd21d..a5fb641072106c579dd9432a98bcafaf7672a7cd 100644 (file)
@@ -5,37 +5,37 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-package org.opendaylight.yangtools.yang.model.repo.api;
+package org.opendaylight.yangtools.yang.model.spi.source;
 
 import static java.util.Objects.requireNonNull;
 
 import java.io.Reader;
 import java.io.StringReader;
-import java.util.Optional;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 
 /**
- * A {@link YangTextSchemaSource} with content readily available.
+ * A {@link YangTextSource} with content readily available.
  */
-public class StringYangTextSchemaSource extends YangTextSchemaSource {
+public class StringYangTextSource extends YangTextSource {
     private final @Nullable String symbolicName;
     private final @NonNull String content;
 
-    public StringYangTextSchemaSource(final SourceIdentifier identifier, final String content) {
-        this(identifier, content, null);
+    public StringYangTextSource(final SourceIdentifier sourceId, final String content) {
+        this(sourceId, content, null);
     }
 
-    public StringYangTextSchemaSource(final SourceIdentifier identifier, final String content,
+    public StringYangTextSource(final SourceIdentifier sourceId, final String content,
             final @Nullable String symbolicName) {
-        super(identifier);
+        super(sourceId);
         this.content = requireNonNull(content);
         this.symbolicName = symbolicName;
     }
 
     @Override
-    public final Optional<String> getSymbolicName() {
-        return Optional.ofNullable(symbolicName);
+    public final String symbolicName() {
+        return symbolicName;
     }
 
     @Override
similarity index 75%
rename from yang/yang-repo-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/YangTextFileSchemaSource.java
rename to model/yang-model-spi/src/main/java/org/opendaylight/yangtools/yang/model/spi/source/YangTextFileSource.java
index c17d96bd9269610b85286edc6e4e40e53ffd8414..06890023dda1770619359fe0351b689841360dc4 100644 (file)
@@ -5,7 +5,7 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-package org.opendaylight.yangtools.yang.model.repo.api;
+package org.opendaylight.yangtools.yang.model.spi.source;
 
 import static java.util.Objects.requireNonNull;
 
@@ -16,21 +16,19 @@ import java.io.Reader;
 import java.nio.charset.Charset;
 import java.nio.file.Files;
 import java.nio.file.Path;
-import java.util.Optional;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.concepts.Delegator;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 
 /**
- * A {@link YangTextSchemaSource} backed by a file.
- *
- * @author Robert Varga
+ * A {@link YangTextSource} backed by a file.
  */
-final class YangTextFileSchemaSource extends YangTextSchemaSource implements Delegator<Path> {
+final class YangTextFileSource extends YangTextSource implements Delegator<Path> {
     private final @NonNull Path path;
     private final @NonNull Charset charset;
 
-    YangTextFileSchemaSource(final SourceIdentifier identifier, final Path path, final Charset charset) {
-        super(identifier);
+    YangTextFileSource(final SourceIdentifier sourceId, final Path path, final Charset charset) {
+        super(sourceId);
         this.path = requireNonNull(path);
         this.charset = requireNonNull(charset);
     }
@@ -51,9 +49,9 @@ final class YangTextFileSchemaSource extends YangTextSchemaSource implements Del
     }
 
     @Override
-    public Optional<String> getSymbolicName() {
+    public String symbolicName() {
         // FIXME: NEXT: this is forcing internal normalization. I think this boils down to providing Path back, which
         //        is essentially getDelegate() anyway. Perhaps expose it as PathAware?
-        return Optional.of(path.toString());
+        return path.toString();
     }
 }
similarity index 73%
rename from yang/yang-repo-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/YangTextSchemaSource.java
rename to model/yang-model-spi/src/main/java/org/opendaylight/yangtools/yang/model/spi/source/YangTextSource.java
index ec5a93ff9f0c7cf8b246eca9658a33564a9d489f..335120ed191dc4fe9727d19341429f51637d00ce 100644 (file)
@@ -5,14 +5,13 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-package org.opendaylight.yangtools.yang.model.repo.api;
+package org.opendaylight.yangtools.yang.model.spi.source;
 
 import static com.google.common.base.Preconditions.checkArgument;
 import static java.util.Objects.requireNonNull;
 import static org.opendaylight.yangtools.yang.common.YangConstants.RFC6020_YANG_FILE_EXTENSION;
 import static org.opendaylight.yangtools.yang.common.YangNames.parseFilename;
 
-import com.google.common.annotations.Beta;
 import com.google.common.base.MoreObjects;
 import com.google.common.base.MoreObjects.ToStringHelper;
 import com.google.common.io.ByteSource;
@@ -26,16 +25,17 @@ import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.YangSourceRepresentation;
 
 /**
  * YANG text schema source representation. Exposes an RFC6020 or RFC7950 text representation as an {@link InputStream}.
  */
-@Beta
-public abstract class YangTextSchemaSource extends CharSource implements YangSchemaSourceRepresentation {
-    private final @NonNull SourceIdentifier identifier;
+public abstract class YangTextSource extends CharSource implements YangSourceRepresentation {
+    private final @NonNull SourceIdentifier sourceId;
 
-    protected YangTextSchemaSource(final SourceIdentifier identifier) {
-        this.identifier = requireNonNull(identifier);
+    protected YangTextSource(final SourceIdentifier sourceId) {
+        this.sourceId = requireNonNull(sourceId);
     }
 
     public static @NonNull SourceIdentifier identifierFromFilename(final String name) {
@@ -56,7 +56,7 @@ public abstract class YangTextSchemaSource extends CharSource implements YangSch
      * @param charset Expected character set
      * @return A new YangTextSchemaSource
      */
-    public static @NonNull YangTextSchemaSource delegateForByteSource(final SourceIdentifier identifier,
+    public static @NonNull YangTextSource delegateForByteSource(final SourceIdentifier identifier,
             final ByteSource delegate, final Charset charset) {
         return delegateForCharSource(identifier, delegate.asCharSource(charset));
     }
@@ -70,7 +70,7 @@ public abstract class YangTextSchemaSource extends CharSource implements YangSch
      * @return A new YangTextSchemaSource
      * @throws IllegalArgumentException if the file name has invalid format
      */
-    public static @NonNull YangTextSchemaSource delegateForByteSource(final String fileName,
+    public static @NonNull YangTextSource delegateForByteSource(final String fileName,
             final ByteSource delegate, final Charset charset) {
         return delegateForCharSource(fileName, delegate.asCharSource(charset));
     }
@@ -83,9 +83,9 @@ public abstract class YangTextSchemaSource extends CharSource implements YangSch
      * @param delegate Backing CharSource instance
      * @return A new YangTextSchemaSource
      */
-    public static @NonNull YangTextSchemaSource delegateForCharSource(final SourceIdentifier identifier,
+    public static @NonNull YangTextSource delegateForCharSource(final SourceIdentifier identifier,
             final CharSource delegate) {
-        return new DelegatedYangTextSchemaSource(identifier, delegate);
+        return new DelegatedYangTextSource(identifier, delegate);
     }
 
     /**
@@ -97,9 +97,9 @@ public abstract class YangTextSchemaSource extends CharSource implements YangSch
      * @return A new YangTextSchemaSource
      * @throws IllegalArgumentException if the file name has invalid format
      */
-    public static @NonNull YangTextSchemaSource delegateForCharSource(final String fileName,
+    public static @NonNull YangTextSource delegateForCharSource(final String fileName,
             final CharSource delegate) {
-        return new DelegatedYangTextSchemaSource(identifierFromFilename(fileName), delegate);
+        return new DelegatedYangTextSource(identifierFromFilename(fileName), delegate);
     }
 
     /**
@@ -111,7 +111,7 @@ public abstract class YangTextSchemaSource extends CharSource implements YangSch
      * @throws IllegalArgumentException if the file name has invalid format or if the supplied File is not a file
      * @throws NullPointerException if file is {@code null}
      */
-    public static @NonNull YangTextSchemaSource forPath(final Path path) {
+    public static @NonNull YangTextSource forPath(final Path path) {
         return forPath(path, identifierFromFilename(path.toFile().getName()));
     }
 
@@ -124,7 +124,7 @@ public abstract class YangTextSchemaSource extends CharSource implements YangSch
      * @throws NullPointerException if any argument is {@code null}
      * @throws IllegalArgumentException if the supplied path is not a regular file
      */
-    public static @NonNull YangTextSchemaSource forPath(final Path path, final SourceIdentifier identifier) {
+    public static @NonNull YangTextSource forPath(final Path path, final SourceIdentifier identifier) {
         return forPath(path, identifier, StandardCharsets.UTF_8);
     }
 
@@ -138,26 +138,26 @@ public abstract class YangTextSchemaSource extends CharSource implements YangSch
      * @throws NullPointerException if any argument is {@code null}
      * @throws IllegalArgumentException if the supplied path is not a regular file
      */
-    public static @NonNull YangTextSchemaSource forPath(final Path path, final SourceIdentifier identifier,
+    public static @NonNull YangTextSource forPath(final Path path, final SourceIdentifier identifier,
             final Charset charset) {
         checkArgument(Files.isRegularFile(path), "Supplied path %s is not a regular file", path);
-        return new YangTextFileSchemaSource(identifier, path, charset);
+        return new YangTextFileSource(identifier, path, charset);
     }
 
     /**
-     * Create a new {@link YangTextSchemaSource} backed by a resource available in the ClassLoader where this
+     * Create a new {@link YangTextSource} backed by a resource available in the ClassLoader where this
      * class resides.
      *
      * @param resourceName Resource name
      * @return A new instance.
      * @throws IllegalArgumentException if the resource does not exist or if the name has invalid format
      */
-    public static @NonNull YangTextSchemaSource forResource(final String resourceName) {
-        return forResource(YangTextSchemaSource.class, resourceName);
+    public static @NonNull YangTextSource forResource(final String resourceName) {
+        return forResource(YangTextSource.class, resourceName);
     }
 
     /**
-     * Create a new {@link YangTextSchemaSource} backed by a resource by a resource available on the ClassLoader
+     * Create a new {@link YangTextSource} backed by a resource by a resource available on the ClassLoader
      * which loaded the specified class.
      *
      * @param clazz Class reference
@@ -165,12 +165,12 @@ public abstract class YangTextSchemaSource extends CharSource implements YangSch
      * @return A new instance.
      * @throws IllegalArgumentException if the resource does not exist or if the name has invalid format
      */
-    public static @NonNull YangTextSchemaSource forResource(final Class<?> clazz, final String resourceName) {
+    public static @NonNull YangTextSource forResource(final Class<?> clazz, final String resourceName) {
         return forResource(clazz, resourceName, StandardCharsets.UTF_8);
     }
 
     /**
-     * Create a new {@link YangTextSchemaSource} backed by a resource by a resource available on the ClassLoader
+     * Create a new {@link YangTextSource} backed by a resource by a resource available on the ClassLoader
      * which loaded the specified class.
      *
      * @param clazz Class reference
@@ -179,29 +179,29 @@ public abstract class YangTextSchemaSource extends CharSource implements YangSch
      * @return A new instance.
      * @throws IllegalArgumentException if the resource does not exist or if the name has invalid format
      */
-    public static @NonNull YangTextSchemaSource forResource(final Class<?> clazz, final String resourceName,
+    public static @NonNull YangTextSource forResource(final Class<?> clazz, final String resourceName,
             final Charset charset) {
         final String fileName = resourceName.substring(resourceName.lastIndexOf('/') + 1);
         final SourceIdentifier identifier = identifierFromFilename(fileName);
         final URL url = Resources.getResource(clazz, resourceName);
-        return new ResourceYangTextSchemaSource(identifier, url, charset);
+        return new ResourceYangTextSource(identifier, url, charset);
     }
 
 
     /**
-     * Create a new {@link YangTextSchemaSource} backed by a URL.
+     * Create a new {@link YangTextSource} backed by a URL.
      *
      * @param url Backing URL
      * @param identifier Source identifier
      * @return A new instance.
      * @throws NullPointerException if any argument is {@code null}
      */
-    public static @NonNull YangTextSchemaSource forURL(final URL url, final SourceIdentifier identifier) {
+    public static @NonNull YangTextSource forURL(final URL url, final SourceIdentifier identifier) {
         return forURL(url, identifier, StandardCharsets.UTF_8);
     }
 
     /**
-     * Create a new {@link YangTextSchemaSource} backed by a URL.
+     * Create a new {@link YangTextSource} backed by a URL.
      *
      * @param url Backing URL
      * @param identifier Source identifier
@@ -209,20 +209,19 @@ public abstract class YangTextSchemaSource extends CharSource implements YangSch
      * @return A new instance.
      * @throws NullPointerException if any argument is {@code null}
      */
-    public static @NonNull YangTextSchemaSource forURL(final URL url, final SourceIdentifier identifier,
+    public static @NonNull YangTextSource forURL(final URL url, final SourceIdentifier identifier,
             final Charset charset) {
-        return new ResourceYangTextSchemaSource(identifier, url, charset);
+        return new ResourceYangTextSource(identifier, url, charset);
     }
 
-
     @Override
-    public final SourceIdentifier getIdentifier() {
-        return identifier;
+    public final Class<YangTextSource> getType() {
+        return YangTextSource.class;
     }
 
     @Override
-    public final Class<YangTextSchemaSource> getType() {
-        return YangTextSchemaSource.class;
+    public final SourceIdentifier sourceId() {
+        return sourceId;
     }
 
     @Override
@@ -240,6 +239,6 @@ public abstract class YangTextSchemaSource extends CharSource implements YangSch
      * @return ToStringHelper supplied as input argument.
      */
     protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
-        return toStringHelper.add("identifier", identifier);
+        return toStringHelper.add("identifier", sourceId);
     }
 }
similarity index 72%
rename from yang/yang-repo-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/YinDomSchemaSource.java
rename to model/yang-model-spi/src/main/java/org/opendaylight/yangtools/yang/model/spi/source/YinDomSource.java
index 023aaf04580dad5829dda73440d5ba602b2be9df..bb42fa705f2f6e1ff3db4c07238b6990a88e46cd 100644 (file)
@@ -5,7 +5,7 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-package org.opendaylight.yangtools.yang.model.repo.api;
+package org.opendaylight.yangtools.yang.model.spi.source;
 
 import static com.google.common.base.Preconditions.checkArgument;
 import static java.util.Objects.requireNonNull;
@@ -16,7 +16,6 @@ import static org.opendaylight.yangtools.yang.model.api.YangStmtMapping.SUBMODUL
 
 import com.google.common.base.MoreObjects;
 import com.google.common.base.MoreObjects.ToStringHelper;
-import java.util.Optional;
 import javax.xml.transform.Source;
 import javax.xml.transform.TransformerException;
 import javax.xml.transform.TransformerFactory;
@@ -26,6 +25,7 @@ import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.YangConstants;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Attr;
@@ -34,10 +34,10 @@ import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
 /**
- * Utility {@link YinXmlSchemaSource} exposing a W3C {@link DOMSource} representation of YIN model.
+ * Utility {@link YinXmlSource} exposing a W3C {@link DOMSource} representation of YIN model.
  */
-public abstract class YinDomSchemaSource implements YinXmlSchemaSource {
-    private static final Logger LOG = LoggerFactory.getLogger(YinDomSchemaSource.class);
+public abstract sealed class YinDomSource implements YinXmlSource {
+    private static final Logger LOG = LoggerFactory.getLogger(YinDomSource.class);
     private static final TransformerFactory TRANSFORMER_FACTORY = TransformerFactory.newInstance();
     private static final QName REVISION_STMT = REVISION.getStatementName();
     private static final String MODULE_ARG = MODULE.getArgumentDefinition().orElseThrow()
@@ -45,19 +45,15 @@ public abstract class YinDomSchemaSource implements YinXmlSchemaSource {
     private static final String REVISION_ARG = REVISION.getArgumentDefinition().orElseThrow()
         .argumentName().getLocalName();
 
-    YinDomSchemaSource() {
-        // Prevent outside instantiation
-    }
-
     /**
-     * Create a new {@link YinDomSchemaSource} using an identifier and a source.
+     * Create a new {@link YinDomSource} using an identifier and a source.
      *
      * @param identifier Schema source identifier
      * @param source W3C DOM source
      * @param symbolicName Source symbolic name
-     * @return A new {@link YinDomSchemaSource} instance.
+     * @return A new {@link YinDomSource} instance.
      */
-    public static @NonNull YinDomSchemaSource create(final @NonNull SourceIdentifier identifier,
+    public static @NonNull YinDomSource create(final @NonNull SourceIdentifier identifier,
             final @NonNull DOMSource source, final @Nullable String symbolicName) {
 
         final Node root = source.getNode().getFirstChild();
@@ -90,7 +86,7 @@ public abstract class YinDomSchemaSource implements YinXmlSchemaSource {
         final Attr dateAttr = revisionStmt.getAttributeNode(REVISION_ARG);
         checkArgument(dateAttr != null, "No revision statement argument found in %s", revisionStmt);
 
-        final SourceIdentifier parsedId = new SourceIdentifier(nameAttr.getValue(), dateAttr.getValue());
+        final var parsedId = new SourceIdentifier(nameAttr.getValue(), dateAttr.getValue());
         final SourceIdentifier id;
         if (!parsedId.equals(identifier)) {
             LOG.debug("Changed identifier from {} to {}", identifier, parsedId);
@@ -103,45 +99,45 @@ public abstract class YinDomSchemaSource implements YinXmlSchemaSource {
     }
 
     /**
-     * Create a {@link YinDomSchemaSource} from a {@link YinXmlSchemaSource}. If the argument is already a
+     * Create a {@link YinDomSource} from a {@link YinXmlSource}. If the argument is already a
      * YinDomSchemaSource, this method returns the same instance. The source will be translated on first access,
      * at which point an {@link IllegalStateException} may be raised.
      *
      * @param xmlSchemaSource Backing schema source
-     * @return A {@link YinDomSchemaSource} instance
+     * @return A {@link YinDomSource} instance
      */
-    public static @NonNull YinDomSchemaSource lazyTransform(final YinXmlSchemaSource xmlSchemaSource) {
-        final YinDomSchemaSource cast = castSchemaSource(xmlSchemaSource);
+    public static @NonNull YinDomSource lazyTransform(final YinXmlSource xmlSchemaSource) {
+        final var cast = castSchemaSource(xmlSchemaSource);
         return cast != null ? cast : new Transforming(xmlSchemaSource);
     }
 
     /**
-     * Create a {@link YinDomSchemaSource} from a {@link YinXmlSchemaSource}. If the argument is already a
+     * Create a {@link YinDomSource} from a {@link YinXmlSource}. If the argument is already a
      * YinDomSchemaSource, this method returns the same instance. The source will be translated immediately.
      *
      * @param xmlSchemaSource Backing schema source
-     * @return A {@link YinDomSchemaSource} instance
+     * @return A {@link YinDomSource} instance
      * @throws TransformerException when the provided source fails to transform
      */
-    public static @NonNull YinDomSchemaSource transform(final YinXmlSchemaSource xmlSchemaSource)
+    public static @NonNull YinDomSource transform(final YinXmlSource xmlSchemaSource)
             throws TransformerException {
-        final YinDomSchemaSource cast = castSchemaSource(xmlSchemaSource);
+        final var cast = castSchemaSource(xmlSchemaSource);
         return cast != null ? cast :
-            create(xmlSchemaSource.getIdentifier(), transformSource(xmlSchemaSource.getSource()),
-                xmlSchemaSource.getSymbolicName().orElse(null));
+            create(xmlSchemaSource.sourceId(), transformSource(xmlSchemaSource.getSource()),
+                xmlSchemaSource.symbolicName());
     }
 
     @Override
-    public abstract DOMSource getSource();
+    public final Class<YinDomSource> getType() {
+        return YinDomSource.class;
+    }
 
     @Override
-    public final Class<YinDomSchemaSource> getType() {
-        return YinDomSchemaSource.class;
-    }
+    public abstract DOMSource getSource();
 
     @Override
     public final String toString() {
-        return addToStringAttributes(MoreObjects.toStringHelper(this).add("identifier", getIdentifier())).toString();
+        return addToStringAttributes(MoreObjects.toStringHelper(this).add("sourceId", sourceId())).toString();
     }
 
     /**
@@ -162,43 +158,43 @@ public abstract class YinDomSchemaSource implements YinXmlSchemaSource {
         return new DOMSource(result.getNode(), result.getSystemId());
     }
 
-    private static @Nullable YinDomSchemaSource castSchemaSource(final YinXmlSchemaSource xmlSchemaSource) {
-        if (xmlSchemaSource instanceof YinDomSchemaSource yinDom) {
+    private static @Nullable YinDomSource castSchemaSource(final YinXmlSource xmlSchemaSource) {
+        if (xmlSchemaSource instanceof YinDomSource yinDom) {
             return yinDom;
         }
 
-        final Source source = xmlSchemaSource.getSource();
+        final var source = xmlSchemaSource.getSource();
         if (source instanceof DOMSource dom) {
-            return create(xmlSchemaSource.getIdentifier(), dom, xmlSchemaSource.getSymbolicName().orElse(null));
+            return create(xmlSchemaSource.sourceId(), dom, xmlSchemaSource.symbolicName());
         }
         return null;
     }
 
-    private static final class Simple extends YinDomSchemaSource {
-        private final @NonNull SourceIdentifier identifier;
+    private static final class Simple extends YinDomSource {
+        private final @NonNull SourceIdentifier sourceId;
         private final @NonNull DOMSource source;
         private final String symbolicName;
 
-        Simple(final @NonNull SourceIdentifier identifier, final @NonNull DOMSource source,
+        Simple(final @NonNull SourceIdentifier sourceId, final @NonNull DOMSource source,
                 final @Nullable String symbolicName) {
-            this.identifier = requireNonNull(identifier);
+            this.sourceId = requireNonNull(sourceId);
             this.source = requireNonNull(source);
             this.symbolicName = symbolicName;
         }
 
         @Override
-        public DOMSource getSource() {
-            return source;
+        public SourceIdentifier sourceId() {
+            return sourceId;
         }
 
         @Override
-        public SourceIdentifier getIdentifier() {
-            return identifier;
+        public DOMSource getSource() {
+            return source;
         }
 
         @Override
-        public Optional<String> getSymbolicName() {
-            return Optional.ofNullable(symbolicName);
+        public String symbolicName() {
+            return symbolicName;
         }
 
         @Override
@@ -207,14 +203,25 @@ public abstract class YinDomSchemaSource implements YinXmlSchemaSource {
         }
     }
 
-    private static final class Transforming extends YinDomSchemaSource {
-        private final YinXmlSchemaSource xmlSchemaSource;
+    private static final class Transforming extends YinDomSource {
+        private final YinXmlSource xmlSchemaSource;
+
         private volatile DOMSource source;
 
-        Transforming(final YinXmlSchemaSource xmlSchemaSource) {
+        Transforming(final YinXmlSource xmlSchemaSource) {
             this.xmlSchemaSource = requireNonNull(xmlSchemaSource);
         }
 
+        @Override
+        public SourceIdentifier sourceId() {
+            return xmlSchemaSource.sourceId();
+        }
+
+        @Override
+        public String symbolicName() {
+            return xmlSchemaSource.symbolicName();
+        }
+
         @Override
         public DOMSource getSource() {
             DOMSource ret = source;
@@ -235,16 +242,6 @@ public abstract class YinDomSchemaSource implements YinXmlSchemaSource {
             return ret;
         }
 
-        @Override
-        public SourceIdentifier getIdentifier() {
-            return xmlSchemaSource.getIdentifier();
-        }
-
-        @Override
-        public Optional<String> getSymbolicName() {
-            return xmlSchemaSource.getSymbolicName();
-        }
-
         @Override
         protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
             return toStringHelper.add("xmlSchemaSource", xmlSchemaSource);
similarity index 70%
rename from yang/yang-repo-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/YinTextFileSchemaSource.java
rename to model/yang-model-spi/src/main/java/org/opendaylight/yangtools/yang/model/spi/source/YinTextFileSource.java
index 10b993e02f209c07893ca1584a72c111713d2cda..d1f1358bb8371e85c025c20fd1c4066111a9b181 100644 (file)
@@ -5,7 +5,7 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-package org.opendaylight.yangtools.yang.model.repo.api;
+package org.opendaylight.yangtools.yang.model.spi.source;
 
 import static java.util.Objects.requireNonNull;
 
@@ -14,20 +14,18 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.nio.file.Files;
 import java.nio.file.Path;
-import java.util.Optional;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.concepts.Delegator;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 
 /**
- * A {@link YinTextSchemaSource} backed by a file.
- *
- * @author Robert Varga
+ * A {@link YinTextSource} backed by a file.
  */
-final class YinTextFileSchemaSource extends YinTextSchemaSource implements Delegator<Path> {
+final class YinTextFileSource extends YinTextSource implements Delegator<Path> {
     private final @NonNull Path path;
 
-    YinTextFileSchemaSource(final @NonNull SourceIdentifier identifier, final @NonNull Path path) {
-        super(identifier);
+    YinTextFileSource(final @NonNull SourceIdentifier sourceId, final @NonNull Path path) {
+        super(sourceId);
         this.path = requireNonNull(path);
     }
 
@@ -47,7 +45,7 @@ final class YinTextFileSchemaSource extends YinTextSchemaSource implements Deleg
     }
 
     @Override
-    public Optional<String> getSymbolicName() {
-        return Optional.of(path.toString());
+    public String symbolicName() {
+        return path.toString();
     }
 }
similarity index 73%
rename from yang/yang-repo-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/YinTextSchemaSource.java
rename to model/yang-model-spi/src/main/java/org/opendaylight/yangtools/yang/model/spi/source/YinTextSource.java
index 9fc0f6254cb85697f1b7b5c2de65acb8de3c9beb..1e780874731c0430cfec522176a10dbc751f274d 100644 (file)
@@ -5,12 +5,11 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-package org.opendaylight.yangtools.yang.model.repo.api;
+package org.opendaylight.yangtools.yang.model.spi.source;
 
 import static com.google.common.base.Preconditions.checkArgument;
 import static java.util.Objects.requireNonNull;
 
-import com.google.common.annotations.Beta;
 import com.google.common.base.MoreObjects;
 import com.google.common.base.MoreObjects.ToStringHelper;
 import com.google.common.io.ByteSource;
@@ -21,21 +20,22 @@ import java.nio.file.Path;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.common.YangConstants;
 import org.opendaylight.yangtools.yang.common.YangNames;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.YinSourceRepresentation;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
  * YIN text schema source representation. Exposes an RFC6020 or RFC7950 XML representation as an {@link InputStream}.
  */
-@Beta
-public abstract class YinTextSchemaSource extends ByteSource implements YinSchemaSourceRepresentation {
-    private static final Logger LOG = LoggerFactory.getLogger(YinTextSchemaSource.class);
+public abstract class YinTextSource extends ByteSource implements YinSourceRepresentation {
+    private static final Logger LOG = LoggerFactory.getLogger(YinTextSource.class);
     private static final String XML_EXTENSION = ".xml";
 
-    private final @NonNull SourceIdentifier identifier;
+    private final @NonNull SourceIdentifier sourceId;
 
-    protected YinTextSchemaSource(final SourceIdentifier identifier) {
-        this.identifier = requireNonNull(identifier);
+    protected YinTextSource(final SourceIdentifier sourceId) {
+        this.sourceId = requireNonNull(sourceId);
     }
 
     public static @NonNull SourceIdentifier identifierFromFilename(final String name) {
@@ -55,13 +55,13 @@ public abstract class YinTextSchemaSource extends ByteSource implements YinSchem
     }
 
     @Override
-    public final SourceIdentifier getIdentifier() {
-        return identifier;
+    public final SourceIdentifier sourceId() {
+        return sourceId;
     }
 
     @Override
-    public final Class<YinTextSchemaSource> getType() {
-        return YinTextSchemaSource.class;
+    public final Class<YinTextSource> getType() {
+        return YinTextSource.class;
     }
 
     @Override
@@ -79,7 +79,7 @@ public abstract class YinTextSchemaSource extends ByteSource implements YinSchem
      * @return ToStringHelper supplied as input argument.
      */
     protected ToStringHelper addToStringAttributes(final @NonNull ToStringHelper toStringHelper) {
-        return toStringHelper.add("identifier", identifier);
+        return toStringHelper.add("identifier", sourceId);
     }
 
     /**
@@ -90,19 +90,19 @@ public abstract class YinTextSchemaSource extends ByteSource implements YinSchem
      * @param delegate Backing ByteSource instance
      * @return A new YinTextSchemaSource
      */
-    public static @NonNull YinTextSchemaSource delegateForByteSource(final SourceIdentifier identifier,
+    public static @NonNull YinTextSource delegateForByteSource(final SourceIdentifier identifier,
             final ByteSource delegate) {
-        return new DelegatedYinTextSchemaSource(identifier, delegate);
+        return new DelegatedYinTextSource(identifier, delegate);
     }
 
-    public static @NonNull YinTextSchemaSource forPath(final Path path) {
+    public static @NonNull YinTextSource forPath(final Path path) {
         checkArgument(Files.isRegularFile(path), "Supplied path %s is not a regular file", path);
-        return new YinTextFileSchemaSource(identifierFromFilename(path.toFile().getName()), path);
+        return new YinTextFileSource(identifierFromFilename(path.toFile().getName()), path);
     }
 
-    public static @NonNull YinTextSchemaSource forResource(final Class<?> clazz, final String resourceName) {
+    public static @NonNull YinTextSource forResource(final Class<?> clazz, final String resourceName) {
         final String fileName = resourceName.substring(resourceName.lastIndexOf('/') + 1);
-        return new ResourceYinTextSchemaSource(identifierFromFilename(fileName),
+        return new ResourceYinTextSource(identifierFromFilename(fileName),
             Resources.getResource(clazz, resourceName));
     }
 }
similarity index 73%
rename from yang/yang-repo-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/YinXmlSchemaSource.java
rename to model/yang-model-spi/src/main/java/org/opendaylight/yangtools/yang/model/spi/source/YinXmlSource.java
index 4bd18ee53a1b1fbe8e20483aa936b2c0eca89a1b..9f62b1296ddd3ec7b247de6118022f1488c5367a 100644 (file)
@@ -5,19 +5,18 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-package org.opendaylight.yangtools.yang.model.repo.api;
+package org.opendaylight.yangtools.yang.model.spi.source;
 
-import com.google.common.annotations.Beta;
 import javax.xml.transform.Source;
 import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.model.api.source.YinSourceRepresentation;
 
 /**
  * YIN text schema source representation. Exposes an RFC6020 or RFC7950 XML representation as an XML {@link Source}.
  */
-@Beta
-public interface YinXmlSchemaSource extends YinSchemaSourceRepresentation {
+public interface YinXmlSource extends YinSourceRepresentation {
     @Override
-    Class<? extends YinXmlSchemaSource> getType();
+    Class<? extends YinXmlSource> getType();
 
     /**
      * Return an XML {@link Source} of the YIN document.
diff --git a/model/yang-model-spi/src/main/java/org/opendaylight/yangtools/yang/model/spi/source/package-info.java b/model/yang-model-spi/src/main/java/org/opendaylight/yangtools/yang/model/spi/source/package-info.java
new file mode 100644 (file)
index 0000000..04565fb
--- /dev/null
@@ -0,0 +1,11 @@
+/*
+ * Copyright (c) 2024 PANTHEON.tech, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+/**
+ * Various utilities dealing with sources of YANG and YIN models.
+ */
+package org.opendaylight.yangtools.yang.model.spi.source;
\ No newline at end of file
index 9b39d85b929262c4c1a10139f99b797ba3473e92..7b9c847f15b9ff15b90438a49e20c3a122faaa5d 100644 (file)
@@ -14,7 +14,7 @@ import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.ModuleLike;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.Submodule;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 
 /**
  * The Schema Context Util contains support methods for searching through Schema Context modules for specified schema
index d14cc5c9829a78d5ace8027addfc79abee7fdab0..5adedebd9cf1ffd70dad7bea955200660c00d0fc 100644 (file)
@@ -12,7 +12,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.Set;
 import org.junit.jupiter.api.Test;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.spi.SimpleSchemaContext;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
index cfe0b54f5e4ee64a85b06c23399169723134b2b3..84e2e4b906fb9dc1f8ae2b92224fdcae5c0b154d 100644 (file)
@@ -21,7 +21,7 @@ import org.opendaylight.yangtools.yang.model.api.stmt.GroupingEffectiveStatement
 import org.opendaylight.yangtools.yang.model.api.stmt.LeafEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.LeafListEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ListEffectiveStatement;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YangTextSource;
 import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
 import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
 import org.opendaylight.yangtools.yang.parser.rfc7950.repo.YangStatementStreamSource;
@@ -42,9 +42,9 @@ class ContextReferenceTest {
             .build();
 
         final var foo = reactor.newBuild()
-            .addSource(YangStatementStreamSource.create(YangTextSchemaSource.forResource(
+            .addSource(YangStatementStreamSource.create(YangTextSource.forResource(
                 ContextReferenceTest.class, "/yang-ext.yang")))
-            .addSource(YangStatementStreamSource.create(YangTextSchemaSource.forResource(
+            .addSource(YangStatementStreamSource.create(YangTextSource.forResource(
                 ContextReferenceTest.class, "/ctxref.yang")))
             .buildEffective()
             .getModuleStatements()
index 8668f49ebda623c5ab3a1dc1912eb1626e21b3e9..a95c87777d757b703051d4b858c07b275ed5f995 100644 (file)
@@ -14,7 +14,7 @@ import org.opendaylight.yangtools.odlext.model.api.MountEffectiveStatement;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YangTextSource;
 import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
 import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
 import org.opendaylight.yangtools.yang.parser.rfc7950.repo.YangStatementStreamSource;
@@ -30,10 +30,8 @@ class MountTest {
                 new MountStatementSupport(YangParserConfiguration.DEFAULT))
             .build();
         final var foo = reactor.newBuild()
-            .addSource(YangStatementStreamSource.create(YangTextSchemaSource.forResource(
-                MountTest.class, "/yang-ext.yang")))
-            .addSource(YangStatementStreamSource.create(YangTextSchemaSource.forResource(
-                MountTest.class, "/mount.yang")))
+            .addSource(YangStatementStreamSource.create(YangTextSource.forResource(MountTest.class, "/yang-ext.yang")))
+            .addSource(YangStatementStreamSource.create(YangTextSource.forResource(MountTest.class, "/mount.yang")))
             .buildEffective()
             .getModuleStatements()
             .get(FOO);
index 44f8b834ceac0536ee28166267b9ebdc88a007da..5fb6852e2f310876e1ba1caca578a748db8989fb 100644 (file)
@@ -17,7 +17,7 @@ import org.opendaylight.yangtools.rfc6241.model.api.NetconfConstants;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.AnyxmlSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YangTextSource;
 import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
 import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
 import org.opendaylight.yangtools.yang.parser.rfc7950.repo.YangStatementStreamSource;
@@ -34,9 +34,9 @@ class NetconfTest {
             .build();
         final var context = reactor.newBuild()
             .addLibSources(YangStatementStreamSource.create(
-                YangTextSchemaSource.forResource(NetconfTest.class, "/ietf-inet-types@2013-07-15.yang")))
+                YangTextSource.forResource(NetconfTest.class, "/ietf-inet-types@2013-07-15.yang")))
             .addSource(YangStatementStreamSource.create(
-                YangTextSchemaSource.forResource(NetconfTest.class, "/ietf-netconf@2011-06-01.yang")))
+                YangTextSource.forResource(NetconfTest.class, "/ietf-netconf@2011-06-01.yang")))
             .buildEffective();
 
         final var module = context.findModule(NetconfConstants.RFC6241_MODULE).orElseThrow();
index 32e00f1a4a9cd03d8a5e55a5a8dbaa4f5ddc0b8b..42f8b8d62ea95e46864daaf383711000f98128e1 100644 (file)
@@ -15,7 +15,7 @@ import org.opendaylight.yangtools.rfc6536.model.api.DefaultDenyAllSchemaNode;
 import org.opendaylight.yangtools.rfc6536.model.api.DefaultDenyWriteSchemaNode;
 import org.opendaylight.yangtools.rfc6536.model.api.NACMConstants;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YangTextSource;
 import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
 import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
 import org.opendaylight.yangtools.yang.parser.rfc7950.repo.YangStatementStreamSource;
@@ -34,9 +34,9 @@ class NACMTest {
         final var context = reactor.newBuild()
             .addSources(
                 YangStatementStreamSource.create(
-                    YangTextSchemaSource.forResource(NACMTest.class, "/ietf-netconf-acm@2012-02-22.yang")),
+                    YangTextSource.forResource(NACMTest.class, "/ietf-netconf-acm@2012-02-22.yang")),
                 YangStatementStreamSource.create(
-                    YangTextSchemaSource.forResource(NACMTest.class, "/ietf-yang-types@2013-07-15.yang")))
+                    YangTextSource.forResource(NACMTest.class, "/ietf-yang-types@2013-07-15.yang")))
             .buildEffective();
 
         final var module = context.findModule(NACMConstants.RFC6536_MODULE).orElseThrow();
index 5c277aba9202d7952fed3bf71f2c3d88baf8418f..8eb6bb24199562188a9fdae6a10236503680c4b6 100644 (file)
@@ -24,7 +24,7 @@ import org.opendaylight.yangtools.yang.common.Uint32;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YangTextSource;
 import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
 import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
 import org.opendaylight.yangtools.yang.parser.rfc7950.repo.YangStatementStreamSource;
@@ -54,9 +54,9 @@ class IetfYangSmiv2ExtensionPluginTest {
             .build();
         final var schema = reactor.newBuild()
             .addSources(
-                YangStatementStreamSource.create(YangTextSchemaSource.forResource(
+                YangStatementStreamSource.create(YangTextSource.forResource(
                     IetfYangSmiv2ExtensionPluginTest.class, "/foo.yang")),
-                YangStatementStreamSource.create(YangTextSchemaSource.forResource(
+                YangStatementStreamSource.create(YangTextSource.forResource(
                     IetfYangSmiv2ExtensionPluginTest.class, "/ietf-yang-smiv2.yang")))
             .buildEffective();
 
index aece6c7023fce8ea56316493b82b7f7d4f3c09ac..a82b0ee66313f33072b38fe9735364c8035cecd0 100644 (file)
@@ -17,8 +17,8 @@ import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.rfc7952.model.api.AnnotationSchemaNode;
 import org.opendaylight.yangtools.yang.common.AnnotationName;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
 import org.opendaylight.yangtools.yang.model.ri.type.BaseTypes;
+import org.opendaylight.yangtools.yang.model.spi.source.YangTextSource;
 import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
 import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
 import org.opendaylight.yangtools.yang.parser.rfc7950.repo.YangStatementStreamSource;
@@ -37,9 +37,9 @@ class AnnotationTest {
         final var context = reactor.newBuild()
             .addSources(
                 YangStatementStreamSource.create(
-                    YangTextSchemaSource.forResource(AnnotationTest.class, "/ietf-yang-metadata@2016-08-05.yang")),
+                    YangTextSource.forResource(AnnotationTest.class, "/ietf-yang-metadata@2016-08-05.yang")),
                 YangStatementStreamSource.create(
-                    YangTextSchemaSource.forResource(AnnotationTest.class, "/example-last-modified.yang")))
+                    YangTextSource.forResource(AnnotationTest.class, "/example-last-modified.yang")))
             .buildEffective();
 
         final var annotations = AnnotationSchemaNode.findAll(context);
index 705dd41855122ef7cca1eefc1af73a5b67e63924..3816657d314d14862be882344bfb698e1bb9eb85 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.yangtools.rfc8040.parser;
 import java.io.IOException;
 import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.BeforeAll;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YangTextSource;
 import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
 import org.opendaylight.yangtools.yang.parser.api.YangSyntaxErrorException;
 import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
@@ -42,7 +42,7 @@ abstract class AbstractYangDataTest {
     static StatementStreamSource sourceForResource(final String resourceName) {
         try {
             return YangStatementStreamSource.create(
-                YangTextSchemaSource.forResource(AbstractYangDataTest.class, resourceName));
+                YangTextSource.forResource(AbstractYangDataTest.class, resourceName));
         } catch (IOException | YangSyntaxErrorException e) {
             throw new IllegalArgumentException("Failed to create source", e);
         }
index 0b327953bcc34202d1e070731c005e7b64321136..601731c0d925eb268cdb85198662537eb93cf151 100644 (file)
@@ -17,7 +17,7 @@ import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YangTextSource;
 import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
 import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
 import org.opendaylight.yangtools.yang.parser.rfc7950.repo.YangStatementStreamSource;
@@ -41,16 +41,15 @@ class MountPointTest {
         final var context = reactor.newBuild()
             .addLibSources(
                 YangStatementStreamSource.create(
-                    YangTextSchemaSource.forResource(MountPointTest.class, "/ietf-inet-types@2013-07-15.yang")),
+                    YangTextSource.forResource(MountPointTest.class, "/ietf-inet-types@2013-07-15.yang")),
                 YangStatementStreamSource.create(
-                    YangTextSchemaSource.forResource(MountPointTest.class, "/ietf-yang-schema-mount@2019-01-14.yang")),
+                    YangTextSource.forResource(MountPointTest.class, "/ietf-yang-schema-mount@2019-01-14.yang")),
                 YangStatementStreamSource.create(
-                    YangTextSchemaSource.forResource(MountPointTest.class, "/ietf-yang-types@2013-07-15.yang")))
+                    YangTextSource.forResource(MountPointTest.class, "/ietf-yang-types@2013-07-15.yang")))
             .addSources(
+                YangStatementStreamSource.create(YangTextSource.forResource(MountPointTest.class, "/example-grp.yang")),
                 YangStatementStreamSource.create(
-                    YangTextSchemaSource.forResource(MountPointTest.class, "/example-grp.yang")),
-                YangStatementStreamSource.create(
-                    YangTextSchemaSource.forResource(MountPointTest.class, "/example-uses.yang")))
+                    YangTextSource.forResource(MountPointTest.class, "/example-uses.yang")))
             .buildEffective();
 
         assertEquals(5, context.getModules().size());
index ccaa5534c38ecfa7da5191a5ce6a3ae7911e762b..0ea631801e48fe539c5e384b3c9fdd89c413b8eb 100644 (file)
@@ -14,7 +14,7 @@ import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.rfc8639.model.api.SubscribedNotificationsConstants;
 import org.opendaylight.yangtools.rfc8639.model.api.SubscriptionStateNotificationEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.NotificationEffectiveStatement;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YangTextSource;
 import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
 import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
 import org.opendaylight.yangtools.yang.parser.rfc7950.repo.YangStatementStreamSource;
@@ -30,24 +30,24 @@ class SubscribedNotificationsTest {
 
         final var context = reactor.newBuild()
             .addLibSources(
-                YangStatementStreamSource.create(YangTextSchemaSource.forResource(
+                YangStatementStreamSource.create(YangTextSource.forResource(
                     SubscribedNotificationsTest.class, "/ietf-inet-types@2013-07-15.yang")),
-                YangStatementStreamSource.create(YangTextSchemaSource.forResource(
+                YangStatementStreamSource.create(YangTextSource.forResource(
                     SubscribedNotificationsTest.class, "/ietf-interfaces@2018-02-20.yang")),
-                YangStatementStreamSource.create(YangTextSchemaSource.forResource(
+                YangStatementStreamSource.create(YangTextSource.forResource(
                     SubscribedNotificationsTest.class, "/ietf-ip@2018-02-22.yang")),
-                YangStatementStreamSource.create(YangTextSchemaSource.forResource(
+                YangStatementStreamSource.create(YangTextSource.forResource(
                     SubscribedNotificationsTest.class, "/ietf-netconf-acm@2018-02-14.yang")),
-                YangStatementStreamSource.create(YangTextSchemaSource.forResource(
+                YangStatementStreamSource.create(YangTextSource.forResource(
                     SubscribedNotificationsTest.class, "/ietf-network-instance@2019-01-21.yang")),
-                YangStatementStreamSource.create(YangTextSchemaSource.forResource(
+                YangStatementStreamSource.create(YangTextSource.forResource(
                     SubscribedNotificationsTest.class, "/ietf-restconf@2017-01-26.yang")),
-                YangStatementStreamSource.create(YangTextSchemaSource.forResource(
+                YangStatementStreamSource.create(YangTextSource.forResource(
                     SubscribedNotificationsTest.class, "/ietf-yang-schema-mount@2019-01-14.yang")),
-                YangStatementStreamSource.create(YangTextSchemaSource.forResource(
+                YangStatementStreamSource.create(YangTextSource.forResource(
                     SubscribedNotificationsTest.class, "/ietf-yang-types@2013-07-15.yang")))
             .addSources(
-                YangStatementStreamSource.create(YangTextSchemaSource.forResource(
+                YangStatementStreamSource.create(YangTextSource.forResource(
                     SubscribedNotificationsTest.class, "/ietf-subscribed-notifications@2019-09-09.yang")))
             .buildEffective();
 
index 26a7ef629d43992c2835227afb66dc7a65a3f57a..b8707cf65b1b9742989448419ec0a41da2e5d3a9 100644 (file)
@@ -21,7 +21,7 @@ import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.rfc8819.model.api.ModuleTagEffectiveStatement;
 import org.opendaylight.yangtools.rfc8819.model.api.Tag;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YangTextSource;
 import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
 import org.opendaylight.yangtools.yang.parser.api.YangSyntaxErrorException;
 import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
@@ -89,8 +89,7 @@ public class ModuleTagTest {
 
     private static YangStatementStreamSource moduleFromResources(final String resourceName) {
         try {
-            return YangStatementStreamSource.create(
-                YangTextSchemaSource.forResource(ModuleTagTest.class, resourceName));
+            return YangStatementStreamSource.create(YangTextSource.forResource(ModuleTagTest.class, resourceName));
         } catch (final YangSyntaxErrorException | IOException e) {
             throw new IllegalStateException("Failed to find resource " + resourceName, e);
         }
index 6ca64bfcbaeb692b9590c5826744f92183cf88ff..39f16fa94c824dc9153fdee17d8fbd5ca006a403 100644 (file)
@@ -34,5 +34,9 @@
             <groupId>org.opendaylight.yangtools</groupId>
             <artifactId>concepts</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>yang-model-api</artifactId>
+        </dependency>
     </dependencies>
 </project>
index 0ac24e72f279bf697a86eba32d831967e7ecd029..43cbe9c20efd7c27c33b7c9f48df73e3ef73d764 100644 (file)
@@ -9,8 +9,9 @@ module org.opendaylight.yangtools.yang.ir {
     exports org.opendaylight.yangtools.yang.ir;
 
     requires transitive com.google.common;
+    requires transitive org.opendaylight.yangtools.yang.model.api;
     requires org.opendaylight.yangtools.concepts;
 
     // Annotations
     requires static transitive org.eclipse.jdt.annotation;
-}
\ No newline at end of file
+}
similarity index 71%
rename from yang/yang-repo-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/YangIRSchemaSource.java
rename to parser/yang-ir/src/main/java/org/opendaylight/yangtools/yang/ir/YangIRSchemaSource.java
index 690ff2de0058b9eb288e148a8ce439de473b007a..8a7fc490a2bb55d5d20a1b23f133f7a90f2e379e 100644 (file)
@@ -5,29 +5,25 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-package org.opendaylight.yangtools.yang.model.repo.api;
+package org.opendaylight.yangtools.yang.ir;
 
 import static com.google.common.base.Preconditions.checkArgument;
 import static java.util.Objects.requireNonNull;
 
-import com.google.common.annotations.Beta;
-import java.util.Optional;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
-import org.opendaylight.yangtools.concepts.AbstractSimpleIdentifiable;
-import org.opendaylight.yangtools.yang.ir.IRKeyword;
 import org.opendaylight.yangtools.yang.ir.IRKeyword.Unqualified;
-import org.opendaylight.yangtools.yang.ir.IRStatement;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.YangSourceRepresentation;
 
-@Beta
-public final class YangIRSchemaSource extends AbstractSimpleIdentifiable<SourceIdentifier>
-        implements YangSchemaSourceRepresentation {
+public final class YangIRSchemaSource implements YangSourceRepresentation {
+    private final @NonNull SourceIdentifier sourceId;
     private final @NonNull IRStatement rootStatement;
     private final @Nullable String symbolicName;
 
-    public YangIRSchemaSource(final @NonNull SourceIdentifier identifier, final @NonNull IRStatement rootStatement,
+    public YangIRSchemaSource(final @NonNull SourceIdentifier sourceId, final @NonNull IRStatement rootStatement,
             final @Nullable String symbolicName) {
-        super(identifier);
+        this.sourceId = requireNonNull(sourceId);
         this.rootStatement = requireNonNull(rootStatement);
         this.symbolicName = symbolicName;
 
@@ -46,8 +42,13 @@ public final class YangIRSchemaSource extends AbstractSimpleIdentifiable<SourceI
     }
 
     @Override
-    public Optional<String> getSymbolicName() {
-        return Optional.ofNullable(symbolicName);
+    public SourceIdentifier sourceId() {
+        return sourceId;
+    }
+
+    @Override
+    public String symbolicName() {
+        return symbolicName;
     }
 
     @Override
index fccfcc8815c47448f532e947d7fda62f8b649986..1433816d1bd04242d2caf570ddaf8a82948199b6 100644 (file)
@@ -14,8 +14,8 @@ import com.google.common.collect.ImmutableSet;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.common.UnresolvedQName.Unqualified;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.SourceRepresentation;
 
 /**
  * A single <a href="https://www.rfc-editor.org/rfc/rfc8525">RFC8525</a> {@code module} or {@code import-only-module}
@@ -27,11 +27,11 @@ import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
  * @param submodules Submodules of this module
  * @param features The set of supported features in this module
  * @param deviationModuleNames Names of modules containing {@code deviate} statements targetting this module
- * @param source A {@link SchemaSourceRepresentation} of the module
+ * @param source A {@link SourceRepresentation} of the module
  */
 public record YangLibModule(@NonNull SourceIdentifier identifier, @NonNull XMLNamespace namespace,
         @NonNull ImmutableMap<Unqualified, YangLibSubmodule> submodules, @NonNull ImmutableSet<Unqualified> features,
-        @NonNull ImmutableSet<Unqualified> deviationModuleNames, @NonNull SchemaSourceRepresentation source) {
+        @NonNull ImmutableSet<Unqualified> deviationModuleNames, @NonNull SourceRepresentation source) {
     public YangLibModule {
         requireNonNull(identifier);
         requireNonNull(namespace);
index f718768ee69d474c7236e98898b105e7e39a24e6..564166daf16afbfdc48db8ee272e9de98c5a8b7b 100644 (file)
@@ -12,7 +12,7 @@ import static java.util.Objects.requireNonNull;
 import com.google.common.collect.ImmutableMap;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.common.UnresolvedQName.Unqualified;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 
 /**
  * A single <a href="https://www.rfc-editor.org/rfc/rfc8525">RFC8525</a> {@code module-set}.
index 29b986c8c455b31a7aed19f1916a205d0586626b..7c9a8a2c7ea38246e898d4b3a0f67754e2118e8d 100644 (file)
@@ -12,7 +12,7 @@ import java.io.IOException;
 import java.util.Collection;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
+import org.opendaylight.yangtools.yang.model.api.source.SourceRepresentation;
 
 /**
  * A service capable of transforming a {@link YangLibModuleSet} to an {@link EffectiveModelContext}.
@@ -20,12 +20,12 @@ import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation
 @Beta
 public interface YangLibResolver {
     /**
-     * Return enumeration of concrete types of {@link SchemaSourceRepresentation} this resolver supports. Users can use
-     * this information prepare the source they have to a representation which will be accepted by this resolver.
+     * Return enumeration of concrete types of {@link SourceRepresentation} this resolver supports. Users can use this
+     * information prepare the source they have to a representation which will be accepted by this resolver.
      *
      * @return Enumeration of supported schema source representations.
      */
-    @NonNull Collection<Class<? extends SchemaSourceRepresentation>> supportedSourceRepresentations();
+    @NonNull Collection<Class<? extends SourceRepresentation>> supportedSourceRepresentations();
 
     /**
      * Build the effective view of a combined view of effective statements.
@@ -34,8 +34,7 @@ public interface YangLibResolver {
      * @throws IOException if a module source cannot be read
      * @throws YangSyntaxErrorException when a syntactic error is encountered
      * @throws NullPointerException if {@code moduleSet} is {@code null}
-     * @throws IllegalArgumentException if {@code moduleSet} references an unsupported
-     *                                  {@link SchemaSourceRepresentation}
+     * @throws IllegalArgumentException if {@code moduleSet} references an unsupported {@link SourceRepresentation}
      */
     @NonNull EffectiveModelContext resolveModuleSet(YangLibModuleSet moduleSet) throws IOException, YangParserException;
 }
index eae369cf7a8cd844f7d6eae9318548331eaf4f94..751cd82c128f2046acadaab3dba99e13d02da83c 100644 (file)
@@ -10,17 +10,17 @@ package org.opendaylight.yangtools.yang.parser.api;
 import static java.util.Objects.requireNonNull;
 
 import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.SourceRepresentation;
 
 /**
  * A single <a href="https://www.rfc-editor.org/rfc/rfc8525">RFC8525</a> {@code submodule} list entry.
  *
  * @param identifier {@link SourceIdentifier} of this submodule, e.g. the combination of {@code name} and
  *        {@code revision}
- * @param source A {@link SchemaSourceRepresentation} of the submodule
+ * @param source A {@link SourceRepresentation} of the submodule
  */
-public record YangLibSubmodule(@NonNull SourceIdentifier identifier, @NonNull SchemaSourceRepresentation source) {
+public record YangLibSubmodule(@NonNull SourceIdentifier identifier, @NonNull SourceRepresentation source) {
     public YangLibSubmodule {
         requireNonNull(identifier);
         requireNonNull(source);
index 84c44f4df09dbc0801cbeb2db79ac1b2dcc841e9..feb57ed9a6b82bf23406ca057c5d54f516fa5a63 100644 (file)
@@ -16,8 +16,8 @@ import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
+import org.opendaylight.yangtools.yang.model.api.source.SourceRepresentation;
 import org.opendaylight.yangtools.yang.model.api.stmt.FeatureSet;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
 
 /**
  * Configurable single-use YANG parser. Each instance can be configured to use a different set of models after
@@ -26,13 +26,13 @@ import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation
 @Beta
 public interface YangParser {
     /**
-     * Return enumeration of concrete types of {@link SchemaSourceRepresentation} parsers created from this factory
+     * Return enumeration of concrete types of {@link SourceRepresentation} parsers created from this factory
      * support. Users can use this information prepare the source they have to a representation which will be accepted
      * by this parser.
      *
      * @return Enumeration of supported schema source representations.
      */
-    @NonNull Collection<Class<? extends SchemaSourceRepresentation>> supportedSourceRepresentations();
+    @NonNull Collection<Class<? extends SourceRepresentation>> supportedSourceRepresentations();
 
     /**
      * Add main source. All main sources are present in resulting SchemaContext.
@@ -42,7 +42,7 @@ public interface YangParser {
      * @throws IOException when an IO error occurs
      * @throws IllegalArgumentException if the representation is not supported
      */
-    @NonNull YangParser addSource(SchemaSourceRepresentation source) throws IOException, YangSyntaxErrorException;
+    @NonNull YangParser addSource(SourceRepresentation source) throws IOException, YangSyntaxErrorException;
 
     /**
      * Add main sources. All main sources are present in resulting SchemaContext.
@@ -52,23 +52,23 @@ public interface YangParser {
      * @throws IOException when an IO error occurs
      * @throws IllegalArgumentException if the representation is not supported
      */
-    default @NonNull YangParser addSources(final SchemaSourceRepresentation... sources) throws IOException,
-        YangSyntaxErrorException {
-        for (SchemaSourceRepresentation source : sources) {
+    default @NonNull YangParser addSources(final SourceRepresentation... sources)
+            throws IOException, YangSyntaxErrorException {
+        for (var source : sources) {
             addSource(source);
         }
         return this;
     }
 
-    default @NonNull YangParser addSources(final Collection<? extends SchemaSourceRepresentation> sources)
+    default @NonNull YangParser addSources(final Collection<? extends SourceRepresentation> sources)
             throws IOException, YangSyntaxErrorException {
-        for (SchemaSourceRepresentation source : sources) {
+        for (var source : sources) {
             addSource(source);
         }
         return this;
     }
 
-    YangParser addLibSource(SchemaSourceRepresentation source) throws IOException, YangSyntaxErrorException;
+    YangParser addLibSource(SourceRepresentation source) throws IOException, YangSyntaxErrorException;
 
     /**
      * Add library sources. Only library sources required by main sources are present in resulting SchemaContext.
@@ -82,17 +82,17 @@ public interface YangParser {
      * @throws IOException when an IO error occurs
      * @throws IllegalArgumentException if the representation is not supported
      */
-    default @NonNull YangParser addLibSources(final SchemaSourceRepresentation... sources) throws IOException,
-            YangSyntaxErrorException {
-        for (SchemaSourceRepresentation source : sources) {
+    default @NonNull YangParser addLibSources(final SourceRepresentation... sources)
+            throws IOException, YangSyntaxErrorException {
+        for (var source : sources) {
             addLibSource(source);
         }
         return this;
     }
 
-    default @NonNull YangParser addLibSources(final Collection<SchemaSourceRepresentation> sources) throws IOException,
-            YangSyntaxErrorException {
-        for (SchemaSourceRepresentation source : sources) {
+    default @NonNull YangParser addLibSources(final Collection<SourceRepresentation> sources)
+            throws IOException, YangSyntaxErrorException {
+        for (var source : sources) {
             addLibSource(source);
         }
         return this;
index 7f199ba9de64683b3728f9587a5de2b49921cee3..0529cff5f3f8a42480cf14c1cee1fd7e46409ba2 100644 (file)
@@ -11,31 +11,32 @@ import com.google.common.annotations.Beta;
 import java.util.Optional;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 
 @Beta
 public class YangSyntaxErrorException extends YangParserException {
+    @java.io.Serial
     private static final long serialVersionUID = 2L;
 
-    private final SourceIdentifier source;
+    private final SourceIdentifier sourceId;
     private final int line;
     private final int charPositionInLine;
 
-    public YangSyntaxErrorException(final @Nullable SourceIdentifier source, final int line,
+    public YangSyntaxErrorException(final @Nullable SourceIdentifier sourceId, final int line,
             final int charPositionInLine, final String message) {
-        this(source, line, charPositionInLine, message, null);
+        this(sourceId, line, charPositionInLine, message, null);
     }
 
-    public YangSyntaxErrorException(final @Nullable SourceIdentifier source, final int line,
+    public YangSyntaxErrorException(final @Nullable SourceIdentifier sourceId, final int line,
             final int charPositionInLine, final String message, final @Nullable Throwable cause) {
         super(message, cause);
-        this.source = source;
+        this.sourceId = sourceId;
         this.line = line;
         this.charPositionInLine = charPositionInLine;
     }
 
     public final Optional<SourceIdentifier> getSource() {
-        return Optional.ofNullable(source);
+        return Optional.ofNullable(sourceId);
     }
 
     public final int getLine() {
@@ -48,8 +49,8 @@ public class YangSyntaxErrorException extends YangParserException {
 
     public @NonNull String getFormattedMessage() {
         final StringBuilder sb = new StringBuilder(getMessage());
-        if (source != null) {
-            sb.append(" in source ").append(source);
+        if (sourceId != null) {
+            sb.append(" in source ").append(sourceId);
         }
         if (line != 0) {
             sb.append(" on line ").append(line);
index a0e3b4baa172f5795377449ec4048bae713e4530..2938d01c13659502ae197752ba4898015d60a5b2 100644 (file)
@@ -16,8 +16,8 @@ import org.kohsuke.MetaInfServices;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.model.api.source.SourceRepresentation;
 import org.opendaylight.yangtools.yang.model.api.stmt.FeatureSet;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
 import org.opendaylight.yangtools.yang.parser.api.YangLibModuleSet;
 import org.opendaylight.yangtools.yang.parser.api.YangLibResolver;
 import org.opendaylight.yangtools.yang.parser.api.YangParserException;
@@ -48,7 +48,7 @@ public final class DefaultYangLibResolver implements YangLibResolver {
     }
 
     @Override
-    public Collection<Class<? extends SchemaSourceRepresentation>> supportedSourceRepresentations() {
+    public Collection<Class<? extends SourceRepresentation>> supportedSourceRepresentations() {
         return DefaultYangParser.REPRESENTATIONS;
     }
 
index f3fd8f45fcd7a9c1fab4a485438d6c1adee24ddf..0350a52d1f189a5916cb0c2b61b2ab751e379e14 100644 (file)
@@ -16,15 +16,15 @@ import java.util.List;
 import javax.xml.transform.TransformerException;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.common.QNameModule;
+import org.opendaylight.yangtools.yang.ir.YangIRSchemaSource;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
+import org.opendaylight.yangtools.yang.model.api.source.SourceRepresentation;
 import org.opendaylight.yangtools.yang.model.api.stmt.FeatureSet;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
-import org.opendaylight.yangtools.yang.model.repo.api.YangIRSchemaSource;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
-import org.opendaylight.yangtools.yang.model.repo.api.YinDomSchemaSource;
-import org.opendaylight.yangtools.yang.model.repo.api.YinTextSchemaSource;
-import org.opendaylight.yangtools.yang.model.repo.api.YinXmlSchemaSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YangTextSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YinDomSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YinTextSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YinXmlSource;
 import org.opendaylight.yangtools.yang.parser.api.YangParser;
 import org.opendaylight.yangtools.yang.parser.api.YangParserException;
 import org.opendaylight.yangtools.yang.parser.api.YangSyntaxErrorException;
@@ -37,13 +37,13 @@ import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementR
 import org.xml.sax.SAXException;
 
 final class DefaultYangParser implements YangParser {
-    static final @NonNull ImmutableSet<Class<? extends SchemaSourceRepresentation>> REPRESENTATIONS = ImmutableSet.of(
+    static final @NonNull ImmutableSet<Class<? extends SourceRepresentation>> REPRESENTATIONS = ImmutableSet.of(
         // In order of preference
         YangIRSchemaSource.class,
-        YangTextSchemaSource.class,
-        YinDomSchemaSource.class,
-        YinXmlSchemaSource.class,
-        YinTextSchemaSource.class);
+        YangTextSource.class,
+        YinDomSource.class,
+        YinXmlSource.class,
+        YinTextSource.class);
 
     private final BuildAction buildAction;
 
@@ -52,19 +52,18 @@ final class DefaultYangParser implements YangParser {
     }
 
     @Override
-    public ImmutableSet<Class<? extends SchemaSourceRepresentation>> supportedSourceRepresentations() {
+    public ImmutableSet<Class<? extends SourceRepresentation>> supportedSourceRepresentations() {
         return REPRESENTATIONS;
     }
 
     @Override
-    public YangParser addSource(final SchemaSourceRepresentation source) throws IOException, YangSyntaxErrorException {
+    public YangParser addSource(final SourceRepresentation source) throws IOException, YangSyntaxErrorException {
         buildAction.addSource(sourceToStatementStream(source));
         return this;
     }
 
     @Override
-    public YangParser addLibSource(final SchemaSourceRepresentation source)
-            throws IOException, YangSyntaxErrorException {
+    public YangParser addLibSource(final SourceRepresentation source) throws IOException, YangSyntaxErrorException {
         buildAction.addLibSource(sourceToStatementStream(source));
         return this;
     }
@@ -105,26 +104,26 @@ final class DefaultYangParser implements YangParser {
         return new YangParserException("Failed to assemble sources", reported);
     }
 
-    static StatementStreamSource sourceToStatementStream(final SchemaSourceRepresentation source)
+    static StatementStreamSource sourceToStatementStream(final SourceRepresentation source)
             throws IOException, YangSyntaxErrorException {
         requireNonNull(source);
         if (source instanceof YangIRSchemaSource irSource) {
             return YangStatementStreamSource.create(irSource);
-        } else if (source instanceof YangTextSchemaSource yangSource) {
+        } else if (source instanceof YangTextSource yangSource) {
             return YangStatementStreamSource.create(yangSource);
-        } else if (source instanceof YinDomSchemaSource yinDom) {
+        } else if (source instanceof YinDomSource yinDom) {
             return YinStatementStreamSource.create(yinDom);
-        } else if (source instanceof YinTextSchemaSource yinText) {
+        } else if (source instanceof YinTextSource yinText) {
             try {
                 return YinStatementStreamSource.create(YinTextToDomTransformer.transformSource(yinText));
             } catch (SAXException e) {
-                throw new YangSyntaxErrorException(source.getIdentifier(), 0, 0, "Failed to parse XML text", e);
+                throw new YangSyntaxErrorException(source.sourceId(), 0, 0, "Failed to parse XML text", e);
             }
-        } else if (source instanceof YinXmlSchemaSource yinXml) {
+        } else if (source instanceof YinXmlSource yinXml) {
             try {
                 return YinStatementStreamSource.create(yinXml);
             } catch (TransformerException e) {
-                throw new YangSyntaxErrorException(source.getIdentifier(), 0, 0,
+                throw new YangSyntaxErrorException(source.sourceId(), 0, 0,
                     "Failed to assemble in-memory representation", e);
             }
         } else {
index 2a9dcf219e738f2e5b9803f56e9a32afffd69f85..33d647c49a7d530e16397a7d4667bc46d4cd661c 100644 (file)
@@ -16,13 +16,12 @@ import com.google.common.util.concurrent.FluentFuture;
 import java.io.IOException;
 import java.util.List;
 import java.util.Map;
-import java.util.Map.Entry;
 import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.ir.YangIRSchemaSource;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactoryConfiguration;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaResolutionException;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.YangIRSchemaSource;
 import org.opendaylight.yangtools.yang.parser.api.YangParser;
 import org.opendaylight.yangtools.yang.parser.api.YangParserException;
 import org.opendaylight.yangtools.yang.parser.api.YangParserFactory;
@@ -44,7 +43,7 @@ final class AssembleSources implements AsyncFunction<List<YangIRSchemaSource>, E
         this.parserFactory = parserFactory;
         this.config = config;
         getIdentifier = switch (config.getStatementParserMode()) {
-            case DEFAULT_MODE -> YangIRSchemaSource::getIdentifier;
+            case DEFAULT_MODE -> YangIRSchemaSource::sourceId;
         };
     }
 
@@ -72,11 +71,12 @@ final class AssembleSources implements AsyncFunction<List<YangIRSchemaSource>, E
         config.getSupportedFeatures().ifPresent(parser::setSupportedFeatures);
         config.getModulesDeviatedByModules().ifPresent(parser::setModulesWithSupportedDeviations);
 
-        for (final Entry<SourceIdentifier, YangIRSchemaSource> entry : srcs.entrySet()) {
+        for (var entry : srcs.entrySet()) {
             try {
                 parser.addSource(entry.getValue());
             } catch (YangSyntaxErrorException | IOException e) {
-                throw new SchemaResolutionException("Failed to add source " + entry.getKey(), e);
+                final var sourceId = entry.getKey();
+                throw new SchemaResolutionException("Failed to add source " + sourceId, sourceId, e);
             }
         }
 
index 99d0d15ef81d674fb4d44a816313367e38c7dfaa..c7df113fa9c0188f3c5b736e7d5abd73f36602aa 100644 (file)
@@ -23,8 +23,8 @@ import java.util.Set;
 import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.common.UnresolvedQName.Unqualified;
 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.api.stmt.ImportEffectiveStatement;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
 import org.opendaylight.yangtools.yang.parser.rfc7950.repo.YangModelDependencyInfo;
 import org.slf4j.Logger;
@@ -107,9 +107,9 @@ abstract class DependencyResolver {
             }
         }
 
-        this.resolvedSources = ImmutableList.copyOf(resolved);
-        this.unresolvedSources = ImmutableList.copyOf(pending);
-        this.unsatisfiedImports = ImmutableMultimap.copyOf(imports);
+        resolvedSources = ImmutableList.copyOf(resolved);
+        unresolvedSources = ImmutableList.copyOf(pending);
+        unsatisfiedImports = ImmutableMultimap.copyOf(imports);
     }
 
     protected abstract boolean isKnown(Collection<SourceIdentifier> haystack, ModuleImport mi);
index 7f3c339bc69f748d33e6b1f64d930b1d17fee443..312ddfe4f96ffc59e989dd0beb8c9ca8b17a26f1 100644 (file)
@@ -11,7 +11,7 @@ import java.util.Collection;
 import java.util.Map;
 import org.opendaylight.yangtools.yang.common.UnresolvedQName.Unqualified;
 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
 import org.opendaylight.yangtools.yang.parser.rfc7950.repo.YangModelDependencyInfo;
 
index 9cc0e6f8fe0e4cf0ac8c98528e8762131a4288ae..eac04f0fd6f606fecf93490648297bf94ced9d3d 100644 (file)
@@ -35,12 +35,12 @@ import java.util.concurrent.ConcurrentMap;
 import java.util.function.Function;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
+import org.opendaylight.yangtools.yang.ir.YangIRSchemaSource;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.EffectiveModelContextFactory;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactoryConfiguration;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.YangIRSchemaSource;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
index f81ee4678e305517d3a099c72c5cef8b6fb1a633..addeef934e969c6537e96371fbc82754d8e1b4d1 100644 (file)
@@ -17,10 +17,10 @@ import org.eclipse.jdt.annotation.NonNull;
 import org.kohsuke.MetaInfServices;
 import org.opendaylight.yangtools.concepts.Identifiable;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.EffectiveModelContextFactory;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactoryConfiguration;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.spi.AbstractSchemaRepository;
 import org.opendaylight.yangtools.yang.parser.api.YangParserFactory;
 import org.opendaylight.yangtools.yang.parser.impl.DefaultYangParserFactory;
index 16a2c2d324dcdbace8c47386cb5aa82fc291b374..74e69d85422506d5ce82d9614513d33e8734fd85 100644 (file)
@@ -17,8 +17,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import org.gaul.modernizer_maven_annotations.SuppressModernizer;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.YangIRSchemaSource;
+import org.opendaylight.yangtools.yang.ir.YangIRSchemaSource;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -37,7 +37,7 @@ final class SourceIdMismatchDetector implements Function<List<YangIRSchemaSource
         final Iterator<SourceIdentifier> srcIt = sourceIdentifiers.iterator();
         final Map<SourceIdentifier, YangIRSchemaSource> filtered = new LinkedHashMap<>();
         for (YangIRSchemaSource irSchemaSource : input) {
-            final SourceIdentifier realSId = irSchemaSource.getIdentifier();
+            final SourceIdentifier realSId = irSchemaSource.sourceId();
             if (srcIt.hasNext()) {
                 final SourceIdentifier expectedSId = srcIt.next();
                 if (!expectedSId.equals(realSId)) {
index 4fae062dc12deb4d1419a4f1928c07f998065a9c..06365a8cbf61ea4ce7589c717474839ef26f9fbb 100644 (file)
@@ -35,34 +35,34 @@ import org.opendaylight.yangtools.concepts.AbstractRegistration;
 import org.opendaylight.yangtools.concepts.Registration;
 import org.opendaylight.yangtools.util.concurrent.FluentFutures;
 import org.opendaylight.yangtools.yang.common.QNameModule;
+import org.opendaylight.yangtools.yang.ir.YangIRSchemaSource;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.api.stmt.FeatureSet;
 import org.opendaylight.yangtools.yang.model.repo.api.MissingSchemaSourceException;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactoryConfiguration;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaResolutionException;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
-import org.opendaylight.yangtools.yang.model.repo.api.YangIRSchemaSource;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
 import org.opendaylight.yangtools.yang.model.repo.spi.GuavaSchemaSourceCache;
 import org.opendaylight.yangtools.yang.model.repo.spi.PotentialSchemaSource;
 import org.opendaylight.yangtools.yang.model.repo.spi.PotentialSchemaSource.Costs;
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider;
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistry;
+import org.opendaylight.yangtools.yang.model.spi.source.YangTextSource;
 import org.opendaylight.yangtools.yang.parser.api.YangParserFactory;
 import org.opendaylight.yangtools.yang.parser.api.YangSyntaxErrorException;
 import org.opendaylight.yangtools.yang.parser.rfc7950.repo.TextToIRTransformer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public final class YangTextSchemaContextResolver implements AutoCloseable, SchemaSourceProvider<YangTextSchemaSource> {
+public final class YangTextSchemaContextResolver implements AutoCloseable, SchemaSourceProvider<YangTextSource> {
     private static final Logger LOG = LoggerFactory.getLogger(YangTextSchemaContextResolver.class);
     private static final Duration SOURCE_LIFETIME = Duration.ofSeconds(60);
 
     private final Collection<SourceIdentifier> requiredSources = new ConcurrentLinkedDeque<>();
-    private final Multimap<SourceIdentifier, YangTextSchemaSource> texts = ArrayListMultimap.create();
+    private final Multimap<SourceIdentifier, YangTextSource> texts = ArrayListMultimap.create();
     @GuardedBy("this")
     private final Map<QNameModule, List<ImmutableSet<String>>> registeredFeatures = new HashMap<>();
     private final AtomicReference<Optional<EffectiveModelContext>> currentSchemaContext =
@@ -96,7 +96,7 @@ public final class YangTextSchemaContextResolver implements AutoCloseable, Schem
     }
 
     /**
-     * Register a {@link YangTextSchemaSource}.
+     * Register a {@link YangTextSource}.
      *
      * @param source YANG text source
      * @return a {@link Registration}
@@ -105,16 +105,16 @@ public final class YangTextSchemaContextResolver implements AutoCloseable, Schem
      * @throws SchemaSourceException When parsing encounters general error
      * @throws NullPointerException if {@code source} is {@code null}
      */
-    public @NonNull Registration registerSource(final @NonNull YangTextSchemaSource source)
+    public @NonNull Registration registerSource(final @NonNull YangTextSource source)
             throws SchemaSourceException, IOException, YangSyntaxErrorException {
         final var ast = TextToIRTransformer.transformText(source);
         LOG.trace("Resolved source {} to source {}", source, ast);
 
         // AST carries an accurate identifier, check if it matches the one supplied by the source. If it
         // does not, check how much it differs and emit a warning.
-        final var providedId = source.getIdentifier();
-        final var parsedId = ast.getIdentifier();
-        final YangTextSchemaSource text;
+        final var providedId = source.sourceId();
+        final var parsedId = ast.sourceId();
+        final YangTextSource text;
         if (!parsedId.equals(providedId)) {
             if (!parsedId.name().equals(providedId.name())) {
                 LOG.info("Provided module name {} does not match actual text {}, corrected",
@@ -131,7 +131,7 @@ public final class YangTextSchemaContextResolver implements AutoCloseable, Schem
                 }
             }
 
-            text = YangTextSchemaSource.delegateForCharSource(parsedId, source);
+            text = YangTextSource.delegateForCharSource(parsedId, source);
         } else {
             text = source;
         }
@@ -141,7 +141,7 @@ public final class YangTextSchemaContextResolver implements AutoCloseable, Schem
             LOG.debug("Populated {} with text", parsedId);
 
             final var reg = registry.registerSchemaSource(this,
-                PotentialSchemaSource.create(parsedId, YangTextSchemaSource.class, Costs.IMMEDIATE.getValue()));
+                PotentialSchemaSource.create(parsedId, YangTextSource.class, Costs.IMMEDIATE.getValue()));
             requiredSources.add(parsedId);
             cache.schemaSourceEncountered(ast);
             LOG.debug("Added source {} to schema context requirements", parsedId);
@@ -176,7 +176,7 @@ public final class YangTextSchemaContextResolver implements AutoCloseable, Schem
             throws SchemaSourceException, IOException, YangSyntaxErrorException {
         final String path = url.getPath();
         final String fileName = path.substring(path.lastIndexOf('/') + 1);
-        return registerSource(YangTextSchemaSource.forURL(url, guessSourceIdentifier(fileName)));
+        return registerSource(YangTextSource.forURL(url, guessSourceIdentifier(fileName)));
     }
 
     /**
@@ -233,7 +233,7 @@ public final class YangTextSchemaContextResolver implements AutoCloseable, Schem
 
     private static SourceIdentifier guessSourceIdentifier(final @NonNull String fileName) {
         try {
-            return YangTextSchemaSource.identifierFromFilename(fileName);
+            return YangTextSource.identifierFromFilename(fileName);
         } catch (IllegalArgumentException e) {
             LOG.warn("Invalid file name format in '{}'", fileName, e);
             return new SourceIdentifier(fileName);
@@ -311,8 +311,7 @@ public final class YangTextSchemaContextResolver implements AutoCloseable, Schem
     }
 
     @Override
-    public synchronized @NonNull FluentFuture<YangTextSchemaSource> getSource(
-            final SourceIdentifier sourceIdentifier) {
+    public synchronized @NonNull FluentFuture<YangTextSource> getSource(final SourceIdentifier sourceIdentifier) {
         final var ret = texts.get(sourceIdentifier);
 
         LOG.debug("Lookup {} result {}", sourceIdentifier, ret);
@@ -334,7 +333,7 @@ public final class YangTextSchemaContextResolver implements AutoCloseable, Schem
     }
 
     @Beta
-    public synchronized Collection<YangTextSchemaSource> getSourceTexts(final SourceIdentifier sourceIdentifier) {
+    public synchronized Collection<YangTextSource> getSourceTexts(final SourceIdentifier sourceIdentifier) {
         return ImmutableSet.copyOf(texts.get(sourceIdentifier));
     }
 
index 64cfd50c06ddaeac7ec8744ddf11b07766bfff47..13e484a5671a8ce4f9153fc7923a1960026c9cf2 100644 (file)
@@ -16,7 +16,7 @@ import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
 import org.opendaylight.yangtools.yang.model.api.meta.DeclarationInText;
 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
 import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YangTextSource;
 import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
 
 public class YT1193Test {
@@ -24,9 +24,9 @@ public class YT1193Test {
     void testDeclarationReference() throws Exception {
         final var declaredRoots = new DefaultYangParserFactory()
             .createParser(YangParserConfiguration.builder().retainDeclarationReferences(true).build())
-            .addSource(YangTextSchemaSource.forResource(getClass(), "/yt1193/foo.yang"))
-            .addSource(YangTextSchemaSource.forResource(getClass(), "/yt1193/bar.yang"))
-            .addSource(YangTextSchemaSource.forResource(getClass(), "/yt1193/baz.yang"))
+            .addSource(YangTextSource.forResource(getClass(), "/yt1193/foo.yang"))
+            .addSource(YangTextSource.forResource(getClass(), "/yt1193/bar.yang"))
+            .addSource(YangTextSource.forResource(getClass(), "/yt1193/baz.yang"))
             .buildDeclaredModel();
         assertEquals(3, declaredRoots.size());
 
index 329220f2933e36f61c6c1295730b6a6ace847e8c..e7b7ae97e7d9cb59fffe89b7fbfa6cc8c828e28a 100644 (file)
@@ -18,10 +18,10 @@ import java.util.concurrent.ExecutionException;
 import java.util.stream.Collectors;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.common.QNameModule;
+import org.opendaylight.yangtools.yang.ir.YangIRSchemaSource;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactoryConfiguration;
-import org.opendaylight.yangtools.yang.model.repo.api.YangIRSchemaSource;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YangTextSource;
 import org.opendaylight.yangtools.yang.parser.api.YangSyntaxErrorException;
 import org.opendaylight.yangtools.yang.parser.rfc7950.repo.TextToIRTransformer;
 
@@ -64,7 +64,7 @@ public abstract class AbstractSchemaRepositoryTest {
     private static SettableSchemaProvider<YangIRSchemaSource> assertYangTextResource(final String resourceName) {
         final YangIRSchemaSource yangSource;
         try {
-            yangSource = TextToIRTransformer.transformText(YangTextSchemaSource.forResource(resourceName));
+            yangSource = TextToIRTransformer.transformText(YangTextSource.forResource(resourceName));
         } catch (YangSyntaxErrorException | IOException e) {
             throw new AssertionError("Failed to parse " + resourceName, e);
         }
index 78614b28d67d4c6c7a7191ba97a069040183fe38..381584ec0746781eee996dd7dfe2052a26257b39 100644 (file)
@@ -12,8 +12,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
 import java.util.HashMap;
 import java.util.Map;
 import org.junit.jupiter.api.Test;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.spi.source.YangTextSource;
 import org.opendaylight.yangtools.yang.parser.rfc7950.repo.YangModelDependencyInfo;
 import org.opendaylight.yangtools.yang.parser.rfc7950.repo.YangModelDependencyInfo.ModuleDependencyInfo;
 
@@ -61,7 +61,7 @@ public class DependencyResolverTest {
 
     private static void addToMap(final Map<SourceIdentifier, YangModelDependencyInfo> map, final String yangFileName)
             throws Exception {
-        final var info = ModuleDependencyInfo.forYangText(YangTextSchemaSource.forResource(DependencyResolverTest.class,
+        final var info = ModuleDependencyInfo.forYangText(YangTextSource.forResource(DependencyResolverTest.class,
             yangFileName));
         map.put(new SourceIdentifier(info.getName(), info.getFormattedRevision()), info);
     }
index 6fcb952fc1e5724e122765ca5591da990d079ea7..8722b62f939e89bc2a4c4b9c96b5356da943ef29 100644 (file)
@@ -18,9 +18,9 @@ import java.util.Optional;
 import java.util.concurrent.ExecutionException;
 import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.ir.YangIRSchemaSource;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
-import org.opendaylight.yangtools.yang.model.repo.api.YangIRSchemaSource;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YangTextSource;
 import org.opendaylight.yangtools.yang.parser.rfc7950.repo.TextToIRTransformer;
 
 public class MultipleRevImportBug6875Test {
@@ -98,7 +98,7 @@ public class MultipleRevImportBug6875Test {
     private static SettableSchemaProvider<YangIRSchemaSource> getSourceProvider(final String resourceName)
             throws Exception {
         return SettableSchemaProvider.createImmediate(
-            TextToIRTransformer.transformText(YangTextSchemaSource.forResource(resourceName)),
+            TextToIRTransformer.transformText(YangTextSource.forResource(resourceName)),
             YangIRSchemaSource.class);
     }
 
index c3b53038f9bbc182d98179d10556dc45eb0eed6f..faa2d44a6530f8c8925538d8b569fa964bb495f4 100644 (file)
@@ -12,9 +12,9 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import org.junit.jupiter.api.Test;
+import org.opendaylight.yangtools.yang.ir.YangIRSchemaSource;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
-import org.opendaylight.yangtools.yang.model.repo.api.YangIRSchemaSource;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YangTextSource;
 import org.opendaylight.yangtools.yang.parser.rfc7950.repo.TextToIRTransformer;
 
 public class OpenconfigVerSharedSchemaRepositoryTest {
@@ -54,7 +54,6 @@ public class OpenconfigVerSharedSchemaRepositoryTest {
     static SettableSchemaProvider<YangIRSchemaSource> getImmediateYangSourceProviderFromResource(
             final String resourceName) throws Exception {
         return SettableSchemaProvider.createImmediate(
-            TextToIRTransformer.transformText(YangTextSchemaSource.forResource(resourceName)),
-            YangIRSchemaSource.class);
+            TextToIRTransformer.transformText(YangTextSource.forResource(resourceName)), YangIRSchemaSource.class);
     }
 }
index 9f48a189d82c326f37f6ec209bb4a871f4c329b0..4a4e8fc917a5258face93093b628476228347ea0 100644 (file)
@@ -10,13 +10,13 @@ package org.opendaylight.yangtools.yang.parser.repo;
 
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.SettableFuture;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.SourceRepresentation;
 import org.opendaylight.yangtools.yang.model.repo.spi.PotentialSchemaSource;
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider;
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistry;
 
-class SettableSchemaProvider<T extends SchemaSourceRepresentation> implements SchemaSourceProvider<T> {
+class SettableSchemaProvider<T extends SourceRepresentation> implements SchemaSourceProvider<T> {
 
     private final SettableFuture<T> future = SettableFuture.create();
     private final T schemaSourceRepresentation;
@@ -25,18 +25,18 @@ class SettableSchemaProvider<T extends SchemaSourceRepresentation> implements Sc
     SettableSchemaProvider(final T schemaSourceRepresentation, final SourceIdentifier sourceIdentifier,
             final Class<T> representation, final int cost) {
         this.schemaSourceRepresentation = schemaSourceRepresentation;
-        this.potentialSchemaSource = PotentialSchemaSource.create(sourceIdentifier, representation, cost);
+        potentialSchemaSource = PotentialSchemaSource.create(sourceIdentifier, representation, cost);
     }
 
-    public static <T extends SchemaSourceRepresentation> SettableSchemaProvider<T> createRemote(
+    public static <T extends SourceRepresentation> SettableSchemaProvider<T> createRemote(
             final T schemaSourceRepresentation, final Class<T> representation) {
-        return new SettableSchemaProvider<>(schemaSourceRepresentation, schemaSourceRepresentation.getIdentifier(),
+        return new SettableSchemaProvider<>(schemaSourceRepresentation, schemaSourceRepresentation.sourceId(),
                 representation, PotentialSchemaSource.Costs.REMOTE_IO.getValue());
     }
 
-    public static <T extends SchemaSourceRepresentation> SettableSchemaProvider<T> createImmediate(
+    public static <T extends SourceRepresentation> SettableSchemaProvider<T> createImmediate(
             final T schemaSourceRepresentation, final Class<T> representation) {
-        return new SettableSchemaProvider<>(schemaSourceRepresentation, schemaSourceRepresentation.getIdentifier(),
+        return new SettableSchemaProvider<>(schemaSourceRepresentation, schemaSourceRepresentation.sourceId(),
                 representation, PotentialSchemaSource.Costs.IMMEDIATE.getValue());
     }
 
@@ -50,7 +50,7 @@ class SettableSchemaProvider<T extends SchemaSourceRepresentation> implements Sc
     }
 
     public SourceIdentifier getId() {
-        return schemaSourceRepresentation.getIdentifier();
+        return schemaSourceRepresentation.sourceId();
     }
 
     public void setResult() {
index eb8cde8c0cf60d297d680ec45fbcd2d5177c2598..57c651e12e3b5f00eb4e3d05b2d6c4a1470c02b3 100644 (file)
@@ -18,13 +18,13 @@ import com.google.common.util.concurrent.ListenableFuture;
 import java.util.concurrent.ExecutionException;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
+import org.opendaylight.yangtools.yang.ir.YangIRSchemaSource;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.MissingSchemaSourceException;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactoryConfiguration;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.YangIRSchemaSource;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
 import org.opendaylight.yangtools.yang.model.repo.spi.PotentialSchemaSource;
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider;
+import org.opendaylight.yangtools.yang.model.spi.source.YangTextSource;
 import org.opendaylight.yangtools.yang.parser.rfc7950.repo.TextToIRTransformer;
 
 public class SharedEffectiveModelContextFactoryTest {
@@ -36,8 +36,8 @@ public class SharedEffectiveModelContextFactoryTest {
 
     @BeforeEach
     public void setUp() {
-        final var source1 = YangTextSchemaSource.forResource("/ietf/ietf-inet-types@2010-09-24.yang");
-        final var source2 = YangTextSchemaSource.forResource("/ietf/iana-timezones@2012-07-09.yang");
+        final var source1 = YangTextSource.forResource("/ietf/ietf-inet-types@2010-09-24.yang");
+        final var source2 = YangTextSource.forResource("/ietf/iana-timezones@2012-07-09.yang");
         s1 = new SourceIdentifier("ietf-inet-types", "2010-09-24");
         s2 = new SourceIdentifier("iana-timezones", "2012-07-09");
 
@@ -45,10 +45,10 @@ public class SharedEffectiveModelContextFactoryTest {
         repository.registerSchemaSourceListener(transformer);
 
         repository.registerSchemaSource(sourceIdentifier -> immediateFluentFuture(source1),
-            PotentialSchemaSource.create(s1, YangTextSchemaSource.class, 1));
+            PotentialSchemaSource.create(s1, YangTextSource.class, 1));
 
         repository.registerSchemaSource(sourceIdentifier -> immediateFluentFuture(source2),
-            PotentialSchemaSource.create(s2, YangTextSchemaSource.class, 1));
+            PotentialSchemaSource.create(s2, YangTextSource.class, 1));
     }
 
     @Test
@@ -60,10 +60,10 @@ public class SharedEffectiveModelContextFactoryTest {
 
     @Test
     public void testSourceRegisteredWithDifferentSI() throws Exception {
-        final var source1 = YangTextSchemaSource.forResource("/ietf/ietf-inet-types@2010-09-24.yang");
-        final var source2 = YangTextSchemaSource.forResource("/ietf/iana-timezones@2012-07-09.yang");
-        s1 = source1.getIdentifier();
-        s2 = source2.getIdentifier();
+        final var source1 = YangTextSource.forResource("/ietf/ietf-inet-types@2010-09-24.yang");
+        final var source2 = YangTextSource.forResource("/ietf/iana-timezones@2012-07-09.yang");
+        s1 = source1.sourceId();
+        s2 = source2.sourceId();
 
         final var provider = SharedSchemaRepositoryTest.getImmediateYangSourceProviderFromResource(
             "/no-revision/imported@2012-12-12.yang");
@@ -86,8 +86,8 @@ public class SharedEffectiveModelContextFactoryTest {
         final SourceIdentifier s3 = new SourceIdentifier("network-topology", "2013-10-21");
 
         repository.registerSchemaSource(new TransientFailureProvider(
-            YangTextSchemaSource.forResource("/ietf/network-topology@2013-10-21.yang")),
-            PotentialSchemaSource.create(s3, YangTextSchemaSource.class, 1));
+            YangTextSource.forResource("/ietf/network-topology@2013-10-21.yang")),
+            PotentialSchemaSource.create(s3, YangTextSource.class, 1));
 
         final var sharedSchemaContextFactory = new SharedEffectiveModelContextFactory(repository, config);
 
@@ -105,17 +105,17 @@ public class SharedEffectiveModelContextFactoryTest {
      * Schema source provider that fails on first attempt of getSource() and succeeds on every subsequent call
      * to simulate transient failures of source retrieval.
      */
-    private static final class TransientFailureProvider implements SchemaSourceProvider<YangTextSchemaSource> {
-        private final YangTextSchemaSource schemaSource;
+    private static final class TransientFailureProvider implements SchemaSourceProvider<YangTextSource> {
+        private final YangTextSource schemaSource;
 
         private boolean shouldFail = true;
 
-        private TransientFailureProvider(final YangTextSchemaSource schemaSource) {
+        private TransientFailureProvider(final YangTextSource schemaSource) {
             this.schemaSource = requireNonNull(schemaSource);
         }
 
         @Override
-        public ListenableFuture<YangTextSchemaSource> getSource(final SourceIdentifier sourceIdentifier) {
+        public ListenableFuture<YangTextSource> getSource(final SourceIdentifier sourceIdentifier) {
             if (shouldFail) {
                 shouldFail = false;
                 return immediateFailedFluentFuture(new Exception("Transient test failure."));
index a1e6355166e7c0ff03d5d0a796df78b9679ad8e3..2df811e0c3f42f64a3df46f6d602ecdd5fe3e8fc 100644 (file)
@@ -20,11 +20,11 @@ import static org.mockito.Mockito.verify;
 
 import java.util.concurrent.ExecutionException;
 import org.junit.jupiter.api.Test;
+import org.opendaylight.yangtools.yang.ir.YangIRSchemaSource;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.MissingSchemaSourceException;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.YangIRSchemaSource;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YangTextSource;
 import org.opendaylight.yangtools.yang.parser.rfc7950.repo.TextToIRTransformer;
 
 public class SharedSchemaRepositoryTest {
@@ -36,9 +36,9 @@ public class SharedSchemaRepositoryTest {
         final var id2 = loadAndRegisterSource(sharedSchemaRepository, "/no-revision/imported@2012-12-12.yang");
 
         var source = sharedSchemaRepository.getSchemaSource(idNoRevision, YangIRSchemaSource.class);
-        assertEquals(idNoRevision, source.get().getIdentifier());
+        assertEquals(idNoRevision, source.get().sourceId());
         source = sharedSchemaRepository.getSchemaSource(id2, YangIRSchemaSource.class);
-        assertEquals(id2, source.get().getIdentifier());
+        assertEquals(id2, source.get().sourceId());
     }
 
     private static SourceIdentifier loadAndRegisterSource(final SharedSchemaRepository sharedSchemaRepository,
@@ -167,14 +167,12 @@ public class SharedSchemaRepositoryTest {
     static SettableSchemaProvider<YangIRSchemaSource> getRemoteYangSourceProviderFromResource(final String resourceName)
             throws Exception {
         return SettableSchemaProvider.createRemote(
-            TextToIRTransformer.transformText(YangTextSchemaSource.forResource(resourceName)),
-            YangIRSchemaSource.class);
+            TextToIRTransformer.transformText(YangTextSource.forResource(resourceName)), YangIRSchemaSource.class);
     }
 
     static SettableSchemaProvider<YangIRSchemaSource> getImmediateYangSourceProviderFromResource(
             final String resourceName) throws Exception {
         return SettableSchemaProvider.createImmediate(
-            TextToIRTransformer.transformText(YangTextSchemaSource.forResource(resourceName)),
-            YangIRSchemaSource.class);
+            TextToIRTransformer.transformText(YangTextSource.forResource(resourceName)), YangIRSchemaSource.class);
     }
 }
index 6332d933431e0ad31445893210423ce658e275f2..490581bfba125202ff82ff3b172aae83b0be8bb3 100644 (file)
@@ -15,13 +15,13 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.ir.YangIRSchemaSource;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.stmt.FeatureSet;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactoryConfiguration;
-import org.opendaylight.yangtools.yang.model.repo.api.YangIRSchemaSource;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YangTextSource;
 import org.opendaylight.yangtools.yang.parser.rfc7950.repo.TextToIRTransformer;
 
 public class SharedSchemaRepositoryWithFeaturesTest {
@@ -121,8 +121,7 @@ public class SharedSchemaRepositoryWithFeaturesTest {
     private static SettableSchemaProvider<YangIRSchemaSource> getImmediateYangSourceProviderFromResource(
             final String resourceName) throws Exception {
         return SettableSchemaProvider.createImmediate(
-            TextToIRTransformer.transformText(YangTextSchemaSource.forResource(resourceName)),
-            YangIRSchemaSource.class);
+            TextToIRTransformer.transformText(YangTextSource.forResource(resourceName)), YangIRSchemaSource.class);
     }
 
     private static void assertSchemaContext(final SchemaContext schemaContext, final int moduleSize) {
index 0379e03b3bea1aa101ed2837aa5f2c5eeb6760a3..afda274f4fd330b26a24b0f4838987699ea42d48 100644 (file)
@@ -11,12 +11,12 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 
 import org.junit.jupiter.api.Test;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaResolutionException;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 
 public class YT1428Test extends AbstractSchemaRepositoryTest {
     @Test
-    public void testDeviateSourceReported() {
+    void testDeviateSourceReported() {
         final var ex = assertExecutionException(null, "/yt1428/orig.yang", "/yt1428/deviate.yang");
         assertEquals(new SourceIdentifier("deviate"),
             assertInstanceOf(SchemaResolutionException.class, ex.getCause()).getFailedSource());
index 9ac1eab608d1e5226f4b22b4204c03c47f7dcabe..d0340383cfe9fa8a5448e84a6fbcd0ca718b95b2 100644 (file)
@@ -21,8 +21,8 @@ import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.MissingSchemaSourceException;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 
 public class YangTextSchemaContextResolverTest {
     @Test
@@ -49,17 +49,17 @@ public class YangTextSchemaContextResolverTest {
         final var fooModuleId = new SourceIdentifier("foo", "2016-09-26");
         final var foo = yangTextSchemaContextResolver.getSource(fooModuleId);
         assertTrue(foo.isDone());
-        assertEquals(fooModuleId, foo.get().getIdentifier());
+        assertEquals(fooModuleId, foo.get().sourceId());
 
         final var barModuleId = new SourceIdentifier("bar", "2016-09-26");
         final var bar = yangTextSchemaContextResolver.getSource(barModuleId);
         assertTrue(bar.isDone());
-        assertEquals(barModuleId, bar.get().getIdentifier());
+        assertEquals(barModuleId, bar.get().sourceId());
 
         final var bazModuleId = new SourceIdentifier("baz", "2016-09-26");
         final var baz = yangTextSchemaContextResolver.getSource(bazModuleId);
         assertTrue(baz.isDone());
-        assertEquals(bazModuleId, baz.get().getIdentifier());
+        assertEquals(bazModuleId, baz.get().sourceId());
 
         final var foobarModuleId = new SourceIdentifier("foobar", "2016-09-26");
         final var foobar = yangTextSchemaContextResolver.getSource(foobarModuleId);
index 7e04bd017b647f494916e0ae843bd870056c30e2..0bfae3377e53e2b6b8ad02a50206fccf26670de3 100644 (file)
@@ -37,8 +37,8 @@ import org.opendaylight.yangtools.yang.common.UnresolvedQName.Unqualified;
 import org.opendaylight.yangtools.yang.common.YangVersion;
 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.api.stmt.FeatureSet;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.parser.spi.ParserNamespaces;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
 import org.opendaylight.yangtools.yang.parser.spi.meta.MutableStatement;
index ef6b1154b784bf617c4a42196a79d4b32d10a281..c875f520a722df8be92841844ad03caf8593cf7f 100644 (file)
@@ -25,13 +25,13 @@ import org.opendaylight.yangtools.yang.common.YangVersion;
 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.api.stmt.AugmentStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ConfigEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.DeviationStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.RefineStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier;
 import org.opendaylight.yangtools.yang.model.api.stmt.UsesStatement;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.parser.spi.meta.CopyType;
 import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStatementState;
 import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
index 42603da5354c1aecf11e71d62daf18945217689e..1b23f4d8f8433f9cd04afc6987e8b312b0e078e1 100644 (file)
@@ -27,7 +27,7 @@ import org.opendaylight.yangtools.yang.common.YangVersion;
 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.meta.StatementSourceReference;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 import org.opendaylight.yangtools.yang.parser.spi.ParserNamespaces;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
 import org.opendaylight.yangtools.yang.parser.spi.meta.MutableStatement;
index 299197aeb2167dcc9b5c990c0f450b51ee0bae98..1e53ea4afd47f05b684057390283964fb96156cb 100644 (file)
@@ -32,7 +32,7 @@ import org.opendaylight.yangtools.yang.common.YangVersion;
 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.meta.StatementSourceReference;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 import org.opendaylight.yangtools.yang.parser.spi.ParserNamespaces;
 import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ModelActionBuilder;
index 4e1fd353e7cc977532ce2f0e9aa3e46b62811bd4..d9292c8080405222ddf26fb065ad4248a2f91654 100644 (file)
@@ -12,19 +12,19 @@ import com.google.common.util.concurrent.Futures;
 import java.io.IOException;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.ir.IRStatement;
+import org.opendaylight.yangtools.yang.ir.YangIRSchemaSource;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.YangIRSchemaSource;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistry;
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceTransformer;
+import org.opendaylight.yangtools.yang.model.spi.source.YangTextSource;
 import org.opendaylight.yangtools.yang.parser.api.YangSyntaxErrorException;
 import org.opendaylight.yangtools.yang.parser.rfc7950.antlr.IRSupport;
 
 @Beta
-public final class TextToIRTransformer extends SchemaSourceTransformer<YangTextSchemaSource, YangIRSchemaSource> {
+public final class TextToIRTransformer extends SchemaSourceTransformer<YangTextSource, YangIRSchemaSource> {
     private TextToIRTransformer(final SchemaRepository provider, final SchemaSourceRegistry consumer) {
-        super(provider, YangTextSchemaSource.class, consumer, YangIRSchemaSource.class,
+        super(provider, YangTextSource.class, consumer, YangIRSchemaSource.class,
             input -> Futures.immediateFuture(transformText(input)));
     }
 
@@ -33,13 +33,13 @@ public final class TextToIRTransformer extends SchemaSourceTransformer<YangTextS
         return new TextToIRTransformer(provider, consumer);
     }
 
-    public static @NonNull YangIRSchemaSource transformText(final YangTextSchemaSource text)
+    public static @NonNull YangIRSchemaSource transformText(final YangTextSource text)
             throws YangSyntaxErrorException, IOException {
         final IRStatement rootStatement = IRSupport.createStatement(YangStatementStreamSource.parseYangSource(text));
-        final String name = YangModelDependencyInfo.safeStringArgument(text.getIdentifier(), rootStatement, "name");
-        final String latestRevision = YangModelDependencyInfo.getLatestRevision(rootStatement, text.getIdentifier());
+        final String name = YangModelDependencyInfo.safeStringArgument(text.sourceId(), rootStatement, "name");
+        final String latestRevision = YangModelDependencyInfo.getLatestRevision(rootStatement, text.sourceId());
         final SourceIdentifier sourceId = new SourceIdentifier(name, latestRevision);
 
-        return new YangIRSchemaSource(sourceId, rootStatement, text.getSymbolicName().orElse(null));
+        return new YangIRSchemaSource(sourceId, rootStatement, text.symbolicName());
     }
 }
index 6d5993417203304504fdeeeed1295098e5dd2c92..319601b52fbdc3cf57854b42d42967e775734f18 100644 (file)
@@ -14,7 +14,7 @@ import java.util.List;
 import org.antlr.v4.runtime.BaseErrorListener;
 import org.antlr.v4.runtime.RecognitionException;
 import org.antlr.v4.runtime.Recognizer;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 import org.opendaylight.yangtools.yang.parser.api.YangSyntaxErrorException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -23,18 +23,18 @@ final class YangErrorListener extends BaseErrorListener {
     private static final Logger LOG = LoggerFactory.getLogger(YangErrorListener.class);
 
     private final List<YangSyntaxErrorException> exceptions = new ArrayList<>();
-    private final SourceIdentifier source;
+    private final SourceIdentifier sourceId;
 
-    YangErrorListener(final SourceIdentifier source) {
-        this.source = requireNonNull(source);
+    YangErrorListener(final SourceIdentifier sourceId) {
+        this.sourceId = requireNonNull(sourceId);
     }
 
     @Override
     @SuppressWarnings("checkstyle:parameterName")
     public void syntaxError(final Recognizer<?, ?> recognizer, final Object offendingSymbol, final int line,
             final int charPositionInLine, final String msg, final RecognitionException e) {
-        LOG.debug("Syntax error in {} at {}:{}: {}", source, line, charPositionInLine, msg, e);
-        exceptions.add(new YangSyntaxErrorException(source, line, charPositionInLine, msg, e));
+        LOG.debug("Syntax error in {} at {}:{}: {}", sourceId, line, charPositionInLine, msg, e);
+        exceptions.add(new YangSyntaxErrorException(sourceId, line, charPositionInLine, msg, e));
     }
 
     void validate() throws YangSyntaxErrorException {
@@ -47,18 +47,18 @@ final class YangErrorListener extends BaseErrorListener {
             throw exceptions.get(0);
         }
 
-        final StringBuilder sb = new StringBuilder();
+        final var sb = new StringBuilder();
         boolean first = true;
-        for (YangSyntaxErrorException e : exceptions) {
+        for (var ex : exceptions) {
             if (first) {
                 first = false;
             } else {
                 sb.append('\n');
             }
 
-            sb.append(e.getFormattedMessage());
+            sb.append(ex.getFormattedMessage());
         }
 
-        throw new YangSyntaxErrorException(source, 0, 0, sb.toString());
+        throw new YangSyntaxErrorException(sourceId, 0, 0, sb.toString());
     }
 }
index 48027e0980e578076f34be59c61fc68e83c92ac6..5845fb2ec537b669f951c20cdd97edf66fd57810 100644 (file)
@@ -24,13 +24,13 @@ import org.opendaylight.yangtools.yang.ir.IRArgument;
 import org.opendaylight.yangtools.yang.ir.IRKeyword;
 import org.opendaylight.yangtools.yang.ir.IRKeyword.Unqualified;
 import org.opendaylight.yangtools.yang.ir.IRStatement;
+import org.opendaylight.yangtools.yang.ir.YangIRSchemaSource;
 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
 import org.opendaylight.yangtools.yang.model.api.meta.StatementSourceReference;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.api.stmt.ImportEffectiveStatement;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.YangIRSchemaSource;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YangTextSource;
 import org.opendaylight.yangtools.yang.parser.api.YangSyntaxErrorException;
 import org.opendaylight.yangtools.yang.parser.spi.source.ExplicitStatement;
 
@@ -133,44 +133,44 @@ public abstract class YangModelDependencyInfo {
      * @throws IllegalArgumentException If the root statement is not a valid YANG module/submodule
      */
     public static @NonNull YangModelDependencyInfo forIR(final YangIRSchemaSource source) {
-        return forIR(source.getRootStatement(), source.getIdentifier());
+        return forIR(source.getRootStatement(), source.sourceId());
     }
 
     /**
      * Extracts {@link YangModelDependencyInfo} from an intermediate representation root statement of a YANG model.
      *
-     * @param source Source identifier
+     * @param sourceId Source identifier
      * @param rootStatement root statement
      * @return {@link YangModelDependencyInfo}
      * @throws IllegalArgumentException If the root statement is not a valid YANG module/submodule
      */
     static @NonNull YangModelDependencyInfo forIR(final IRStatement rootStatement,
-            final SourceIdentifier source) {
+            final SourceIdentifier sourceId) {
         final IRKeyword keyword = rootStatement.keyword();
         checkArgument(keyword instanceof Unqualified, "Invalid root statement %s", keyword);
 
         final String arg = keyword.identifier();
         if (MODULE.equals(arg)) {
-            return parseModuleContext(rootStatement, source);
+            return parseModuleContext(rootStatement, sourceId);
         }
         if (SUBMODULE.equals(arg)) {
-            return parseSubmoduleContext(rootStatement, source);
+            return parseSubmoduleContext(rootStatement, sourceId);
         }
         throw new IllegalArgumentException("Root of parsed AST must be either module or submodule");
     }
 
     /**
-     * Extracts {@link YangModelDependencyInfo} from a {@link YangTextSchemaSource}. This parsing does not
-     * validate full YANG module, only parses header up to the revisions and imports.
+     * Extracts {@link YangModelDependencyInfo} from a {@link YangTextSource}. This parsing does not validate full YANG
+     * module, only parses header up to the revisions and imports.
      *
-     * @param yangText {@link YangTextSchemaSource}
+     * @param yangText {@link YangTextSource}
      * @return {@link YangModelDependencyInfo}
      * @throws YangSyntaxErrorException If the resource does not pass syntactic analysis
      * @throws IOException When the resource cannot be read
      */
-    public static YangModelDependencyInfo forYangText(final YangTextSchemaSource yangText)
+    public static YangModelDependencyInfo forYangText(final YangTextSource yangText)
             throws IOException, YangSyntaxErrorException {
-        final YangStatementStreamSource source = YangStatementStreamSource.create(yangText);
+        final var source = YangStatementStreamSource.create(yangText);
         return forIR(source.rootStatement(), source.getIdentifier());
     }
 
index 306632cd0276257b338f100840f4d04730cd1710..d36fd11adcd9d885f9f569b0faa2ebf0f5f107bf 100644 (file)
@@ -21,11 +21,11 @@ import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.YangVersion;
 import org.opendaylight.yangtools.yang.ir.IRKeyword;
 import org.opendaylight.yangtools.yang.ir.IRStatement;
+import org.opendaylight.yangtools.yang.ir.YangIRSchemaSource;
 import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
 import org.opendaylight.yangtools.yang.model.api.meta.StatementSourceReference;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.YangIRSchemaSource;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.spi.source.YangTextSource;
 import org.opendaylight.yangtools.yang.parser.antlr.YangStatementLexer;
 import org.opendaylight.yangtools.yang.parser.antlr.YangStatementParser;
 import org.opendaylight.yangtools.yang.parser.antlr.YangStatementParser.FileContext;
@@ -51,25 +51,25 @@ public final class YangStatementStreamSource extends AbstractSimpleIdentifiable<
     private final IRStatement rootStatement;
     private final String sourceName;
 
-    private YangStatementStreamSource(final SourceIdentifier identifier,  final IRStatement rootStatement,
+    private YangStatementStreamSource(final SourceIdentifier sourceId, final IRStatement rootStatement,
             final String sourceName) {
-        super(identifier);
+        super(sourceId);
         this.rootStatement = requireNonNull(rootStatement);
         this.sourceName = sourceName;
     }
 
     /**
-     * Create a {@link YangStatementStreamSource} for a {@link YangTextSchemaSource}.
+     * Create a {@link YangStatementStreamSource} for a {@link YangTextSource}.
      *
      * @param source YangTextSchemaSource, must not be null
      * @return A new {@link YangStatementStreamSource}
      * @throws IOException When we fail to read the source
      * @throws YangSyntaxErrorException If the source fails basic parsing
      */
-    public static YangStatementStreamSource create(final YangTextSchemaSource source) throws IOException,
-            YangSyntaxErrorException {
-        return new YangStatementStreamSource(source.getIdentifier(),
-            IRSupport.createStatement(parseYangSource(source)), source.getSymbolicName().orElse(null));
+    public static YangStatementStreamSource create(final YangTextSource source)
+            throws IOException, YangSyntaxErrorException {
+        return new YangStatementStreamSource(source.sourceId(),
+            IRSupport.createStatement(parseYangSource(source)), source.symbolicName());
     }
 
     /**
@@ -80,7 +80,7 @@ public final class YangStatementStreamSource extends AbstractSimpleIdentifiable<
      * @throws NullPointerException if {@code source} is null
      */
     public static YangStatementStreamSource create(final YangIRSchemaSource source) {
-        return create(source.getIdentifier(), source.getRootStatement(), source.getSymbolicName().orElse(null));
+        return create(source.sourceId(), source.getRootStatement(), source.symbolicName());
     }
 
     public static YangStatementStreamSource create(final SourceIdentifier identifier, final IRStatement rootStatement,
@@ -130,14 +130,14 @@ public final class YangStatementStreamSource extends AbstractSimpleIdentifiable<
         return rootStatement;
     }
 
-    static StatementContext parseYangSource(final YangTextSchemaSource source)
+    static StatementContext parseYangSource(final YangTextSource source)
             throws IOException, YangSyntaxErrorException {
         try (var reader = source.openStream()) {
-            return parseYangSource(source.getIdentifier(), reader);
+            return parseYangSource(source.sourceId(), reader);
         }
     }
 
-    private static StatementContext parseYangSource(final SourceIdentifier source, final Reader stream)
+    private static StatementContext parseYangSource(final SourceIdentifier sourceId, final Reader stream)
             throws IOException, YangSyntaxErrorException {
         final YangStatementLexer lexer = new CompactYangStatementLexer(CharStreams.fromReader(stream));
         final YangStatementParser parser = new YangStatementParser(new CommonTokenStream(lexer));
@@ -145,7 +145,7 @@ public final class YangStatementStreamSource extends AbstractSimpleIdentifiable<
         lexer.removeErrorListeners();
         parser.removeErrorListeners();
 
-        final YangErrorListener errorListener = new YangErrorListener(source);
+        final YangErrorListener errorListener = new YangErrorListener(sourceId);
         lexer.addErrorListener(errorListener);
         parser.addErrorListener(errorListener);
 
index cdbdb827042a21b1d4988896bc44f76bb8edbe3a..23f45572c5a5f7951d32d1e581e61f8d4c407915 100644 (file)
@@ -22,9 +22,9 @@ import org.opendaylight.yangtools.yang.common.XMLNamespace;
 import org.opendaylight.yangtools.yang.common.YangVersion;
 import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
 import org.opendaylight.yangtools.yang.model.api.meta.StatementSourceReference;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.YinDomSchemaSource;
-import org.opendaylight.yangtools.yang.model.repo.api.YinXmlSchemaSource;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.spi.source.YinDomSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YinXmlSource;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
 import org.opendaylight.yangtools.yang.parser.spi.source.PrefixResolver;
 import org.opendaylight.yangtools.yang.parser.spi.source.QNameToStatementDefinition;
@@ -40,8 +40,8 @@ import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
 /**
- * A {@link StatementStreamSource} based on a {@link YinXmlSchemaSource}. Internal implementation works on top
- * of {@link YinDomSchemaSource} and its DOM document.
+ * A {@link StatementStreamSource} based on a {@link YinXmlSource}. Internal implementation works on top
+ * of {@link YinDomSource} and its DOM document.
  *
  * @author Robert Varga
  */
@@ -58,17 +58,17 @@ public final class YinStatementStreamSource extends AbstractSimpleIdentifiable<S
         });
     private final Node root;
 
-    private YinStatementStreamSource(final SourceIdentifier identifier, final Node root) {
-        super(identifier);
+    private YinStatementStreamSource(final SourceIdentifier sourceId, final Node root) {
+        super(sourceId);
         this.root = requireNonNull(root);
     }
 
-    public static StatementStreamSource create(final YinXmlSchemaSource source) throws TransformerException {
-        return create(YinDomSchemaSource.transform(source));
+    public static StatementStreamSource create(final YinXmlSource source) throws TransformerException {
+        return create(YinDomSource.transform(source));
     }
 
-    public static StatementStreamSource create(final YinDomSchemaSource source) {
-        return new YinStatementStreamSource(source.getIdentifier(), source.getSource().getNode());
+    public static StatementStreamSource create(final YinDomSource source) {
+        return new YinStatementStreamSource(source.sourceId(), source.getSource().getNode());
     }
 
     private static StatementDefinition getValidDefinition(final Node node, final StatementWriter writer,
index 8881d83890c5ffbd0db1105220fbe8cc125e2233..f4921d0e1c1c16f9b1b6d17270f5b93b122edcea 100644 (file)
@@ -14,24 +14,22 @@ import javax.xml.parsers.SAXParser;
 import javax.xml.transform.dom.DOMSource;
 import org.opendaylight.yangtools.util.xml.UntrustedXML;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
-import org.opendaylight.yangtools.yang.model.repo.api.YinDomSchemaSource;
-import org.opendaylight.yangtools.yang.model.repo.api.YinTextSchemaSource;
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistry;
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceTransformer;
+import org.opendaylight.yangtools.yang.model.spi.source.YinDomSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YinTextSource;
 import org.w3c.dom.Document;
 import org.xml.sax.SAXException;
 import org.xml.sax.helpers.DefaultHandler;
 
 /**
- * A {@link SchemaSourceTransformer} which handles translation of models from
- * {@link YinTextSchemaSource} representation into {@link YinDomSchemaSource}.
- *
- * @author Robert Varga
+ * A {@link SchemaSourceTransformer} which handles translation of models from {@link YinTextSource} representation into
+ * {@link YinDomSource}.
  */
 @Beta
-public final class YinTextToDomTransformer extends SchemaSourceTransformer<YinTextSchemaSource, YinDomSchemaSource> {
+public final class YinTextToDomTransformer extends SchemaSourceTransformer<YinTextSource, YinDomSource> {
     private YinTextToDomTransformer(final SchemaRepository provider, final SchemaSourceRegistry consumer) {
-        super(provider, YinTextSchemaSource.class, consumer, YinDomSchemaSource.class,
+        super(provider, YinTextSource.class, consumer, YinDomSource.class,
             input -> Futures.immediateFuture(transformSource(input)));
     }
 
@@ -39,13 +37,11 @@ public final class YinTextToDomTransformer extends SchemaSourceTransformer<YinTe
         return new YinTextToDomTransformer(provider, consumer);
     }
 
-    public static YinDomSchemaSource transformSource(final YinTextSchemaSource source) throws SAXException,
-            IOException {
+    public static YinDomSource transformSource(final YinTextSource source) throws SAXException, IOException {
         final Document doc = UntrustedXML.newDocumentBuilder().newDocument();
         final SAXParser parser = UntrustedXML.newSAXParser();
         final DefaultHandler handler = new StatementSourceReferenceHandler(doc, null);
         parser.parse(source.openStream(), handler);
-        return YinDomSchemaSource.create(source.getIdentifier(), new DOMSource(doc),
-            source.getSymbolicName().orElse(null));
+        return YinDomSource.create(source.sourceId(), new DOMSource(doc), source.symbolicName());
     }
 }
index 84f4494b5923623a34047cf8a28a8800bb643d7f..bec77d82dd61669001fafa50562de4253c8def32 100644 (file)
@@ -24,10 +24,10 @@ import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
 import org.opendaylight.yangtools.yang.model.api.meta.DeclarationReference;
 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.api.stmt.ImportEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ImportStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.PrefixStatement;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.ri.stmt.DeclaredStatementDecorators;
 import org.opendaylight.yangtools.yang.model.ri.stmt.DeclaredStatements;
 import org.opendaylight.yangtools.yang.model.ri.stmt.EffectiveStatements;
index a63c291f966c2266b57cc8d590a281a99886ee5a..45f1c0724ebd252e9b9b164bb500ef8095b36702 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.import_;
 import com.google.common.annotations.Beta;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.common.Empty;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ParserNamespace;
 
index 517ac367faf7440f31f5e3321d999ac9d8f9a255..01a3d126b87abd17c2e88f848640207784e34a62 100644 (file)
@@ -16,13 +16,13 @@ import org.opendaylight.yangtools.yang.common.Empty;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.common.UnresolvedQName.Unqualified;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.api.stmt.ImportEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ImportStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ModuleStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.PrefixStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.RevisionDateStatement;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.parser.rfc7950.namespace.ModuleQNameToPrefix;
 import org.opendaylight.yangtools.yang.parser.spi.ParserNamespaces;
 import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
index 48caf00682855586c0773be36602b1229c679159..aa2fcb41fa9f8c2138d61180a9256e42110aca42 100644 (file)
@@ -16,10 +16,10 @@ import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
 import org.opendaylight.yangtools.yang.model.api.meta.DeclarationReference;
 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.api.stmt.BelongsToEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.BelongsToStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.PrefixStatement;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.ri.stmt.DeclaredStatementDecorators;
 import org.opendaylight.yangtools.yang.model.ri.stmt.DeclaredStatements;
 import org.opendaylight.yangtools.yang.model.ri.stmt.EffectiveStatements;
index 0ece778a67a711b05d7e742cd0bec3dcf9deb7bd..33295694d4c87012b6d1bcbd9ca9b0e893838916 100644 (file)
@@ -21,12 +21,12 @@ import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
 import org.opendaylight.yangtools.yang.model.api.meta.DeclarationReference;
 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.api.stmt.IncludeEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.IncludeStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.RevisionDateStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.SubmoduleEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.SubmoduleStatement;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.ri.stmt.DeclaredStatementDecorators;
 import org.opendaylight.yangtools.yang.model.ri.stmt.DeclaredStatements;
 import org.opendaylight.yangtools.yang.model.ri.stmt.EffectiveStatements;
index 03c4300b7ea64b9b141826cd74a23f372c9307c3..7d2e1f9961f6eba4b34e9bc6bc6ed14034559c6c 100644 (file)
@@ -31,11 +31,11 @@ import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
 import org.opendaylight.yangtools.yang.model.api.meta.DeclarationReference;
 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ModuleStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.NamespaceStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.PrefixStatement;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.ri.stmt.DeclaredStatementDecorators;
 import org.opendaylight.yangtools.yang.model.ri.stmt.DeclaredStatements;
 import org.opendaylight.yangtools.yang.model.spi.meta.SubstatementIndexingException;
index 231c99f16d5e16bc6a8eaebec0b4ab980722ac34..d9e2e732b6120f2b850ac97649567004ea46337a 100644 (file)
@@ -18,11 +18,11 @@ import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
 import org.opendaylight.yangtools.yang.model.api.meta.DeclarationReference;
 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.api.stmt.BelongsToStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.PrefixStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.SubmoduleEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.SubmoduleStatement;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.ri.stmt.DeclaredStatementDecorators;
 import org.opendaylight.yangtools.yang.model.ri.stmt.DeclaredStatements;
 import org.opendaylight.yangtools.yang.model.spi.meta.SubstatementIndexingException;
index bd2ef7e9e93c3d983c87b9e10ff415758b44c624..190b9cc784a658b9b804ac61bce8f340f60c011a 100644 (file)
@@ -18,7 +18,7 @@ import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.ir.IOSupport;
 import org.opendaylight.yangtools.yang.ir.IRStatement;
-import org.opendaylight.yangtools.yang.model.repo.api.YangIRSchemaSource;
+import org.opendaylight.yangtools.yang.ir.YangIRSchemaSource;
 import org.opendaylight.yangtools.yang.parser.rfc7950.repo.TextToIRTransformer;
 import org.opendaylight.yangtools.yang.stmt.TestUtils;
 
index 9eee31f90d227ae30ace2bd8addd5c79cdfcdab4..fbb2a7f24f66284677407fa37435ac560f0dec75 100644 (file)
@@ -24,10 +24,10 @@ import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.api.stmt.FeatureSet;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
-import org.opendaylight.yangtools.yang.model.repo.api.YinTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YangTextSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YinTextSource;
 import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
 import org.opendaylight.yangtools.yang.parser.api.YangSyntaxErrorException;
 import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
@@ -67,7 +67,7 @@ public final class StmtTestUtils {
 
     public static YangStatementStreamSource sourceForResource(final String resourceName) {
         try {
-            return YangStatementStreamSource.create(YangTextSchemaSource.forPath(Path.of(
+            return YangStatementStreamSource.create(YangTextSource.forPath(Path.of(
                 StmtTestUtils.class.getResource(resourceName).toURI())));
         } catch (IOException | YangSyntaxErrorException | URISyntaxException e) {
             throw new IllegalArgumentException("Failed to create source", e);
@@ -117,7 +117,7 @@ public final class StmtTestUtils {
 
         final Collection<YangStatementStreamSource> sources = new ArrayList<>(files.length);
         for (File file : files) {
-            sources.add(YangStatementStreamSource.create(YangTextSchemaSource.forPath(file.toPath())));
+            sources.add(YangStatementStreamSource.create(YangTextSource.forPath(file.toPath())));
         }
 
         return parseYangSources(config, supportedFeatures, sources);
@@ -151,10 +151,10 @@ public final class StmtTestUtils {
         final File[] files = new File(resourceDir.toURI()).listFiles(YIN_FILE_FILTER);
         final StatementStreamSource[] sources = new StatementStreamSource[files.length];
         for (int i = 0; i < files.length; i++) {
-            final SourceIdentifier identifier = YinTextSchemaSource.identifierFromFilename(files[i].getName());
+            final SourceIdentifier identifier = YinTextSource.identifierFromFilename(files[i].getName());
 
             sources[i] = YinStatementStreamSource.create(YinTextToDomTransformer.transformSource(
-                YinTextSchemaSource.delegateForByteSource(identifier, Files.asByteSource(files[i]))));
+                YinTextSource.delegateForByteSource(identifier, Files.asByteSource(files[i]))));
         }
 
         return parseYinSources(config, sources);
index 29ddfcd4e184c07ab8c9442b068fa2ce84de0d2e..f6c8f08764e36794c75e98352c3503cb0df7ff89 100644 (file)
@@ -24,8 +24,8 @@ import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.stmt.FeatureSet;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
-import org.opendaylight.yangtools.yang.model.repo.api.YinTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YangTextSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YinTextSource;
 import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
 import org.opendaylight.yangtools.yang.parser.rfc7950.repo.YangStatementStreamSource;
 import org.opendaylight.yangtools.yang.parser.rfc7950.repo.YinStatementStreamSource;
@@ -51,7 +51,7 @@ public final class TestUtils {
             .listFiles(StmtTestUtils.YANG_FILE_FILTER);
         final var sources = new ArrayList<StatementStreamSource>(files.length);
         for (var file : files) {
-            sources.add(YangStatementStreamSource.create(YangTextSchemaSource.forPath(file.toPath())));
+            sources.add(YangStatementStreamSource.create(YangTextSource.forPath(file.toPath())));
         }
         return sources;
     }
@@ -96,9 +96,9 @@ public final class TestUtils {
         return reactor.buildEffective();
     }
 
-    public static YangTextSchemaSource assertSchemaSource(final String resourcePath) {
+    public static YangTextSource assertSchemaSource(final String resourcePath) {
         try {
-            return YangTextSchemaSource.forPath(Path.of(TestUtils.class.getResource(resourcePath).toURI()));
+            return YangTextSource.forPath(Path.of(TestUtils.class.getResource(resourcePath).toURI()));
         } catch (URISyntaxException e) {
             throw new AssertionError(e);
         }
@@ -112,18 +112,17 @@ public final class TestUtils {
 
         for (File file : new File(resourceDirectory).listFiles()) {
             reactor.addSource(YinStatementStreamSource.create(YinTextToDomTransformer.transformSource(
-                YinTextSchemaSource.forPath(file.toPath()))));
+                YinTextSource.forPath(file.toPath()))));
         }
 
         return reactor.buildEffective();
     }
 
-    public static Module loadYinModule(final YinTextSchemaSource source) throws ReactorException, SAXException,
-            IOException {
+    public static Module loadYinModule(final YinTextSource source) throws ReactorException, SAXException, IOException {
         return RFC7950Reactors.defaultReactor().newBuild()
-                .addSource(YinStatementStreamSource.create(YinTextToDomTransformer.transformSource(source)))
-                .buildEffective()
-                .getModules().iterator().next();
+            .addSource(YinStatementStreamSource.create(YinTextToDomTransformer.transformSource(source)))
+            .buildEffective()
+            .getModules().iterator().next();
     }
 
     public static ModuleImport findImport(final Collection<? extends ModuleImport> imports, final String prefix) {
index ad0e0e2cfb8d0421ad24575bc9b717a48036ffb3..644c2ed455f61f6e960a88689d42ff80aa815b3c 100644 (file)
@@ -15,7 +15,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
 
 import java.io.IOException;
 import org.junit.jupiter.api.Test;
-import org.opendaylight.yangtools.yang.model.repo.api.YinTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YinTextSource;
 import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
 import org.opendaylight.yangtools.yang.parser.rfc7950.repo.YinStatementStreamSource;
 import org.opendaylight.yangtools.yang.parser.rfc7950.repo.YinTextToDomTransformer;
@@ -36,7 +36,7 @@ class YinFileStmtTest {
     private static StatementStreamSource createSource(final String name) {
         try {
             return YinStatementStreamSource.create(YinTextToDomTransformer.transformSource(
-                YinTextSchemaSource.forResource(YinFileStmtTest.class, "/semantic-statement-parser/yin/" + name)));
+                YinTextSource.forResource(YinFileStmtTest.class, "/semantic-statement-parser/yin/" + name)));
         } catch (SAXException | IOException e) {
             throw new IllegalArgumentException(e);
         }
index 56b2b13511a732f32ee6346a417b3be21c0a17ad..0a25015a87d9c5c0c19c7593dbbb99d8b49a9684 100644 (file)
@@ -17,6 +17,7 @@ import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.UnresolvedQName.Unqualified;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.api.stmt.ExtensionEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ExtensionStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.FeatureEffectiveStatement;
@@ -36,7 +37,6 @@ import org.opendaylight.yangtools.yang.model.api.stmt.SubmoduleStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.TypedefEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.TypedefStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.UnknownStatement;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ParserNamespace;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils;
index fe4b755b92b37834d14ecec0b0e4a662090b782b..b30f7069a996f8900c1540f4530e2ac2bae3b1f5 100644 (file)
@@ -15,14 +15,12 @@ import com.google.common.base.MoreObjects.ToStringHelper;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.common.UnresolvedQName.Unqualified;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 
 /**
  * Namespace key matching criterion.
  *
  * @param <K> Key type
- *
- * @author Robert Varga
  */
 @Beta
 public abstract class NamespaceKeyCriterion<K> {
index 476d790736778027ca4a879a01a107da57ecf1a0..b932b848b16a57921e409f134d352a5f0eb46fdf 100644 (file)
@@ -9,7 +9,7 @@ package org.opendaylight.yangtools.yang.parser.spi.meta;
 
 import static java.util.Objects.requireNonNull;
 
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 
 public class ReactorException extends Exception {
     private static final long serialVersionUID = 1L;
@@ -21,13 +21,13 @@ public class ReactorException extends Exception {
             final Throwable cause) {
         super(message, cause);
         this.phase = requireNonNull(phase);
-        this.sourceIdentifier = sourceId;
+        sourceIdentifier = sourceId;
     }
 
     public ReactorException(final ModelProcessingPhase phase, final String message, final SourceIdentifier sourceId) {
         super(message);
         this.phase = requireNonNull(phase);
-        this.sourceIdentifier = sourceId;
+        sourceIdentifier = sourceId;
     }
 
     public final ModelProcessingPhase getPhase() {
index ef3b151d96a1146c2f6ff601e3ac5667cf32e454..02df2975af90ca17c23f31c827e98b03e19e0a86 100644 (file)
@@ -7,14 +7,14 @@
  */
 package org.opendaylight.yangtools.yang.parser.spi.meta;
 
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 
 public class SomeModifiersUnresolvedException extends ReactorException {
-
+    @java.io.Serial
     private static final long serialVersionUID = 1L;
 
-    public SomeModifiersUnresolvedException(ModelProcessingPhase phase, SourceIdentifier sourceId, Throwable cause) {
+    public SomeModifiersUnresolvedException(final ModelProcessingPhase phase, final SourceIdentifier sourceId,
+            final Throwable cause) {
         super(phase, "Some of " + phase + " modifiers for statements were not resolved.", sourceId, cause);
     }
-
 }
index e5cc2c4c1d43905d867d8408da480d2cc5d9d6c6..11577ba97b6d2e4b660184e7b6edd90d645bc628 100644 (file)
@@ -23,7 +23,7 @@ import org.opendaylight.yangtools.yang.common.YangVersion;
 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 
 /**
  * An inference context associated with an instance of a statement.
index c04edcc879c72dedcb120a529db8a9933efdf692..2ac3eb5f19185181749a4942f8c49c0bbf2c3640 100644 (file)
@@ -9,7 +9,7 @@ package org.opendaylight.yangtools.yang.parser.spi.source;
 
 import org.opendaylight.yangtools.concepts.Identifiable;
 import org.opendaylight.yangtools.yang.common.YangVersion;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 
 /**
  * Statement stream source, which is used for inference of effective model.
similarity index 71%
rename from parser/yang-test-util/src/main/java/org/opendaylight/yangtools/yang/test/util/LiteralYangTextSchemaSource.java
rename to parser/yang-test-util/src/main/java/org/opendaylight/yangtools/yang/test/util/LiteralYangTextSource.java
index aa50efb232173aa78decc0ce59c00b7634497fdb..1e0f303f37d06b994e31211223c568789920382a 100644 (file)
@@ -11,26 +11,25 @@ import static com.google.common.base.Preconditions.checkArgument;
 import static java.util.Objects.requireNonNull;
 
 import java.io.StringReader;
-import java.util.Optional;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.common.UnresolvedQName;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.spi.source.YangTextSource;
 
 /**
- * A {@link YangTextSchemaSource} backed by a string literal.
+ * A {@link YangTextSource} backed by a string literal.
  */
-final class LiteralYangTextSchemaSource extends YangTextSchemaSource {
+final class LiteralYangTextSource extends YangTextSource {
     private final @NonNull String sourceString;
 
-    private LiteralYangTextSchemaSource(final SourceIdentifier identifier, final String sourceString,
+    private LiteralYangTextSource(final SourceIdentifier identifier, final String sourceString,
             final String symbolicName) {
         super(identifier);
         this.sourceString = requireNonNull(sourceString);
     }
 
     /**
-     * Create a new {@link YangTextSchemaSource} backed by a String input.
+     * Create a new {@link YangTextSource} backed by a String input.
      *
      * @param sourceString YANG file as a String
      * @return A new instance.
@@ -38,7 +37,7 @@ final class LiteralYangTextSchemaSource extends YangTextSchemaSource {
      * @throws IllegalArgumentException if {@code sourceString} does not a valid YANG body, given a rather restrictive
      *         view of what is valid.
      */
-    static @NonNull LiteralYangTextSchemaSource ofLiteral(final String sourceString) {
+    static @NonNull LiteralYangTextSource ofLiteral(final String sourceString) {
         // First line of a YANG file looks as follows:
         //   `module module-name {`
         // therefore in order to extract the name of the module from a plain string, we are interested in the second
@@ -50,7 +49,7 @@ final class LiteralYangTextSchemaSource extends YangTextSchemaSource {
         final String arg = firstLine[1].strip();
         final var localName = UnresolvedQName.tryLocalName(arg);
         checkArgument(localName != null);
-        return new LiteralYangTextSchemaSource(new SourceIdentifier(localName), sourceString, arg);
+        return new LiteralYangTextSource(new SourceIdentifier(localName), sourceString, arg);
     }
 
     @Override
@@ -59,7 +58,7 @@ final class LiteralYangTextSchemaSource extends YangTextSchemaSource {
     }
 
     @Override
-    public Optional<String> getSymbolicName() {
-        return Optional.of(getIdentifier().name().getLocalName());
+    public String symbolicName() {
+        return sourceId().name().getLocalName();
     }
 }
index 02b0bcc37378c9db2cd0c16d878159374c623fb3..77e19efb6360be33f48f48f34546f20f64eb0ce4 100644 (file)
@@ -26,9 +26,9 @@ import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.YangConstants;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.model.api.source.SourceRepresentation;
 import org.opendaylight.yangtools.yang.model.api.stmt.FeatureSet;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YangTextSource;
 import org.opendaylight.yangtools.yang.parser.api.YangParser;
 import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
 import org.opendaylight.yangtools.yang.parser.api.YangParserException;
@@ -107,8 +107,8 @@ public final class YangParserTestUtils {
      */
     public static EffectiveModelContext parseYangResource(final String resource, final YangParserConfiguration config,
             final Set<QName> supportedFeatures) {
-        final YangTextSchemaSource source = YangTextSchemaSource.forResource(YangParserTestUtils.class, resource);
-        return parseYangSources(config, supportedFeatures, source);
+        return parseYangSources(config, supportedFeatures,
+            YangTextSource.forResource(YangParserTestUtils.class, resource));
     }
 
     /**
@@ -201,7 +201,7 @@ public final class YangParserTestUtils {
     public static EffectiveModelContext parseYangFiles(final Set<QName> supportedFeatures,
             final YangParserConfiguration config, final Collection<File> files) {
         return parseSources(config, supportedFeatures,
-            files.stream().map(file -> YangTextSchemaSource.forPath(file.toPath())).collect(Collectors.toList()));
+            files.stream().map(file -> YangTextSource.forPath(file.toPath())).collect(Collectors.toList()));
     }
 
     /**
@@ -275,9 +275,9 @@ public final class YangParserTestUtils {
     }
 
     public static EffectiveModelContext parseYangResources(final Class<?> clazz, final Collection<String> resources) {
-        final List<YangTextSchemaSource> sources = new ArrayList<>(resources.size());
+        final var sources = new ArrayList<YangTextSource>(resources.size());
         for (final String r : resources) {
-            sources.add(YangTextSchemaSource.forResource(clazz, r));
+            sources.add(YangTextSource.forResource(clazz, r));
         }
         return parseSources(YangParserConfiguration.DEFAULT, null, sources);
     }
@@ -340,12 +340,12 @@ public final class YangParserTestUtils {
     }
 
     public static EffectiveModelContext parseYangSources(final YangParserConfiguration config,
-            final Set<QName> supportedFeatures, final YangTextSchemaSource... sources) {
+            final Set<QName> supportedFeatures, final YangTextSource... sources) {
         return parseSources(config, supportedFeatures, Arrays.asList(sources));
     }
 
     public static EffectiveModelContext parseSources(final YangParserConfiguration config,
-            final Set<QName> supportedFeatures, final Collection<? extends SchemaSourceRepresentation> sources) {
+            final Set<QName> supportedFeatures, final Collection<? extends SourceRepresentation> sources) {
         final YangParser parser = PARSER_FACTORY.createParser(config);
         if (supportedFeatures != null) {
             parser.setSupportedFeatures(FeatureSet.of(supportedFeatures));
@@ -374,7 +374,7 @@ public final class YangParserTestUtils {
      */
     public static EffectiveModelContext parseYang(final String... sources) {
         return parseSources(YangParserConfiguration.DEFAULT, null,
-            Arrays.stream(sources).map(LiteralYangTextSchemaSource::ofLiteral).toList());
+            Arrays.stream(sources).map(LiteralYangTextSource::ofLiteral).toList());
     }
 
     @SuppressFBWarnings(value = "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE", justification = "Wrong inferent on listFiles")
index 87c56befe43894cf1b7a0fe80aa0d1e232f355d3..9d83c314d57defb5046fa459802fdfe0cb5587f6 100644 (file)
@@ -10,7 +10,7 @@ module org.opendaylight.yangtools.plugin.generator.api {
 
     requires transitive com.google.common;
     requires transitive org.opendaylight.yangtools.yang.model.api;
-    requires transitive org.opendaylight.yangtools.yang.repo.api;
+    requires transitive org.opendaylight.yangtools.yang.model.spi;
     requires transitive org.opendaylight.yangtools.concepts;
 
     // Annotations
index 963ca9d1a8a66900f5d405c2123d77b728536f3c..c3b966dd2b285f5b7c9ee6ea28e50a9ba9058b1e 100644 (file)
@@ -9,8 +9,8 @@ package org.opendaylight.yangtools.plugin.generator.api;
 
 import java.util.Optional;
 import org.opendaylight.yangtools.yang.model.api.ModuleLike;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.api.source.SourceRepresentation;
+import org.opendaylight.yangtools.yang.model.spi.source.YangTextSource;
 
 /**
  * An SPI-level interface to find the schema source for a particular YANG module, as packaged in the final artifact.
@@ -26,10 +26,9 @@ public interface ModuleResourceResolver {
      * @throws NullPointerException if any argument is {@code null}
      * @throws IllegalArgumentException if the requested representation is not supported by this resolver
      */
-    Optional<String> findModuleResourcePath(ModuleLike module,
-        Class<? extends SchemaSourceRepresentation> representation);
+    Optional<String> findModuleResourcePath(ModuleLike module, Class<? extends SourceRepresentation> representation);
 
     default Optional<String> findModuleYangTextResourcePath(final ModuleLike module) {
-        return findModuleResourcePath(module, YangTextSchemaSource.class);
+        return findModuleResourcePath(module, YangTextSource.class);
     }
 }
index aab8f5e2d3347b647e1999f2dd28d95f3b13c98b..3c58e1aa0b15721d3e53f94e2922be5c0a7fabe4 100644 (file)
@@ -19,9 +19,9 @@ import org.opendaylight.yangtools.plugin.generator.api.ModuleResourceResolver;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.ModuleLike;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.SourceRepresentation;
+import org.opendaylight.yangtools.yang.model.spi.source.YangTextSource;
 
 final class ContextHolder implements Immutable, ModuleResourceResolver {
     private final @NonNull EffectiveModelContext context;
@@ -36,8 +36,8 @@ final class ContextHolder implements Immutable, ModuleResourceResolver {
 
     @Override
     public Optional<String> findModuleResourcePath(final ModuleLike module,
-            final Class<? extends SchemaSourceRepresentation> representation) {
-        checkArgument(YangTextSchemaSource.class.equals(requireNonNull(representation)),
+            final Class<? extends SourceRepresentation> representation) {
+        checkArgument(YangTextSource.class.equals(requireNonNull(representation)),
             "Unsupported representation %s", representation);
         final SourceIdentifier id = Util.moduleToIdentifier(module);
         return sources.contains(id)
index 20d55e910e81d3aa8cb8cddfac8e0e679c21d638..e607ffef8b258c0443194fb86b442512239ec428 100644 (file)
@@ -25,8 +25,8 @@ import java.util.Set;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.Submodule;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.spi.source.YangTextSource;
 import org.opendaylight.yangtools.yang.parser.api.YangParser;
 import org.opendaylight.yangtools.yang.parser.api.YangParserException;
 import org.slf4j.Logger;
@@ -39,22 +39,22 @@ import org.slf4j.LoggerFactory;
 final class ProcessorModuleReactor {
     private static final Logger LOG = LoggerFactory.getLogger(ProcessorModuleReactor.class);
 
-    private final Map<SourceIdentifier, YangTextSchemaSource> modelsInProject;
+    private final Map<SourceIdentifier, YangTextSource> modelsInProject;
     private final Collection<ScannedDependency> dependencies;
 
     private YangParser parser;
 
-    ProcessorModuleReactor(final YangParser parser, final Collection<YangTextSchemaSource> modelsInProject,
+    ProcessorModuleReactor(final YangParser parser, final Collection<YangTextSource> modelsInProject,
             final Collection<ScannedDependency> dependencies) {
         this.parser = requireNonNull(parser);
-        this.modelsInProject = Maps.uniqueIndex(modelsInProject, YangTextSchemaSource::getIdentifier);
+        this.modelsInProject = Maps.uniqueIndex(modelsInProject, YangTextSource::sourceId);
         this.dependencies = ImmutableList.copyOf(dependencies);
     }
 
     ContextHolder toContext() throws IOException, YangParserException {
         checkState(parser != null, "Context has already been assembled");
 
-        for (YangTextSchemaSource source : toUniqueSources(dependencies)) {
+        for (var source : toUniqueSources(dependencies)) {
             // This source is coming from a dependency:
             // - its identifier should be accurate, as it should have been processed into a file with accurate name
             // - it is not required to be parsed, hence we add it just as a library source
@@ -84,16 +84,16 @@ final class ProcessorModuleReactor {
         return new ContextHolder(schemaContext, modules, modelsInProject.keySet());
     }
 
-    Collection<YangTextSchemaSource> getModelsInProject() {
+    Collection<YangTextSource> getModelsInProject() {
         return modelsInProject.values();
     }
 
-    private static Collection<YangTextSchemaSource> toUniqueSources(final Collection<ScannedDependency> dependencies)
+    private static Collection<YangTextSource> toUniqueSources(final Collection<ScannedDependency> dependencies)
             throws IOException {
-        final Map<String, YangTextSchemaSource> byContent = new HashMap<>();
+        final Map<String, YangTextSource> byContent = new HashMap<>();
 
         for (ScannedDependency dependency : dependencies) {
-            for (YangTextSchemaSource s : dependency.sources()) {
+            for (YangTextSource s : dependency.sources()) {
                 try (Reader reader = s.openStream()) {
                     final String contents = CharStreams.toString(reader);
                     byContent.putIfAbsent(contents, s);
index 3bd4b2b015cfb9f452ca8d353bcb3508c0b8d2bf..efa1db1ea5bc93bc6ef9fe71cfa4109a21e22b17 100644 (file)
@@ -28,7 +28,7 @@ import java.util.zip.ZipFile;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.project.MavenProject;
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YangTextSource;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -40,8 +40,8 @@ abstract class ScannedDependency {
         }
 
         @Override
-        ImmutableList<YangTextSchemaSource> sources() {
-            return ImmutableList.of(YangTextSchemaSource.forPath(file().toPath()));
+        ImmutableList<YangTextSource> sources() {
+            return ImmutableList.of(YangTextSource.forPath(file().toPath()));
         }
     }
 
@@ -54,14 +54,14 @@ abstract class ScannedDependency {
         }
 
         @Override
-        ImmutableList<YangTextSchemaSource> sources() throws IOException {
-            final var builder = ImmutableList.<YangTextSchemaSource>builderWithExpectedSize(entryNames.size());
+        ImmutableList<YangTextSource> sources() throws IOException {
+            final var builder = ImmutableList.<YangTextSource>builderWithExpectedSize(entryNames.size());
 
             try (ZipFile zip = new ZipFile(file())) {
                 for (String entryName : entryNames) {
                     final ZipEntry entry = requireNonNull(zip.getEntry(entryName));
 
-                    builder.add(YangTextSchemaSource.delegateForByteSource(
+                    builder.add(YangTextSource.delegateForByteSource(
                         entryName.substring(entryName.lastIndexOf('/') + 1),
                         // FIXME: can we reasonable make this a CharSource?
                         ByteSource.wrap(ByteStreams.toByteArray(zip.getInputStream(entry))),
@@ -130,7 +130,7 @@ abstract class ScannedDependency {
         return file;
     }
 
-    abstract ImmutableList<YangTextSchemaSource> sources() throws IOException;
+    abstract ImmutableList<YangTextSource> sources() throws IOException;
 
     @VisibleForTesting
     static List<File> getClassPath(final MavenProject project) {
index 4e3e9fd4d1cf518ab90bc9b48c0e7f0b45ae9ca7..90edf6d9823ca24083708619ec678b0b884b6d1c 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.yangtools.yang2sources.plugin;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.common.UnresolvedQName.Unqualified;
 import org.opendaylight.yangtools.yang.model.api.ModuleLike;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 
 final class Util {
     private Util() {
index ea4401d9c439017e35795197c72d85f73ae44e84..ee880da8a06a1450199284aa7a3ea553b5337f37 100644 (file)
@@ -12,12 +12,12 @@ import java.io.IOException;
 import java.util.Collection;
 import java.util.List;
 import org.apache.maven.project.MavenProject;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YangTextSource;
 
 @FunctionalInterface
 @VisibleForTesting
 interface YangProvider {
 
-    List<FileState> addYangsToMetaInf(MavenProject project,
-            Collection<YangTextSchemaSource> modelsInProject) throws IOException;
+    List<FileState> addYangsToMetaInf(MavenProject project, Collection<YangTextSource> modelsInProject)
+        throws IOException;
 }
index eae80170c5ffe158563db4fe016eb38cce333d0e..5cd7cb175109d6acd1d35579836705e269e5e865 100644 (file)
@@ -39,8 +39,8 @@ import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.plugin.generator.api.FileGeneratorException;
 import org.opendaylight.yangtools.plugin.generator.api.FileGeneratorFactory;
 import org.opendaylight.yangtools.yang.common.YangConstants;
-import org.opendaylight.yangtools.yang.model.repo.api.YangIRSchemaSource;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.ir.YangIRSchemaSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YangTextSource;
 import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
 import org.opendaylight.yangtools.yang.parser.api.YangParserException;
 import org.opendaylight.yangtools.yang.parser.api.YangParserFactory;
@@ -87,10 +87,10 @@ class YangToSourcesProcessor {
 
         final var stateListBuilder = ImmutableList.<FileState>builderWithExpectedSize(modelsInProject.size());
         for (var source : modelsInProject) {
-            final File file = new File(withMetaInf, source.getIdentifier().toYangFilename());
+            final File file = new File(withMetaInf, source.sourceId().toYangFilename());
             stateListBuilder.add(FileState.ofWrittenFile(file,
                 out -> source.asByteSource(StandardCharsets.UTF_8).copyTo(out)));
-            LOG.debug("Created file {} for {}", file, source.getIdentifier());
+            LOG.debug("Created file {} for {}", file, source.sourceId());
         }
 
         ProjectFileAccess.addResourceDir(project, generatedYangDir);
@@ -244,9 +244,9 @@ class YangToSourcesProcessor {
 
         final Stopwatch watch = Stopwatch.createStarted();
 
-        final List<Entry<YangTextSchemaSource, YangIRSchemaSource>> parsed = yangFilesInProject.parallelStream()
+        final List<Entry<YangTextSource, YangIRSchemaSource>> parsed = yangFilesInProject.parallelStream()
             .map(file -> {
-                final YangTextSchemaSource textSource = YangTextSchemaSource.forPath(file.toPath());
+                final var textSource = YangTextSource.forPath(file.toPath());
                 try {
                     return Map.entry(textSource, TextToIRTransformer.transformText(textSource));
                 } catch (YangSyntaxErrorException | IOException e) {
@@ -258,7 +258,7 @@ class YangToSourcesProcessor {
         LOG.info("{} Project model files found: {} in {}", LOG_PREFIX, yangFilesInProject.size(), watch);
 
         final var outputFiles = ImmutableList.<FileState>builder();
-        Collection<YangTextSchemaSource> modelsInProject = null;
+        Collection<YangTextSource> modelsInProject = null;
         for (var parserConfig : codeGenerators.stream().map(GeneratorTask::parserConfig).collect(Collectors.toSet())) {
             final var moduleReactor = createReactor(yangFilesInProject, parserConfig, dependencies, parsed);
             final var yangSw = Stopwatch.createStarted();
@@ -388,19 +388,19 @@ class YangToSourcesProcessor {
     @SuppressWarnings("checkstyle:illegalCatch")
     private @NonNull ProcessorModuleReactor createReactor(final List<File> yangFilesInProject,
             final YangParserConfiguration parserConfig, final Collection<ScannedDependency> dependencies,
-            final List<Entry<YangTextSchemaSource, YangIRSchemaSource>> parsed) throws MojoExecutionException {
+            final List<Entry<YangTextSource, YangIRSchemaSource>> parsed) throws MojoExecutionException {
 
         try {
-            final var sourcesInProject = new ArrayList<YangTextSchemaSource>(yangFilesInProject.size());
+            final var sourcesInProject = new ArrayList<YangTextSource>(yangFilesInProject.size());
             final var parser = parserFactory.createParser(parserConfig);
             for (var entry : parsed) {
                 final var textSource = entry.getKey();
                 final var astSource = entry.getValue();
                 parser.addSource(astSource);
 
-                if (!astSource.getIdentifier().equals(textSource.getIdentifier())) {
+                if (!astSource.sourceId().equals(textSource.sourceId())) {
                     // AST indicates a different source identifier, make sure we use that
-                    sourcesInProject.add(YangTextSchemaSource.delegateForCharSource(astSource.getIdentifier(),
+                    sourcesInProject.add(YangTextSource.delegateForCharSource(astSource.sourceId(),
                         textSource));
                 } else {
                     sourcesInProject.add(textSource);
index 7a7a28b830ef5f8f6bb15a87f74c42b54b8d9c95..dbbc43bd0a497c1c590e08f933012420c531cee5 100644 (file)
@@ -22,7 +22,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.junit.jupiter.MockitoExtension;
 import org.opendaylight.yangtools.plugin.generator.api.ModuleResourceResolver;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YangTextSource;
 
 @ExtendWith(MockitoExtension.class)
 class FilenameResolutionTest extends AbstractCodeGeneratorTest {
@@ -38,11 +38,11 @@ class FilenameResolutionTest extends AbstractCodeGeneratorTest {
 
                     final var module = Iterables.getOnlyElement(context.getModules());
                     assertEquals(Optional.of("/META-INF/yang/foo@2020-10-13.yang"),
-                        resolver.findModuleResourcePath(module, YangTextSchemaSource.class));
+                        resolver.findModuleResourcePath(module, YangTextSource.class));
 
                     final var submodule = Iterables.getOnlyElement(module.getSubmodules());
                     assertEquals(Optional.of("/META-INF/yang/foo-submodule@2020-10-12.yang"),
-                        resolver.findModuleResourcePath(submodule, YangTextSchemaSource.class));
+                        resolver.findModuleResourcePath(submodule, YangTextSource.class));
 
                     return ImmutableTable.of();
                 }).when(mock).generateFiles(any(), any(), any());
index 891f183e0b80000b572d228da06acb475f73382a..b74a6287c140b501148d4d289106f549763fa789 100644 (file)
@@ -33,7 +33,7 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.YangConstants;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.stmt.FeatureSet;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YangTextSource;
 import org.opendaylight.yangtools.yang.parser.api.YangParser;
 import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
 import org.opendaylight.yangtools.yang.parser.api.YangParserException;
@@ -102,10 +102,10 @@ final class SystemTestUtils {
         }
 
         for (File file : testFiles) {
-            parser.addSource(YangTextSchemaSource.forPath(file.toPath()));
+            parser.addSource(YangTextSource.forPath(file.toPath()));
         }
         for (File file : libFiles) {
-            parser.addLibSource(YangTextSchemaSource.forPath(file.toPath()));
+            parser.addLibSource(YangTextSource.forPath(file.toPath()));
         }
 
         return parser.buildEffectiveModel();
index 905e24a86c381236e023b7ee5df4efcafdaa66a5..3685aa327316b87ecac028345adb957bcafc5231 100644 (file)
         </dependency>
         <dependency>
             <groupId>org.opendaylight.yangtools</groupId>
-            <artifactId>yang-ir</artifactId>
+            <artifactId>yang-model-api</artifactId>
         </dependency>
         <dependency>
             <groupId>org.opendaylight.yangtools</groupId>
-            <artifactId>yang-model-api</artifactId>
+            <artifactId>yang-model-spi</artifactId>
         </dependency>
     </dependencies>
 </project>
index ce8de51621721684788a73db3c8f78715fb3acbe..436f2f463ca393c0fb02c4101cb68f27dd813710 100644 (file)
@@ -12,8 +12,8 @@ module org.opendaylight.yangtools.yang.repo.api {
     requires transitive com.google.common;
     requires transitive org.opendaylight.yangtools.concepts;
     requires transitive org.opendaylight.yangtools.yang.common;
-    requires transitive org.opendaylight.yangtools.yang.ir;
     requires transitive org.opendaylight.yangtools.yang.model.api;
+    requires transitive org.opendaylight.yangtools.yang.model.spi;
 
     requires org.opendaylight.yangtools.util;
     requires org.slf4j;
index 7292b6e1866aa7ab82ccc2e4e38d1ce1d6e5d294..ec52092a4c2c0ab56d54fd495f16cb121b77c274 100644 (file)
@@ -9,10 +9,11 @@ package org.opendaylight.yangtools.yang.model.repo.api;
 
 import com.google.common.annotations.Beta;
 import com.google.common.util.concurrent.ListenableFuture;
-import java.util.Arrays;
 import java.util.Collection;
+import java.util.List;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 
 /**
  * An asynchronous factory for building {@link EffectiveModelContext} instances based on a specification of what
@@ -32,6 +33,6 @@ public interface EffectiveModelContextFactory {
 
     default @NonNull ListenableFuture<EffectiveModelContext> createEffectiveModelContext(
             final SourceIdentifier... requiredSources) {
-        return createEffectiveModelContext(Arrays.asList(requiredSources));
+        return createEffectiveModelContext(List.of(requiredSources));
     }
 }
index cc9cae35529fca8462187f8926dda7c684506ce7..b7d4b3fcdbe9e0dd6693711fb478c77be0cfd82c 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.yangtools.yang.model.repo.api;
 import static java.util.Objects.requireNonNull;
 
 import com.google.common.annotations.Beta;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 
 /**
  * Exception thrown when a the specified schema source is not available.
index bb76e885e9f0ae0515cc5f59a78a6c77a0e463b3..9250a4344023fd4b011ba8e5bfa29a29b151668a 100644 (file)
@@ -11,6 +11,8 @@ import com.google.common.annotations.Beta;
 import com.google.common.util.concurrent.ListenableFuture;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.SourceRepresentation;
 
 /**
  * Interface exposed by repository implementations. A schema repository is a logically centralized place for model
@@ -36,6 +38,6 @@ public interface SchemaRepository {
         return createEffectiveModelContextFactory(SchemaContextFactoryConfiguration.getDefault());
     }
 
-    <T extends SchemaSourceRepresentation> @NonNull ListenableFuture<T> getSchemaSource(@NonNull SourceIdentifier id,
+    <T extends SourceRepresentation> @NonNull ListenableFuture<T> getSchemaSource(@NonNull SourceIdentifier id,
             @NonNull Class<T> represetation);
 }
index b6128bf8cb16e24147aa203f6b7ccb9ad153f1e2..b2862b6ac7287ea9cfc49f80615d8ba046dcf313 100644 (file)
@@ -16,6 +16,7 @@ import com.google.common.collect.Multimap;
 import java.util.Collection;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 
 /**
  * Exception thrown when a Schema Source fails to resolve.
@@ -69,7 +70,7 @@ public class SchemaResolutionException extends SchemaSourceException {
      * @return YANG schema source identifier
      */
     public final SourceIdentifier getFailedSource() {
-        return this.failedSource;
+        return failedSource;
     }
 
     /**
index cccfc92733e78b5c52536d8224002f0e17a178b2..e9ca81828cbe473f45c9ef9cb10b1e3a60aac0ce 100644 (file)
@@ -13,6 +13,7 @@ import com.google.common.util.concurrent.FluentFuture;
 import com.google.common.util.concurrent.ListenableFuture;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.util.concurrent.FluentFutures;
+import org.opendaylight.yangtools.yang.model.api.source.SourceRepresentation;
 
 /**
  * A filter of schema sources. This is used to restrict which sources representation instances are allowed
@@ -25,16 +26,16 @@ public interface SchemaSourceFilter {
      * A {@link SchemaSourceFilter} which accepts any schema source it is presented with.
      */
     @NonNull SchemaSourceFilter ALWAYS_ACCEPT = new SchemaSourceFilter() {
-        private final ImmutableList<Class<? extends SchemaSourceRepresentation>> representations =
-                ImmutableList.of(SchemaSourceRepresentation.class);
+        private final ImmutableList<Class<? extends SourceRepresentation>> representations =
+                ImmutableList.of(SourceRepresentation.class);
 
         @Override
-        public ImmutableList<Class<? extends SchemaSourceRepresentation>> supportedRepresentations() {
+        public ImmutableList<Class<? extends SourceRepresentation>> supportedRepresentations() {
             return representations;
         }
 
         @Override
-        public FluentFuture<Boolean> apply(final SchemaSourceRepresentation schemaSource) {
+        public FluentFuture<Boolean> apply(final SourceRepresentation schemaSource) {
             return FluentFutures.immediateTrueFluentFuture();
         }
     };
@@ -45,7 +46,7 @@ public interface SchemaSourceFilter {
      *
      * @return Set of supported representations.
      */
-    Iterable<Class<? extends SchemaSourceRepresentation>> supportedRepresentations();
+    Iterable<Class<? extends SourceRepresentation>> supportedRepresentations();
 
     /**
      * Check if a particular schema source is acceptable to the filter. The process
@@ -57,5 +58,5 @@ public interface SchemaSourceFilter {
      * @return Promise of a filtering decision. The result should be {@link Boolean#TRUE}
      *         if the source is acceptable.
      */
-    ListenableFuture<Boolean> apply(SchemaSourceRepresentation schemaSource);
+    ListenableFuture<Boolean> apply(SourceRepresentation schemaSource);
 }
index 5e5a8a653c4941195e3bdfd0a1dde81b36760534..fe1509fea81f5c45ccd4a1b607b759dcef477988 100644 (file)
@@ -33,28 +33,25 @@ import java.util.TreeMap;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import org.opendaylight.yangtools.yang.common.Revision;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.SourceRepresentation;
 import org.opendaylight.yangtools.yang.model.repo.api.MissingSchemaSourceException;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
 import org.opendaylight.yangtools.yang.model.repo.spi.AbstractSchemaSourceCache;
 import org.opendaylight.yangtools.yang.model.repo.spi.PotentialSchemaSource.Costs;
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistry;
+import org.opendaylight.yangtools.yang.model.spi.source.YangTextSource;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
  * Cache implementation that stores schemas in form of files under provided folder.
  */
-public final class FilesystemSchemaSourceCache<T extends SchemaSourceRepresentation>
-        extends AbstractSchemaSourceCache<T> {
-
+public final class FilesystemSchemaSourceCache<T extends SourceRepresentation> extends AbstractSchemaSourceCache<T> {
     private static final Logger LOG = LoggerFactory.getLogger(FilesystemSchemaSourceCache.class);
 
     // Init storage adapters
-    private static final Map<Class<? extends SchemaSourceRepresentation>,
-            StorageAdapter<? extends SchemaSourceRepresentation>> STORAGE_ADAPTERS = Collections.singletonMap(
-                    YangTextSchemaSource.class, new YangTextSchemaStorageAdapter());
+    private static final Map<Class<? extends SourceRepresentation>, StorageAdapter<? extends SourceRepresentation>>
+        STORAGE_ADAPTERS = Collections.singletonMap(YangTextSource.class, new YangTextStorageAdapter());
 
     private static final Pattern CACHED_FILE_PATTERN =
             Pattern.compile("(?<moduleName>[^@]+)" + "(@(?<revision>" + Revision.STRING_FORMAT_PATTERN + "))?");
@@ -62,8 +59,8 @@ public final class FilesystemSchemaSourceCache<T extends SchemaSourceRepresentat
     private final Class<T> representation;
     private final File storageDirectory;
 
-    public FilesystemSchemaSourceCache(
-            final SchemaSourceRegistry consumer, final Class<T> representation, final File storageDirectory) {
+    public FilesystemSchemaSourceCache(final SchemaSourceRegistry consumer, final Class<T> representation,
+            final File storageDirectory) {
         super(consumer, representation, Costs.LOCAL_IO);
         this.representation = representation;
         this.storageDirectory = requireNonNull(storageDirectory);
@@ -78,16 +75,16 @@ public final class FilesystemSchemaSourceCache<T extends SchemaSourceRepresentat
         init();
     }
 
-    private static void checkSupportedRepresentation(final Class<? extends SchemaSourceRepresentation> representation) {
-        for (final Class<? extends SchemaSourceRepresentation> supportedRepresentation : STORAGE_ADAPTERS.keySet()) {
+    private static void checkSupportedRepresentation(final Class<? extends SourceRepresentation> representation) {
+        for (final var supportedRepresentation : STORAGE_ADAPTERS.keySet()) {
             if (supportedRepresentation.isAssignableFrom(representation)) {
                 return;
             }
         }
 
         throw new IllegalArgumentException(String.format(
-                   "This cache does not support representation: %s, supported representations are: %s",
-                   representation, STORAGE_ADAPTERS.keySet()));
+            "This cache does not support representation: %s, supported representations are: %s",
+            representation, STORAGE_ADAPTERS.keySet()));
     }
 
     /**
@@ -111,8 +108,7 @@ public final class FilesystemSchemaSourceCache<T extends SchemaSourceRepresentat
         final File file = sourceIdToFile(sourceIdentifier, storageDirectory);
         if (file.exists() && file.canRead()) {
             LOG.trace("Source {} found in cache as {}", sourceIdentifier, file);
-            final SchemaSourceRepresentation restored = STORAGE_ADAPTERS.get(representation).restore(sourceIdentifier,
-                    file);
+            final var restored = STORAGE_ADAPTERS.get(representation).restore(sourceIdentifier, file);
             return immediateFluentFuture(representation.cast(restored));
         }
 
@@ -122,20 +118,20 @@ public final class FilesystemSchemaSourceCache<T extends SchemaSourceRepresentat
 
     @Override
     protected synchronized void offer(final T source) {
-        LOG.trace("Source {} offered to cache", source.getIdentifier());
+        LOG.trace("Source {} offered to cache", source.sourceId());
         final File file = sourceIdToFile(source);
         if (file.exists()) {
-            LOG.debug("Source {} already in cache as {}", source.getIdentifier(), file);
+            LOG.debug("Source {} already in cache as {}", source.sourceId(), file);
             return;
         }
 
         storeSource(file, source);
-        register(source.getIdentifier());
-        LOG.trace("Source {} stored in cache as {}", source.getIdentifier(), file);
+        register(source.sourceId());
+        LOG.trace("Source {} stored in cache as {}", source.sourceId(), file);
     }
 
     private File sourceIdToFile(final T source) {
-        return sourceIdToFile(source.getIdentifier(), storageDirectory);
+        return sourceIdToFile(source.sourceId(), storageDirectory);
     }
 
     static File sourceIdToFile(final SourceIdentifier identifier, final File storageDirectory) {
@@ -198,15 +194,14 @@ public final class FilesystemSchemaSourceCache<T extends SchemaSourceRepresentat
         STORAGE_ADAPTERS.get(representation).store(file, schemaRepresentation);
     }
 
-    private abstract static class StorageAdapter<T extends SchemaSourceRepresentation> {
-
+    private abstract static class StorageAdapter<T extends SourceRepresentation> {
         private final Class<T> supportedType;
 
         protected StorageAdapter(final Class<T> supportedType) {
             this.supportedType = supportedType;
         }
 
-        void store(final File file, final SchemaSourceRepresentation schemaSourceRepresentation) {
+        void store(final File file, final SourceRepresentation schemaSourceRepresentation) {
             checkArgument(supportedType.isAssignableFrom(schemaSourceRepresentation.getClass()),
                     "Cannot store schema source %s, this adapter only supports %s", schemaSourceRepresentation,
                     supportedType);
@@ -227,25 +222,23 @@ public final class FilesystemSchemaSourceCache<T extends SchemaSourceRepresentat
         abstract T restoreAsType(SourceIdentifier sourceIdentifier, File cachedSource);
     }
 
-    private static final class YangTextSchemaStorageAdapter extends StorageAdapter<YangTextSchemaSource> {
-
-        protected YangTextSchemaStorageAdapter() {
-            super(YangTextSchemaSource.class);
+    private static final class YangTextStorageAdapter extends StorageAdapter<YangTextSource> {
+        protected YangTextStorageAdapter() {
+            super(YangTextSource.class);
         }
 
         @Override
-        protected void storeAsType(final File file, final YangTextSchemaSource cast) {
+        protected void storeAsType(final File file, final YangTextSource cast) {
             try (var castStream = cast.asByteSource(StandardCharsets.UTF_8).openStream()) {
                 Files.copy(castStream, file.toPath(), StandardCopyOption.REPLACE_EXISTING);
             } catch (final IOException e) {
-                throw new IllegalStateException("Cannot store schema source " + cast.getIdentifier() + " to " + file,
-                        e);
+                throw new IllegalStateException("Cannot store schema source " + cast.sourceId() + " to " + file, e);
             }
         }
 
         @Override
-        YangTextSchemaSource restoreAsType(final SourceIdentifier sourceIdentifier, final File cachedSource) {
-            return YangTextSchemaSource.forPath(cachedSource.toPath(), sourceIdentifier);
+        YangTextSource restoreAsType(final SourceIdentifier sourceIdentifier, final File cachedSource) {
+            return YangTextSource.forPath(cachedSource.toPath(), sourceIdentifier);
         }
     }
 
index f479026ef48ddd5fd92a7db57a0f35ede5e16d13..94fc3448f6d87d04983c3ef5f4d68363adfdff20 100644 (file)
@@ -13,7 +13,6 @@ import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.opendaylight.yangtools.util.concurrent.FluentFutures.immediateFluentFuture;
 
 import com.google.common.base.MoreObjects.ToStringHelper;
 import com.google.common.collect.Lists;
@@ -28,16 +27,16 @@ import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
-import java.util.Optional;
 import java.util.concurrent.ExecutionException;
 import org.junit.jupiter.api.Test;
+import org.opendaylight.yangtools.util.concurrent.FluentFutures;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.SourceRepresentation;
 import org.opendaylight.yangtools.yang.model.repo.api.MissingSchemaSourceException;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
 import org.opendaylight.yangtools.yang.model.repo.spi.PotentialSchemaSource;
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceListener;
+import org.opendaylight.yangtools.yang.model.spi.source.YangTextSource;
 import org.opendaylight.yangtools.yang.parser.repo.SharedSchemaRepository;
 import org.opendaylight.yangtools.yang.parser.rfc7950.repo.TextToIRTransformer;
 
@@ -50,7 +49,7 @@ public class FilesystemSchemaSourceCacheIntegrationTest {
             List<PotentialSchemaSource<?>> registeredSources = new ArrayList<>();
 
             @Override
-            public void schemaSourceEncountered(final SchemaSourceRepresentation source) {
+            public void schemaSourceEncountered(final SourceRepresentation source) {
             }
 
             @Override
@@ -82,8 +81,8 @@ public class FilesystemSchemaSourceCacheIntegrationTest {
         final File test4 = new File(tempDir, "module@2010-12-12.yang");
         Files.asCharSink(test4, StandardCharsets.UTF_8).write("content-module-2010");
 
-        final FilesystemSchemaSourceCache<YangTextSchemaSource> cache = new FilesystemSchemaSourceCache<>(
-                sharedSchemaRepository, YangTextSchemaSource.class, tempDir);
+        final FilesystemSchemaSourceCache<YangTextSource> cache = new FilesystemSchemaSourceCache<>(
+                sharedSchemaRepository, YangTextSource.class, tempDir);
         sharedSchemaRepository.registerSchemaSourceListener(cache);
 
         assertEquals(4, listener.registeredSources.size());
@@ -102,14 +101,14 @@ public class FilesystemSchemaSourceCacheIntegrationTest {
 
         final File storageDir = Files.createTempDir();
 
-        final FilesystemSchemaSourceCache<YangTextSchemaSource> cache = new FilesystemSchemaSourceCache<>(
-                sharedSchemaRepository, YangTextSchemaSource.class, storageDir);
+        final FilesystemSchemaSourceCache<YangTextSource> cache = new FilesystemSchemaSourceCache<>(
+                sharedSchemaRepository, YangTextSource.class, storageDir);
         sharedSchemaRepository.registerSchemaSourceListener(cache);
 
         final SourceIdentifier runningId = new SourceIdentifier("running", "2012-12-12");
 
-        sharedSchemaRepository.registerSchemaSource(sourceIdentifier -> immediateFluentFuture(
-            new YangTextSchemaSource(runningId) {
+        sharedSchemaRepository.registerSchemaSource(sourceIdentifier -> FluentFutures.immediateFluentFuture(
+            new YangTextSource(runningId) {
                 @Override
                 protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
                     return toStringHelper;
@@ -121,10 +120,10 @@ public class FilesystemSchemaSourceCacheIntegrationTest {
                 }
 
                 @Override
-                public Optional<String> getSymbolicName() {
-                    return Optional.empty();
+                public String symbolicName() {
+                    return null;
                 }
-            }), PotentialSchemaSource.create(runningId, YangTextSchemaSource.class,
+            }), PotentialSchemaSource.create(runningId, YangTextSource.class,
                 PotentialSchemaSource.Costs.REMOTE_IO.getValue()));
 
         final TextToIRTransformer transformer = TextToIRTransformer.create(sharedSchemaRepository,
index e6dd9515dae420ea4884118e5d57dc9831c872cf..5c99d47965fb2b7468fa3f6c852ee847820b15ff 100644 (file)
@@ -32,7 +32,6 @@ import java.nio.file.Files;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
-import java.util.Optional;
 import java.util.concurrent.ExecutionException;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -42,11 +41,11 @@ import org.mockito.junit.jupiter.MockitoExtension;
 import org.mockito.junit.jupiter.MockitoSettings;
 import org.mockito.quality.Strictness;
 import org.opendaylight.yangtools.concepts.Registration;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.spi.PotentialSchemaSource;
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider;
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistry;
+import org.opendaylight.yangtools.yang.model.spi.source.YangTextSource;
 
 @ExtendWith(MockitoExtension.class)
 @MockitoSettings(strictness = Strictness.LENIENT)
@@ -67,15 +66,15 @@ public class FilesystemSchemaSourceCacheTest {
 
     @Test
     public void testCacheAndRestore() throws Exception {
-        final FilesystemSchemaSourceCache<YangTextSchemaSource> cache
-                = new FilesystemSchemaSourceCache<>(registry, YangTextSchemaSource.class, storageDir);
+        final FilesystemSchemaSourceCache<YangTextSource> cache = new FilesystemSchemaSourceCache<>(registry,
+            YangTextSource.class, storageDir);
 
         final String content = "content1";
-        final YangTextSchemaSource source = new TestingYangSource("test", "2012-12-12", content);
+        final YangTextSource source = new TestingYangSource("test", "2012-12-12", content);
         cache.offer(source);
 
         final String content2 = "content2";
-        final YangTextSchemaSource source2 = new TestingYangSource("test2", null, content);
+        final YangTextSource source2 = new TestingYangSource("test2", null, content);
         cache.offer(source2);
 
         final List<File> storedFiles = getFilesFromCache();
@@ -93,7 +92,7 @@ public class FilesystemSchemaSourceCacheTest {
             any(PotentialSchemaSource.class));
 
         // Create new cache from stored sources
-        new FilesystemSchemaSourceCache<>(registry, YangTextSchemaSource.class, storageDir);
+        new FilesystemSchemaSourceCache<>(registry, YangTextSource.class, storageDir);
 
         verify(registry, times(4)).registerSchemaSource(any(SchemaSourceProvider.class),
             any(PotentialSchemaSource.class));
@@ -112,11 +111,11 @@ public class FilesystemSchemaSourceCacheTest {
 
     @Test
     public void testCacheDuplicate() throws Exception {
-        final FilesystemSchemaSourceCache<YangTextSchemaSource> cache
-                = new FilesystemSchemaSourceCache<>(registry, YangTextSchemaSource.class, storageDir);
+        final FilesystemSchemaSourceCache<YangTextSource> cache = new FilesystemSchemaSourceCache<>(registry,
+            YangTextSource.class, storageDir);
 
         final String content = "content1";
-        final YangTextSchemaSource source = new TestingYangSource("test", null, content);
+        final YangTextSource source = new TestingYangSource("test", null, content);
         // Double offer
         cache.offer(source);
         cache.offer(source);
@@ -128,13 +127,13 @@ public class FilesystemSchemaSourceCacheTest {
 
     @Test
     public void testCacheMultipleRevisions() throws Exception {
-        final FilesystemSchemaSourceCache<YangTextSchemaSource> cache
-                = new FilesystemSchemaSourceCache<>(registry, YangTextSchemaSource.class, storageDir);
+        final FilesystemSchemaSourceCache<YangTextSource> cache = new FilesystemSchemaSourceCache<>(registry,
+            YangTextSource.class, storageDir);
 
         final String content = "content1";
-        final YangTextSchemaSource source = new TestingYangSource("test", null, content);
-        final YangTextSchemaSource source2 = new TestingYangSource("test", "2012-12-12", content);
-        final YangTextSchemaSource source3 = new TestingYangSource("test", "2013-12-12", content);
+        final YangTextSource source = new TestingYangSource("test", null, content);
+        final YangTextSource source2 = new TestingYangSource("test", "2012-12-12", content);
+        final YangTextSource source3 = new TestingYangSource("test", "2013-12-12", content);
         // Double offer
         cache.offer(source);
         cache.offer(source2);
@@ -154,8 +153,8 @@ public class FilesystemSchemaSourceCacheTest {
     public void sourceIdToFileEmptyRevWithEmptyDir() {
         final SourceIdentifier sourceIdentifier = new SourceIdentifier("test");
         final File sourceIdToFile = FilesystemSchemaSourceCache.sourceIdToFile(sourceIdentifier, storageDir);
-        final FilesystemSchemaSourceCache<YangTextSchemaSource> cache = new FilesystemSchemaSourceCache<>(registry,
-                YangTextSchemaSource.class, sourceIdToFile);
+        final FilesystemSchemaSourceCache<YangTextSource> cache = new FilesystemSchemaSourceCache<>(registry,
+                YangTextSource.class, sourceIdToFile);
         assertNotNull(cache);
         final List<File> storedFiles = Arrays.asList(sourceIdToFile.listFiles());
         assertEquals(0, storedFiles.size());
@@ -163,10 +162,10 @@ public class FilesystemSchemaSourceCacheTest {
 
     @Test
     public void sourceIdToFileEmptyRevWithOneItemInDir() {
-        final FilesystemSchemaSourceCache<YangTextSchemaSource> cache = new FilesystemSchemaSourceCache<>(registry,
-                YangTextSchemaSource.class, storageDir);
+        final FilesystemSchemaSourceCache<YangTextSource> cache = new FilesystemSchemaSourceCache<>(registry,
+                YangTextSource.class, storageDir);
         final String content = "content1";
-        final YangTextSchemaSource source = new TestingYangSource("test", "2013-12-12", content);
+        final YangTextSource source = new TestingYangSource("test", "2013-12-12", content);
         cache.offer(source);
 
         final SourceIdentifier sourceIdentifier = new SourceIdentifier("test");
@@ -179,11 +178,11 @@ public class FilesystemSchemaSourceCacheTest {
 
     @Test
     public void sourceIdToFileEmptyRevWithMoreItemsInDir() {
-        final FilesystemSchemaSourceCache<YangTextSchemaSource> cache = new FilesystemSchemaSourceCache<>(registry,
-                YangTextSchemaSource.class, storageDir);
+        final FilesystemSchemaSourceCache<YangTextSource> cache = new FilesystemSchemaSourceCache<>(registry,
+                YangTextSource.class, storageDir);
         final String content = "content1";
-        final YangTextSchemaSource source = new TestingYangSource("test", "2012-12-12", content);
-        final YangTextSchemaSource source2 = new TestingYangSource("test", "2013-12-12", content);
+        final YangTextSource source = new TestingYangSource("test", "2012-12-12", content);
+        final YangTextSource source2 = new TestingYangSource("test", "2013-12-12", content);
         cache.offer(source);
         cache.offer(source2);
 
@@ -196,28 +195,28 @@ public class FilesystemSchemaSourceCacheTest {
 
     @Test
     public void test() throws Exception {
-        final FilesystemSchemaSourceCache<YangTextSchemaSource> cache = new FilesystemSchemaSourceCache<>(registry,
-                YangTextSchemaSource.class, storageDir);
+        final FilesystemSchemaSourceCache<YangTextSource> cache = new FilesystemSchemaSourceCache<>(registry,
+                YangTextSource.class, storageDir);
         final String content = "content1";
-        final YangTextSchemaSource source = new TestingYangSource("test", "2013-12-12", content);
+        final YangTextSource source = new TestingYangSource("test", "2013-12-12", content);
         cache.offer(source);
         final SourceIdentifier sourceIdentifier = new SourceIdentifier("test", "2013-12-12");
-        final ListenableFuture<? extends YangTextSchemaSource> checked = cache.getSource(sourceIdentifier);
+        final ListenableFuture<? extends YangTextSource> checked = cache.getSource(sourceIdentifier);
         assertNotNull(checked);
         assertTrue(checked.isDone());
-        final YangTextSchemaSource checkedGet = checked.get();
-        assertEquals(sourceIdentifier, checkedGet.getIdentifier());
+        final YangTextSource checkedGet = checked.get();
+        assertEquals(sourceIdentifier, checkedGet.sourceId());
     }
 
     @Test
     public void test1() throws Exception {
-        final FilesystemSchemaSourceCache<YangTextSchemaSource> cache = new FilesystemSchemaSourceCache<>(registry,
-                YangTextSchemaSource.class, storageDir);
+        final FilesystemSchemaSourceCache<YangTextSource> cache = new FilesystemSchemaSourceCache<>(registry,
+                YangTextSource.class, storageDir);
         final String content = "content1";
-        final YangTextSchemaSource source = new TestingYangSource("test", "2013-12-12", content);
+        final YangTextSource source = new TestingYangSource("test", "2013-12-12", content);
         cache.offer(source);
         final SourceIdentifier sourceIdentifier = new SourceIdentifier("test1", "2012-12-12");
-        final ListenableFuture<? extends YangTextSchemaSource> checked = cache.getSource(sourceIdentifier);
+        final ListenableFuture<? extends YangTextSource> checked = cache.getSource(sourceIdentifier);
         assertNotNull(checked);
         assertThrows(ExecutionException.class, () -> checked.get());
     }
@@ -226,7 +225,7 @@ public class FilesystemSchemaSourceCacheTest {
         return Arrays.asList(storageDir.listFiles());
     }
 
-    private static class TestingYangSource extends YangTextSchemaSource {
+    private static class TestingYangSource extends YangTextSource {
         private final String content;
 
         TestingYangSource(final String name, final String revision, final String content) {
@@ -245,8 +244,8 @@ public class FilesystemSchemaSourceCacheTest {
         }
 
         @Override
-        public Optional<String> getSymbolicName() {
-            return Optional.empty();
+        public String symbolicName() {
+            return null;
         }
     }
 }
index 9d95628b50ab17f758f987e90c41cf66acf41291..49012e4260b3668b05ed110036d25044d9d95cb6 100644 (file)
@@ -29,10 +29,10 @@ import org.checkerframework.checker.lock.qual.GuardedBy;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
 import org.opendaylight.yangtools.concepts.Registration;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.SourceRepresentation;
 import org.opendaylight.yangtools.yang.model.repo.api.MissingSchemaSourceException;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -49,7 +49,7 @@ public abstract class AbstractSchemaRepository implements SchemaRepository, Sche
      * a specific representation of a source.
      */
     @GuardedBy("this")
-    private final Map<SourceIdentifier, ListMultimap<Class<? extends SchemaSourceRepresentation>,
+    private final Map<SourceIdentifier, ListMultimap<Class<? extends SourceRepresentation>,
             SchemaSourceRegistration>> sources = new HashMap<>();
 
     /*
@@ -58,23 +58,23 @@ public abstract class AbstractSchemaRepository implements SchemaRepository, Sche
     @GuardedBy("this")
     private final List<SchemaListenerRegistration> listeners = new ArrayList<>();
 
-    private static <T extends SchemaSourceRepresentation> ListenableFuture<T> fetchSource(final SourceIdentifier id,
-            final Iterator<SchemaSourceRegistration> it) {
+    private static <T extends SourceRepresentation> ListenableFuture<T> fetchSource(
+            final SourceIdentifier sourceId, final Iterator<SchemaSourceRegistration> it) {
         final var reg = it.next();
         @SuppressWarnings("unchecked")
         final var provider = (SchemaSourceProvider<T>) reg.provider();
 
-        return Futures.catchingAsync(provider.getSource(id), Throwable.class, input -> {
+        return Futures.catchingAsync(provider.getSource(sourceId), Throwable.class, input -> {
             LOG.debug("Failed to acquire source from {}", reg, input);
             if (it.hasNext()) {
-                return fetchSource(id, it);
+                return fetchSource(sourceId, it);
             }
-            throw new MissingSchemaSourceException("All available providers exhausted", id, input);
+            throw new MissingSchemaSourceException("All available providers exhausted", sourceId, input);
         }, MoreExecutors.directExecutor());
     }
 
     @Override
-    public <T extends SchemaSourceRepresentation> ListenableFuture<T> getSchemaSource(final SourceIdentifier id,
+    public <T extends SourceRepresentation> ListenableFuture<T> getSchemaSource(final SourceIdentifier id,
             final Class<T> representation) {
         final ArrayList<SchemaSourceRegistration> sortedSchemaSourceRegistrations;
 
@@ -94,7 +94,7 @@ public abstract class AbstractSchemaRepository implements SchemaRepository, Sche
         final var regs = sortedSchemaSourceRegistrations.iterator();
         if (!regs.hasNext()) {
             return immediateFailedFluentFuture(new MissingSchemaSourceException(
-                        "No providers for source " + id + " representation " + representation + " available", id));
+                "No providers for source " + id + " representation " + representation + " available", id));
         }
 
         final ListenableFuture<T> fetchSourceFuture = fetchSource(id, regs);
@@ -145,7 +145,7 @@ public abstract class AbstractSchemaRepository implements SchemaRepository, Sche
     }
 
     @Override
-    public <T extends SchemaSourceRepresentation> Registration registerSchemaSource(
+    public <T extends SourceRepresentation> Registration registerSchemaSource(
             final SchemaSourceProvider<? super T> provider, final PotentialSchemaSource<T> source) {
         final var ret = new SchemaSourceRegistration(source.cachedReference(), provider);
         addSource(ret);
index 0d6e1776b66b6d3bb91cf49219876cabf600cd0e..bbe75cde3d71050496af623eb9fc01e37f9123b0 100644 (file)
@@ -10,18 +10,18 @@ package org.opendaylight.yangtools.yang.model.repo.spi;
 import static java.util.Objects.requireNonNull;
 
 import org.opendaylight.yangtools.concepts.Registration;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.SourceRepresentation;
 import org.opendaylight.yangtools.yang.model.repo.spi.PotentialSchemaSource.Costs;
 
 /**
  * Abstract base class for cache-type SchemaSourceListeners. It needs to be registered with a
  * {@link SchemaSourceRegistry}, where it gets notifications from. It performs filtering and
- * {@link #offer(SchemaSourceRepresentation)}s conforming sources to the subclass.
+ * {@link #offer(SourceRepresentation)}s conforming sources to the subclass.
  *
  * @param <T> Cached schema source type.
  */
-public abstract class AbstractSchemaSourceCache<T extends SchemaSourceRepresentation>
+public abstract class AbstractSchemaSourceCache<T extends SourceRepresentation>
         implements SchemaSourceListener, SchemaSourceProvider<T> {
     private final SchemaSourceRegistry consumer;
     private final Class<T> representation;
@@ -48,17 +48,17 @@ public abstract class AbstractSchemaSourceCache<T extends SchemaSourceRepresenta
      * have cached a schema source representation, or when they have determined they have a schema source is available
      * -- like when a persistent cache reads its cache index.
      *
-     * @param sourceIdentifier Source identifier
+     * @param sourceId Source identifier
      * @return schema source registration, which the subclass needs to {@link Registration#close()} once it expunges the
      *         source from the cache.
      */
-    protected final Registration register(final SourceIdentifier sourceIdentifier) {
-        return consumer.registerSchemaSource(this, PotentialSchemaSource.create(sourceIdentifier, representation,
+    protected final Registration register(final SourceIdentifier sourceId) {
+        return consumer.registerSchemaSource(this, PotentialSchemaSource.create(sourceId, representation,
             cost.getValue()));
     }
 
     @Override
-    public void schemaSourceEncountered(final SchemaSourceRepresentation source) {
+    public void schemaSourceEncountered(final SourceRepresentation source) {
         if (representation.isAssignableFrom(source.getType())) {
             offer(representation.cast(source));
         }
index 65f038e090deedc53ef6cb11990eb0bb86b2c81d..0b9d1a395c3c1e871b0ea0f89c772c43c9edbbe0 100644 (file)
@@ -20,19 +20,19 @@ import java.util.List;
 import java.util.concurrent.TimeUnit;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.util.concurrent.FluentFutures;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.SourceRepresentation;
 import org.opendaylight.yangtools.yang.model.repo.api.MissingSchemaSourceException;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 
 /**
  * A simple {@link AbstractSchemaSourceCache} based on {@link Cache Guava Cache}.
  *
- * @param <T> {@link SchemaSourceRepresentation} type stored in this cache
+ * @param <T> {@link SourceRepresentation} type stored in this cache
  * @deprecated This class has a rather complicated and ugly design. Use {@link SoftSchemaSourceCache} instead.
  */
 @Beta
 @Deprecated(since = "7.0.13", forRemoval = true)
-public final class GuavaSchemaSourceCache<T extends SchemaSourceRepresentation> extends AbstractSchemaSourceCache<T>
+public final class GuavaSchemaSourceCache<T extends SourceRepresentation> extends AbstractSchemaSourceCache<T>
         implements AutoCloseable {
     // FIXME: 7.0.0: use a java.util.Cleaner?
     private final List<FinalizablePhantomReference<T>> regs = Collections.synchronizedList(new ArrayList<>());
@@ -45,35 +45,35 @@ public final class GuavaSchemaSourceCache<T extends SchemaSourceRepresentation>
         cache = cacheBuilder.build();
     }
 
-    public static <R extends SchemaSourceRepresentation> @NonNull GuavaSchemaSourceCache<R> createSoftCache(
+    public static <R extends SourceRepresentation> @NonNull GuavaSchemaSourceCache<R> createSoftCache(
             final SchemaSourceRegistry consumer, final Class<R> representation) {
         return new GuavaSchemaSourceCache<>(consumer, representation, CacheBuilder.newBuilder().softValues());
     }
 
-    public static <R extends SchemaSourceRepresentation> @NonNull GuavaSchemaSourceCache<R> createSoftCache(
+    public static <R extends SourceRepresentation> @NonNull GuavaSchemaSourceCache<R> createSoftCache(
             final SchemaSourceRegistry consumer, final Class<R> representation, final long lifetime,
             final TimeUnit units) {
         return new GuavaSchemaSourceCache<>(consumer, representation, CacheBuilder.newBuilder().softValues()
             .expireAfterAccess(lifetime, units));
     }
 
-    public static <R extends SchemaSourceRepresentation> @NonNull GuavaSchemaSourceCache<R> createSoftCache(
+    public static <R extends SourceRepresentation> @NonNull GuavaSchemaSourceCache<R> createSoftCache(
             final SchemaSourceRegistry consumer, final Class<R> representation, final Duration duration) {
         return new GuavaSchemaSourceCache<>(consumer, representation, CacheBuilder.newBuilder().softValues()
             .expireAfterAccess(duration));
     }
 
     @Override
-    public FluentFuture<? extends T> getSource(final SourceIdentifier sourceIdentifier) {
-        final T present = cache.getIfPresent(sourceIdentifier);
+    public FluentFuture<? extends T> getSource(final SourceIdentifier sourceId) {
+        final T present = cache.getIfPresent(sourceId);
         return present != null ? FluentFutures.immediateFluentFuture(present)
-                : FluentFutures.immediateFailedFluentFuture(new MissingSchemaSourceException("Source not found",
-                    sourceIdentifier));
+                : FluentFutures.immediateFailedFluentFuture(
+                    new MissingSchemaSourceException("Source not found", sourceId));
     }
 
     @Override
     protected void offer(final T source) {
-        final var srcId = source.getIdentifier();
+        final var srcId = source.sourceId();
         if (cache.getIfPresent(srcId) != null) {
             // We already have this source, do not track it
             return;
index c9663386583bb259d96ddba2ac4d39b0c84bae6b..a42c904b383c171f43cd76aeb75279c10a30f739 100644 (file)
@@ -14,16 +14,15 @@ import com.google.common.annotations.Beta;
 import com.google.common.collect.Interner;
 import com.google.common.collect.Interners;
 import java.util.Objects;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.SourceRepresentation;
 
 /**
- * A potential schema source. Instances of this class track the various
- * representations of a schema source and the cost attached to obtaining
- * the source from them.
+ * A potential schema source. Instances of this class track the various representations of a schema source and the cost
+ * attached to obtaining the source from them.
  */
 @Beta
-public final class PotentialSchemaSource<T extends SchemaSourceRepresentation> {
+public final class PotentialSchemaSource<T extends SourceRepresentation> {
     /**
      * Each registered source has a cost associated with it. Since a particular
      * representation can be acquired by various means, here are general constants
@@ -79,14 +78,14 @@ public final class PotentialSchemaSource<T extends SchemaSourceRepresentation> {
         this.cost = cost;
     }
 
-    public static <T extends SchemaSourceRepresentation> PotentialSchemaSource<T> create(
-            final SourceIdentifier sourceIdentifier, final Class<? extends T> representation, final int cost) {
-        return new PotentialSchemaSource<>(sourceIdentifier, representation, cost);
+    public static <T extends SourceRepresentation> PotentialSchemaSource<T> create(
+            final SourceIdentifier sourceId, final Class<? extends T> representation, final int cost) {
+        return new PotentialSchemaSource<>(sourceId, representation, cost);
     }
 
-    public static <T extends SchemaSourceRepresentation> PotentialSchemaSource<T> create(
-            final SourceIdentifier sourceIdentifier, final Class<? extends T> representation, final Costs cost) {
-        return new PotentialSchemaSource<>(sourceIdentifier, representation, cost.getValue());
+    public static <T extends SourceRepresentation> PotentialSchemaSource<T> create(
+            final SourceIdentifier sourceId, final Class<? extends T> representation, final Costs cost) {
+        return new PotentialSchemaSource<>(sourceId, representation, cost.getValue());
     }
 
     /**
index 5e07793fcd7984dfb3b7ad49a55e54dfd6589e51..ba58a4657fc999af929811c5c819de027bfe91f9 100644 (file)
@@ -9,10 +9,10 @@ package org.opendaylight.yangtools.yang.model.repo.spi;
 
 import com.google.common.annotations.Beta;
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
+import org.opendaylight.yangtools.yang.model.api.source.SourceRepresentation;
 
 /**
- * Listener on {@link SchemaSourceRepresentation} lifecycle.
+ * Listener on {@link SourceRepresentation} lifecycle.
  */
 @Beta
 @NonNullByDefault
@@ -23,7 +23,7 @@ public interface SchemaSourceListener {
      *
      * @param source Schema source
      */
-    void schemaSourceEncountered(SchemaSourceRepresentation source);
+    void schemaSourceEncountered(SourceRepresentation source);
 
     /**
      * Invoked when a new schema source is registered by a provider. This call
index d5a7fbc9747333abee3cea1220f86eb239d75db5..4add2e50fffb2b576ef206b64d6f0e49bcdaa3b2 100644 (file)
@@ -10,9 +10,9 @@ package org.opendaylight.yangtools.yang.model.repo.spi;
 import com.google.common.annotations.Beta;
 import com.google.common.util.concurrent.ListenableFuture;
 import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.SourceRepresentation;
 import org.opendaylight.yangtools.yang.model.repo.api.MissingSchemaSourceException;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 
 /**
  * Schema source provider implementations take care of resolving a {@link SourceIdentifier}
@@ -22,30 +22,29 @@ import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
  * @param <T> Schema source representation type provided by this implementation
  */
 @Beta
-public interface SchemaSourceProvider<T extends SchemaSourceRepresentation> {
+public interface SchemaSourceProvider<T extends SourceRepresentation> {
     /**
      * Returns a representation a for supplied YANG source identifier. The resolution
      * criteria are as follows:
      *
      * <ul>
-     * <li> If the source identifier specifies a revision, this method returns either
-     * a representation of that particular revision or throw {@link MissingSchemaSourceException}.
-     * <li> If the source identifier does not specify a revision, this method returns
-     * the newest available revision, or throws {@link MissingSchemaSourceException}.
+     *   <li>If the source identifier specifies a revision, this method returns either a representation of that
+     *       particular revision or throw {@link MissingSchemaSourceException}</li>
+     *   <li>If the source identifier does not specify a revision, this method returns the newest available revision,
+     *       or throws {@link MissingSchemaSourceException}</li>
      * </ul>
      *
      * <p>
-     * In either case the returned representation is required to report a non-null
-     * revision in the {@link SourceIdentifier} returned from
-     * {@link SchemaSourceRepresentation#getIdentifier()}.
+     * In either case the returned representation is required to report a non-null revision in the
+     * {@link SourceIdentifier} returned from {@link SourceRepresentation#sourceId()}.
      *
      * <p>
-     * Implementations are not required to provide constant behavior in time, notably
-     * this different invocation of this method may produce different results.
+     * Implementations are not required to provide constant behavior in time, notably this different invocation of this
+     * method may produce different results.
      *
-     * @param sourceIdentifier source identifier
+     * @param sourceId source identifier
      * @return future source representation, if supplied YANG module is available
      * @throws NullPointerException if {@code sourceIdentifier} is null
      */
-    @NonNull ListenableFuture<? extends T> getSource(@NonNull SourceIdentifier sourceIdentifier);
+    @NonNull ListenableFuture<? extends T> getSource(@NonNull SourceIdentifier sourceId);
 }
index 246353351b846f3a7d18a87a9733fec2621a76dc..d9fb0eb274883e4152c0d3d3b823412f3cac1694 100644 (file)
@@ -9,8 +9,8 @@ package org.opendaylight.yangtools.yang.model.repo.spi;
 
 import com.google.common.annotations.Beta;
 import org.opendaylight.yangtools.concepts.Registration;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.SourceRepresentation;
 
 /**
  * Registry of all potentially available schema sources. Processes capable of dynamic schema discovery, such as OSGi
@@ -28,7 +28,7 @@ public interface SchemaSourceRegistry {
      * @param source Schema source details
      * @return A registration handle. Invoking {@link Registration#close()} will cancel the registration.
      */
-    <T extends SchemaSourceRepresentation> Registration registerSchemaSource(SchemaSourceProvider<? super T> provider,
+    <T extends SourceRepresentation> Registration registerSchemaSource(SchemaSourceProvider<? super T> provider,
         PotentialSchemaSource<T> source);
 
     /**
index 21872ae53030b78841347194614a5f06c2469b91..f0221971386b44562554195c1b5df7c0f5b3767c 100644 (file)
@@ -15,14 +15,14 @@ import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.MoreExecutors;
 import java.util.HashMap;
 import java.util.Map;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.SourceRepresentation;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 
-public class SchemaSourceTransformer<S extends SchemaSourceRepresentation, D extends SchemaSourceRepresentation>
+public class SchemaSourceTransformer<S extends SourceRepresentation, D extends SourceRepresentation>
         implements SchemaSourceListener, SchemaSourceProvider<D> {
     @FunctionalInterface
-    public interface Transformation<S extends SchemaSourceRepresentation, D extends SchemaSourceRepresentation>
+    public interface Transformation<S extends SourceRepresentation, D extends SourceRepresentation>
             extends AsyncFunction<S, D> {
         @Override
         ListenableFuture<D> apply(S input) throws Exception;
@@ -51,7 +51,7 @@ public class SchemaSourceTransformer<S extends SchemaSourceRepresentation, D ext
     }
 
     @Override
-    public final void schemaSourceEncountered(final SchemaSourceRepresentation source) {
+    public final void schemaSourceEncountered(final SourceRepresentation source) {
         // Not interesting
     }
 
index cdbc4b6889eaa78e92853b3c65b08edc26a76d98..90abc12d9a831859008c0206f29eb9febf9c9c87 100644 (file)
@@ -17,18 +17,18 @@ import java.lang.ref.SoftReference;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import org.opendaylight.yangtools.concepts.Registration;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.SourceRepresentation;
 import org.opendaylight.yangtools.yang.model.repo.api.MissingSchemaSourceException;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.spi.PotentialSchemaSource.Costs;
 
 /**
  * A simple {@link AbstractSchemaSourceCache} maintaining soft references.
  *
- * @param <T> {@link SchemaSourceRepresentation} type stored in this cache
+ * @param <T> {@link SourceRepresentation} type stored in this cache
  */
 @Beta
-public final class SoftSchemaSourceCache<T extends SchemaSourceRepresentation> extends AbstractSchemaSourceCache<T>
+public final class SoftSchemaSourceCache<T extends SourceRepresentation> extends AbstractSchemaSourceCache<T>
         implements AutoCloseable {
     private static final Cleaner CLEANER = Cleaner.create();
 
@@ -74,11 +74,11 @@ public final class SoftSchemaSourceCache<T extends SchemaSourceRepresentation> e
             return;
         }
 
-        final var id = source.getIdentifier();
+        final var sourceId = source.sourceId();
         final var ref = new SoftReference<>(source);
 
         while (true) {
-            final var prev = references.putIfAbsent(id, ref);
+            final var prev = references.putIfAbsent(sourceId, ref);
             if (prev == null) {
                 // We have performed a fresh insert and need to add a cleanup
                 break;
@@ -90,15 +90,15 @@ public final class SoftSchemaSourceCache<T extends SchemaSourceRepresentation> e
             }
 
             // Existing reference is dead, remove it and retry
-            references.remove(id, prev);
+            references.remove(sourceId, prev);
         }
 
         // We have populated a cache entry, register the source and a cleanup action
-        final var reg = register(id);
+        final var reg = register(sourceId);
         cleanables.put(reg, CLEANER.register(source, () -> {
             cleanables.remove(reg);
             reg.close();
-            references.remove(id, ref);
+            references.remove(sourceId, ref);
         }));
 
         // Ensure 'source' is still reachable here. This is needed to ensure the cleanable action does not fire before
index 9e84d86e1c8003c5385c29d75a463a92008af10f..6c53af93bfd525b352a070c1abb5bb825b3794fb 100644 (file)
@@ -16,7 +16,6 @@ import static org.mockito.Mockito.doReturn;
 
 import com.google.common.base.MoreObjects.ToStringHelper;
 import java.io.StringReader;
-import java.util.Optional;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
 import org.junit.jupiter.api.Test;
@@ -24,14 +23,14 @@ import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
 import org.mockito.junit.jupiter.MockitoExtension;
 import org.opendaylight.yangtools.concepts.Registration;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.YangSchemaSourceRepresentation;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.YangSourceRepresentation;
+import org.opendaylight.yangtools.yang.model.spi.source.YangTextSource;
 
 @Deprecated
 @ExtendWith(MockitoExtension.class)
 class GuavaSchemaSourceCacheTest {
-    private static final Class<YangSchemaSourceRepresentation> REPRESENTATION = YangSchemaSourceRepresentation.class;
+    private static final Class<YangSourceRepresentation> REPRESENTATION = YangSourceRepresentation.class;
     private static final long LIFETIME = 1000L;
     private static final TimeUnit UNITS = TimeUnit.MILLISECONDS;
 
@@ -68,7 +67,7 @@ class GuavaSchemaSourceCacheTest {
             assertNotNull(checkedSource);
             final var yangSchemaSourceRepresentation = checkedSource.get();
             assertNotNull(yangSchemaSourceRepresentation);
-            assertEquals(sourceIdentifier, yangSchemaSourceRepresentation.getIdentifier());
+            assertEquals(sourceIdentifier, yangSchemaSourceRepresentation.sourceId());
         }
     }
 
@@ -105,7 +104,7 @@ class GuavaSchemaSourceCacheTest {
         }
     }
 
-    private static class TestingYangSource extends YangTextSchemaSource {
+    private static class TestingYangSource extends YangTextSource {
         private final String content;
 
         TestingYangSource(final String name, final String revision, final String content) {
@@ -119,8 +118,8 @@ class GuavaSchemaSourceCacheTest {
         }
 
         @Override
-        public Optional<String> getSymbolicName() {
-            return Optional.empty();
+        public String symbolicName() {
+            return null;
         }
 
         @Override
index d0435649d1d8b0440f3a86fcbe59ef0db5688f88..ce2408853284e4b51bf24d6592f6d56a26e98419 100644 (file)
@@ -16,27 +16,27 @@ import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.junit.jupiter.MockitoExtension;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.YangSchemaSourceRepresentation;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.YangSourceRepresentation;
 
 @ExtendWith(MockitoExtension.class)
 class PotentialSchemaSourceTest {
-    private interface TestSchemaSourceRepresentation extends YangSchemaSourceRepresentation {
+    private interface TestSourceRepresentation extends YangSourceRepresentation {
         @Override
-        default Class<TestSchemaSourceRepresentation> getType() {
-            return TestSchemaSourceRepresentation.class;
+        default Class<TestSourceRepresentation> getType() {
+            return TestSourceRepresentation.class;
         }
     }
 
     public final SourceIdentifier sourceIdentifier = new SourceIdentifier("foo");
     @SuppressWarnings("exports")
-    public PotentialSchemaSource<TestSchemaSourceRepresentation> source;
+    public PotentialSchemaSource<TestSourceRepresentation> source;
     @SuppressWarnings("exports")
-    public PotentialSchemaSource<TestSchemaSourceRepresentation> same;
+    public PotentialSchemaSource<TestSourceRepresentation> same;
 
     @BeforeEach
     void before() {
-        source = PotentialSchemaSource.create(sourceIdentifier, TestSchemaSourceRepresentation.class,
+        source = PotentialSchemaSource.create(sourceIdentifier, TestSourceRepresentation.class,
             PotentialSchemaSource.Costs.LOCAL_IO.getValue());
         same = PotentialSchemaSource.create(source.getSourceIdentifier(), source.getRepresentation(),
             source.getCost());
@@ -45,14 +45,14 @@ class PotentialSchemaSourceTest {
     @Test
     void testNegativeCost() {
         assertThrows(IllegalArgumentException.class,
-            () -> PotentialSchemaSource.create(sourceIdentifier, TestSchemaSourceRepresentation.class, -1));
+            () -> PotentialSchemaSource.create(sourceIdentifier, TestSourceRepresentation.class, -1));
     }
 
     @Test
     void testMethods() {
         assertEquals(PotentialSchemaSource.Costs.LOCAL_IO.getValue(), source.getCost());
         assertSame(sourceIdentifier, source.getSourceIdentifier());
-        assertSame(TestSchemaSourceRepresentation.class, source.getRepresentation());
+        assertSame(TestSourceRepresentation.class, source.getRepresentation());
         assertEquals(same.hashCode(), source.hashCode());
         assertNotEquals(null, source);
         assertEquals(source, source);
index f7d198dfa839647d34d7ea5fda3f74387ea3483d..cfb5580dcf45d7ae4151f2709cbf36e790c933f1 100644 (file)
@@ -19,19 +19,19 @@ import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
 import org.mockito.junit.jupiter.MockitoExtension;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.SourceRepresentation;
+import org.opendaylight.yangtools.yang.model.api.source.YangSourceRepresentation;
 import org.opendaylight.yangtools.yang.model.repo.api.EffectiveModelContextFactory;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactoryConfiguration;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.YangSchemaSourceRepresentation;
-import org.opendaylight.yangtools.yang.model.repo.api.YinXmlSchemaSource;
 import org.opendaylight.yangtools.yang.model.repo.spi.PotentialSchemaSource.Costs;
+import org.opendaylight.yangtools.yang.model.spi.source.YinXmlSource;
 
 @ExtendWith(MockitoExtension.class)
 class SchemaSourceTransformerTest {
-    public static final Class<YangSchemaSourceRepresentation> SRC_CLASS = YangSchemaSourceRepresentation.class;
-    public static final Class<YinXmlSchemaSource> DST_CLASS = YinXmlSchemaSource.class;
+    public static final Class<YangSourceRepresentation> SRC_CLASS = YangSourceRepresentation.class;
+    public static final Class<YinXmlSource> DST_CLASS = YinXmlSource.class;
 
     @Mock
     public SchemaRepository provider;
@@ -40,9 +40,9 @@ class SchemaSourceTransformerTest {
     public SchemaSourceRegistry consumer;
 
     @Mock
-    public AsyncFunction<YangSchemaSourceRepresentation, YinXmlSchemaSource> function;
+    public AsyncFunction<YangSourceRepresentation, YinXmlSource> function;
 
-    public SchemaSourceTransformer<YangSchemaSourceRepresentation, YinXmlSchemaSource> schema;
+    public SchemaSourceTransformer<YangSourceRepresentation, YinXmlSource> schema;
 
     @Test
     void schemaSourceTransformerTest() {
@@ -99,7 +99,7 @@ class SchemaSourceTransformerTest {
         assertNotNull(source2);
     }
 
-    private static class Foo<T extends SchemaSourceRepresentation> {
+    private static class Foo<T extends SourceRepresentation> {
         final PotentialSchemaSource<T> src;
 
         Foo(final SourceIdentifier sourceIdentifier, final Class<T> representation, final Costs cost) {
@@ -111,20 +111,19 @@ class SchemaSourceTransformerTest {
         }
     }
 
-    private static class Registrator extends AbstractSchemaSourceCache<YangSchemaSourceRepresentation> {
-        Registrator(final SchemaSourceRegistry consumer, final Class<YangSchemaSourceRepresentation> srcClass,
+    private static class Registrator extends AbstractSchemaSourceCache<YangSourceRepresentation> {
+        Registrator(final SchemaSourceRegistry consumer, final Class<YangSourceRepresentation> srcClass,
                 final Costs cost) {
             super(consumer, srcClass, cost);
         }
 
         @Override
-        protected void offer(final YangSchemaSourceRepresentation source) {
+        protected void offer(final YangSourceRepresentation source) {
 
         }
 
         @Override
-        public ListenableFuture<? extends YangSchemaSourceRepresentation> getSource(
-                final SourceIdentifier sourceIdentifier) {
+        public ListenableFuture<? extends YangSourceRepresentation> getSource(final SourceIdentifier sourceId) {
             return SettableFuture.create();
         }
     }
index cf9c3ad2088a891d055523361f4179cea7fc75c9..a3759c540a552a06372a9e2ce21b285acc5844ec 100644 (file)
@@ -16,20 +16,19 @@ import static org.mockito.Mockito.doReturn;
 
 import com.google.common.base.MoreObjects.ToStringHelper;
 import java.io.StringReader;
-import java.util.Optional;
 import java.util.concurrent.ExecutionException;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
 import org.mockito.junit.jupiter.MockitoExtension;
 import org.opendaylight.yangtools.concepts.Registration;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.YangSchemaSourceRepresentation;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.YangSourceRepresentation;
+import org.opendaylight.yangtools.yang.model.spi.source.YangTextSource;
 
 @ExtendWith(MockitoExtension.class)
 class SoftSchemaSourceCacheTest {
-    private static final Class<YangSchemaSourceRepresentation> REPRESENTATION = YangSchemaSourceRepresentation.class;
+    private static final Class<YangSourceRepresentation> REPRESENTATION = YangSourceRepresentation.class;
 
     @Mock
     private SchemaSourceRegistry registry;
@@ -57,7 +56,7 @@ class SoftSchemaSourceCacheTest {
             assertNotNull(checkedSource);
             final var yangSchemaSourceRepresentation = checkedSource.get();
             assertNotNull(yangSchemaSourceRepresentation);
-            assertEquals(sourceIdentifier, yangSchemaSourceRepresentation.getIdentifier());
+            assertEquals(sourceIdentifier, yangSchemaSourceRepresentation.sourceId());
         }
     }
 
@@ -94,7 +93,7 @@ class SoftSchemaSourceCacheTest {
         }
     }
 
-    private static class TestingYangSource extends YangTextSchemaSource {
+    private static class TestingYangSource extends YangTextSource {
         private final String content;
 
         TestingYangSource(final String name, final String revision, final String content) {
@@ -108,8 +107,8 @@ class SoftSchemaSourceCacheTest {
         }
 
         @Override
-        public Optional<String> getSymbolicName() {
-            return Optional.empty();
+        public String symbolicName() {
+            return null;
         }
 
         @Override