Bump yangtools to 13.0.0
[mdsal.git] / binding / mdsal-binding-runtime-spi / src / main / java / org / opendaylight / mdsal / binding / runtime / spi / ModuleInfoSnapshotResolver.java
index ab655c878286b1d785a09d6989594e6db370dcbe..d98becaabaaeafb11797060801087621a3d1cd74 100644 (file)
@@ -37,12 +37,12 @@ import org.opendaylight.yangtools.yang.binding.YangFeature;
 import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
 import org.opendaylight.yangtools.yang.binding.contract.Naming;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.Revision;
 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.YangTextSource;
 import org.opendaylight.yangtools.yang.model.api.stmt.SubmoduleEffectiveStatement;
 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.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.spi.source.DelegatedYangTextSource;
 import org.opendaylight.yangtools.yang.parser.api.YangParserFactory;
 import org.opendaylight.yangtools.yang.parser.api.YangSyntaxErrorException;
 import org.opendaylight.yangtools.yang.parser.repo.YangTextSchemaContextResolver;
@@ -167,7 +167,7 @@ public final class ModuleInfoSnapshotResolver implements Mutable {
     public synchronized @NonNull ModuleInfoSnapshot takeSnapshot() {
         final var effectiveModel = ctxResolver.getEffectiveModelContext().orElseThrow();
         final var local = currentSnapshot;
-        if (local != null && local.getEffectiveModelContext().equals(effectiveModel)) {
+        if (local != null && local.modelContext().equals(effectiveModel)) {
             return local;
         }
 
@@ -175,10 +175,10 @@ public final class ModuleInfoSnapshotResolver implements Mutable {
     }
 
     @Holding("this")
-    private @NonNull ModuleInfoSnapshot updateSnapshot(final EffectiveModelContext effectiveModel) {
+    private @NonNull ModuleInfoSnapshot updateSnapshot(final EffectiveModelContext modelContext) {
         // Alright, now let's find out which sources got captured
         final var sources = new HashSet<SourceIdentifier>();
-        for (var entry : effectiveModel.getModuleStatements().entrySet()) {
+        for (var entry : modelContext.getModuleStatements().entrySet()) {
             final var revision = entry.getKey().getRevision().orElse(null);
             final var module = entry.getValue();
 
@@ -202,7 +202,7 @@ public final class ModuleInfoSnapshotResolver implements Mutable {
                 infoClass.getClassLoader());
         }
 
-        final var next = new DefaultModuleInfoSnapshot(effectiveModel, moduleInfos, classLoaders);
+        final var next = new DefaultModuleInfoSnapshot(modelContext, moduleInfos, classLoaders);
         currentSnapshot = next;
         return next;
     }
@@ -223,19 +223,18 @@ public final class ModuleInfoSnapshotResolver implements Mutable {
         }
     }
 
-    static @NonNull YangTextSchemaSource toYangTextSource(final YangModuleInfo moduleInfo) {
-        return YangTextSchemaSource.delegateForCharSource(sourceIdentifierFrom(moduleInfo),
-            moduleInfo.getYangTextCharSource());
+    static @NonNull YangTextSource toYangTextSource(final YangModuleInfo moduleInfo) {
+        return new DelegatedYangTextSource(sourceIdentifierFrom(moduleInfo), moduleInfo.getYangTextCharSource());
     }
 
-    private static @NonNull YangTextSchemaSource toYangTextSource(final SourceIdentifier identifier,
+    private static @NonNull YangTextSource toYangTextSource(final SourceIdentifier identifier,
             final YangModuleInfo moduleInfo) {
-        return YangTextSchemaSource.delegateForCharSource(identifier, moduleInfo.getYangTextCharSource());
+        return new DelegatedYangTextSource(identifier, moduleInfo.getYangTextCharSource());
     }
 
     private static SourceIdentifier sourceIdentifierFrom(final YangModuleInfo moduleInfo) {
         final var name = moduleInfo.getName();
-        return new SourceIdentifier(name.getLocalName(), name.getRevision().map(Revision::toString).orElse(null));
+        return new SourceIdentifier(name.getLocalName(), name.getRevision().orElse(null));
     }
 
     private static @NonNull List<@NonNull YangModuleInfo> flatDependencies(final YangModuleInfo moduleInfo) {