Bump yangtools to 13.0.0 82/109282/15
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 11 Dec 2023 10:19:04 +0000 (11:19 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 8 Jan 2024 08:06:32 +0000 (09:06 +0100)
This adopts yangtools-13.0.0 and updates the various integration
surfaces.

Change-Id: Ie9e2ed6fec32bdb7cd98803552a4500a5b44f127
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
82 files changed:
binding/binding-parent/pom.xml
binding/mdsal-binding-dom-adapter/src/main/java/module-info.java
binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/BindingDOMWriteTransactionAdapter.java
binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/CurrentAdapterSerializer.java
binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/FutureSchema.java
binding/mdsal-binding-dom-adapter/src/test/java/org/opendaylight/mdsal/binding/dom/adapter/BindingStructuralTypeTest.java
binding/mdsal-binding-dom-adapter/src/test/java/org/opendaylight/mdsal/binding/dom/adapter/CurrentAdapterSerializerTest.java
binding/mdsal-binding-dom-adapter/src/test/java/org/opendaylight/mdsal/binding/dom/adapter/test/AbstractDataBrokerTestCustomizer.java
binding/mdsal-binding-dom-adapter/src/test/java/org/opendaylight/mdsal/binding/dom/adapter/test/AbstractSchemaAwareTest.java
binding/mdsal-binding-dom-adapter/src/test/java/org/opendaylight/mdsal/binding/dom/adapter/test/util/BindingTestContext.java
binding/mdsal-binding-dom-adapter/src/test/java/org/opendaylight/mdsal/binding/dom/adapter/test/util/MockSchemaService.java
binding/mdsal-binding-dom-codec-spi/src/main/java/org/opendaylight/mdsal/binding/dom/codec/spi/AbstractBindingLazyContainerNode.java
binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/BindingCodecContext.java
binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/CodecDataObject.java
binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/DataContainerCodecContext.java
binding/mdsal-binding-dom-codec/src/test/java/org/opendaylight/mdsal/binding/dom/codec/impl/Mdsal673Test.java
binding/mdsal-binding-dom-codec/src/test/java/org/opendaylight/mdsal/binding/dom/codec/impl/NonCachingCodecTest.java
binding/mdsal-binding-generator/src/main/java/org/opendaylight/mdsal/binding/generator/impl/BindingRuntimeTypesFactory.java
binding/mdsal-binding-generator/src/main/java/org/opendaylight/mdsal/binding/generator/impl/DefaultBindingRuntimeGenerator.java
binding/mdsal-binding-generator/src/main/java/org/opendaylight/mdsal/binding/generator/impl/reactor/GeneratorContext.java
binding/mdsal-binding-generator/src/main/java/org/opendaylight/mdsal/binding/generator/impl/rt/DefaultBindingRuntimeTypes.java
binding/mdsal-binding-generator/src/test/java/org/opendaylight/mdsal/binding/generator/impl/Mdsal829Test.java
binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/java/api/generator/JavaFileGenerator.java
binding/mdsal-binding-runtime-api/pom.xml
binding/mdsal-binding-runtime-api/src/main/java/module-info.java
binding/mdsal-binding-runtime-api/src/main/java/org/opendaylight/mdsal/binding/runtime/api/BindingRuntimeContext.java
binding/mdsal-binding-runtime-api/src/main/java/org/opendaylight/mdsal/binding/runtime/api/BindingRuntimeGenerator.java
binding/mdsal-binding-runtime-api/src/main/java/org/opendaylight/mdsal/binding/runtime/api/BindingRuntimeTypes.java
binding/mdsal-binding-runtime-api/src/main/java/org/opendaylight/mdsal/binding/runtime/api/ModuleInfoSnapshot.java
binding/mdsal-binding-runtime-osgi/src/main/java/org/opendaylight/mdsal/binding/runtime/osgi/impl/OSGiBindingRuntime.java
binding/mdsal-binding-runtime-spi/pom.xml
binding/mdsal-binding-runtime-spi/src/main/java/module-info.java
binding/mdsal-binding-runtime-spi/src/main/java/org/opendaylight/mdsal/binding/runtime/spi/BindingRuntimeHelpers.java
binding/mdsal-binding-runtime-spi/src/main/java/org/opendaylight/mdsal/binding/runtime/spi/DefaultModuleInfoSnapshot.java
binding/mdsal-binding-runtime-spi/src/main/java/org/opendaylight/mdsal/binding/runtime/spi/ForwardingModuleInfoSnapshot.java
binding/mdsal-binding-runtime-spi/src/main/java/org/opendaylight/mdsal/binding/runtime/spi/ModuleInfoSnapshotBuilder.java
binding/mdsal-binding-runtime-spi/src/main/java/org/opendaylight/mdsal/binding/runtime/spi/ModuleInfoSnapshotResolver.java
binding/mdsal-binding-runtime-spi/src/test/java/org/opendaylight/mdsal/binding/runtime/spi/ModuleInfoSnapshotBuilderTest.java
binding/mdsal-binding-test-utils/src/main/java/org/opendaylight/mdsal/binding/testutils/DataBrokerTestModule.java
docs/pom.xml
dom/dom-parent/pom.xml
dom/mdsal-dom-api/pom.xml
dom/mdsal-dom-api/src/main/java/module-info.java
dom/mdsal-dom-api/src/main/java/org/opendaylight/mdsal/dom/api/DOMSchemaService.java
dom/mdsal-dom-api/src/main/java/org/opendaylight/mdsal/dom/api/DOMYangTextSourceProvider.java
dom/mdsal-dom-broker/pom.xml
dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMRpcRouter.java
dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/Rpcs.java
dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/InMemoryDOMDataStore.java
dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/InMemoryDOMDataStoreFactory.java
dom/mdsal-dom-inmemory-datastore/src/test/java/org/opendaylight/mdsal/dom/store/inmemory/InMemoryDOMDataStoreFactoryTest.java
dom/mdsal-dom-schema-osgi/pom.xml
dom/mdsal-dom-schema-osgi/src/main/java/module-info.java
dom/mdsal-dom-schema-osgi/src/main/java/org/opendaylight/mdsal/dom/schema/osgi/impl/ModelContextListener.java [moved from dom/mdsal-dom-schema-osgi/src/main/java/org/opendaylight/mdsal/dom/schema/osgi/impl/EffectiveModelContextImpl.java with 57% similarity]
dom/mdsal-dom-schema-osgi/src/main/java/org/opendaylight/mdsal/dom/schema/osgi/impl/OSGiDOMSchemaService.java
dom/mdsal-dom-spi/src/main/java/org/opendaylight/mdsal/dom/spi/AbstractDOMSchemaService.java [deleted file]
dom/mdsal-dom-spi/src/main/java/org/opendaylight/mdsal/dom/spi/FixedDOMSchemaService.java
dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/ContentRoutedRpcContextTest.java
dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/PingPongTransactionChainTest.java
dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/store/SnapshotBackedReadTransactionTest.java
dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/store/SnapshotBackedReadWriteTransactionTest.java
dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/store/SnapshotBackedWriteTransactionTest.java
features/feature-parent/pom.xml
features/odl-mdsal-binding-api/src/main/feature/feature.xml
features/odl-mdsal-binding-base/src/main/feature/feature.xml
features/odl-mdsal-binding-runtime-api/src/main/feature/feature.xml
features/odl-mdsal-common/src/main/feature/feature.xml
features/odl-mdsal-dom-api/src/main/feature/feature.xml
features/odl-mdsal-eos-common/src/main/feature/feature.xml
features/odl-mdsal-exp-yanglib-api/src/main/feature/feature.xml
features/odl-mdsal-replicate-netty/src/main/feature/feature.xml
features/odl-mdsal-rfc8294-netty/src/main/feature/feature.xml
replicate/mdsal-replicate-common/src/main/java/org/opendaylight/mdsal/replicate/common/DOMDataBrokerModification.java
replicate/mdsal-replicate-common/src/main/java/org/opendaylight/mdsal/replicate/common/DOMStoreModification.java
replicate/mdsal-replicate-netty/src/main/java/org/opendaylight/mdsal/replicate/netty/NettyReplicationSource.java
yanglib/mdsal-yanglib-api/pom.xml
yanglib/mdsal-yanglib-api/src/main/java/org/opendaylight/mdsal/yanglib/api/SourceReference.java
yanglib/mdsal-yanglib-rfc8525/src/main/java/org/opendaylight/mdsal/yanglib/rfc8525/MountPointContextFactoryImpl.java
yanglib/mdsal-yanglib-rfc8525/src/main/java/org/opendaylight/mdsal/yanglib/rfc8525/YangLibrarySupport.java
yanglib/mdsal-yanglib-rfc8525/src/test/java/org/opendaylight/mdsal/yanglib/rfc8525/AbstractYangLibraryTest.java
yanglib/mdsal-yanglib-rfc8525/src/test/java/org/opendaylight/mdsal/yanglib/rfc8525/LegacyYangLibraryFormatTest.java
yanglib/mdsal-yanglib-rfc8525/src/test/java/org/opendaylight/mdsal/yanglib/rfc8525/YangLibrarySupportTest.java

index 1ed2a3b2c5e61176d0912d2da3dfea80e4d6b1d8..7b87af3f6f5d030c316333a6c3fb7ae6af094e00 100644 (file)
@@ -70,7 +70,7 @@
                         <plugin>
                             <groupId>org.opendaylight.yangtools</groupId>
                             <artifactId>yang-maven-plugin</artifactId>
-                            <version>11.0.5</version>
+                            <version>13.0.0</version>
                             <dependencies>
                                 <dependency>
                                     <groupId>org.opendaylight.mdsal</groupId>
index bed4a62a3cc5682395685fd79dc65cf3f2af1ca8..7efb5b51e4c6e693746e332e402e540094682d20 100644 (file)
@@ -34,6 +34,7 @@ module org.opendaylight.mdsal.binding.dom.adapter {
     requires org.opendaylight.mdsal.binding.runtime.api;
     requires org.opendaylight.mdsal.binding.spec.util;
     requires org.opendaylight.mdsal.dom.spi;
+    requires org.opendaylight.yangtools.concepts;
     requires org.opendaylight.yangtools.yang.common;
     requires org.opendaylight.yangtools.yang.model.api;
     requires org.slf4j;
index 742ba5c927eb6a53ccc3123726026c35c9ddf526..016b781d59ccfbc5c0f1a1f0111e9b07a9d50834 100644 (file)
@@ -147,8 +147,8 @@ class BindingDOMWriteTransactionAdapter<T extends DOMDataTreeWriteTransaction> e
         // AugmentationResult already points to parent path
         final var parentPath = normalized instanceof AugmentationResult ? path : path.getParent();
         if (parentPath != null && !parentPath.isEmpty()) {
-            final var parentNode = ImmutableNodes.fromInstanceId(
-                serializer.getRuntimeContext().getEffectiveModelContext(), parentPath);
+            final var parentNode = ImmutableNodes.fromInstanceId(serializer.getRuntimeContext().modelContext(),
+                parentPath);
             getDelegate().merge(store, YangInstanceIdentifier.of(parentNode.name()), parentNode);
         }
     }
index c5b99844f2ce0c23528a1163b8ee9c634168fb11..432a4a4aafe9f01123852a6fc2b95290c0d8d205 100644 (file)
@@ -152,7 +152,7 @@ public final class CurrentAdapterSerializer extends ForwardingBindingDOMCodecSer
     }
 
     private @NonNull Entry<SchemaInferenceStack, QNameModule> resolvePath(final @NonNull InstanceIdentifier<?> path) {
-        final var stack = SchemaInferenceStack.of(getRuntimeContext().getEffectiveModelContext());
+        final var stack = SchemaInferenceStack.of(getRuntimeContext().modelContext());
         final var it = toYangInstanceIdentifier(path).getPathArguments().iterator();
         verify(it.hasNext(), "Unexpected empty instance identifier for %s", path);
 
index 03248a75bca49edc341938203f473e9a9778e9f9..fbe1d71f70b23168a5ae009665ea9367adc26782 100644 (file)
@@ -132,7 +132,7 @@ abstract class FutureSchema implements AutoCloseable {
         return addPostponedOpAndWait(new FutureSchemaPredicate() {
             @Override
             public boolean test(final BindingRuntimeContext input) {
-                return input.getEffectiveModelContext().findModule(module).isPresent();
+                return input.modelContext().findModule(module).isPresent();
             }
         });
     }
index eeb519109fabc338be49b7140044eca7c363da23..18273b5b010d0538c6d8217f9440fe1311f7bce8 100644 (file)
@@ -7,25 +7,25 @@
  */
 package org.opendaylight.mdsal.binding.dom.adapter;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.Mockito.doReturn;
 
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.opendaylight.yangtools.yang.data.api.schema.AnydataNode;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode;
 
-@RunWith(MockitoJUnitRunner.StrictStubs.class)
-public class BindingStructuralTypeTest {
+@ExtendWith(MockitoExtension.class)
+class BindingStructuralTypeTest {
     @Mock
-    private NormalizedNode normalizedNode;
+    private AnydataNode<?> normalizedNode;
     @Mock
     private DataTreeCandidateNode dataTreeCandidateNode;
 
     @Test
-    public void basicTest() {
+    void basicTest() {
         doReturn(normalizedNode).when(dataTreeCandidateNode).dataBefore();
         assertEquals(BindingStructuralType.UNKNOWN, BindingStructuralType.from(dataTreeCandidateNode));
     }
index a2e8e9b8a8f9b9347b28494e048411355a5dfd96..e677a8625edfd1ce2e85690b624a90b7bfe91fa3 100644 (file)
@@ -34,8 +34,8 @@ import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
-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.YangTextSource;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public class CurrentAdapterSerializerTest {
@@ -126,12 +126,12 @@ public class CurrentAdapterSerializerTest {
         }
 
         @Override
-        public EffectiveModelContext getEffectiveModelContext() {
+        public EffectiveModelContext modelContext() {
             throw new UnsupportedOperationException();
         }
 
         @Override
-        public ListenableFuture<? extends YangTextSchemaSource> getSource(final SourceIdentifier sourceIdentifier) {
+        public ListenableFuture<? extends YangTextSource> getSource(final SourceIdentifier sourceIdentifier) {
             throw new UnsupportedOperationException();
         }
 
index 4d69c99603ff1701551b95aa5dd172789f50e0a2..52c8f48f5f30bda3d778118a9d2941b10de2b621 100644 (file)
@@ -42,14 +42,14 @@ public abstract class AbstractDataBrokerTestCustomizer {
     }
 
     public DOMStore createConfigurationDatastore() {
-        final InMemoryDOMDataStore store = new InMemoryDOMDataStore("CFG", getDataTreeChangeListenerExecutor());
-        schemaService.registerSchemaContextListener(store);
+        final var store = new InMemoryDOMDataStore("CFG", getDataTreeChangeListenerExecutor());
+        schemaService.registerSchemaContextListener(store::onModelContextUpdated);
         return store;
     }
 
     public DOMStore createOperationalDatastore() {
-        final InMemoryDOMDataStore store = new InMemoryDOMDataStore("OPER", getDataTreeChangeListenerExecutor());
-        schemaService.registerSchemaContextListener(store);
+        final var store = new InMemoryDOMDataStore("OPER", getDataTreeChangeListenerExecutor());
+        schemaService.registerSchemaContextListener(store::onModelContextUpdated);
         return store;
     }
 
index 2819d2837b09e77a3696bc0bad4e7b753a35ea62..286aa99547a530bbbc9e9f0a45e6962b113a4768 100644 (file)
@@ -53,12 +53,12 @@ public abstract class AbstractSchemaAwareTest {
         return RUNTIME_CONTEXT_CACHE.getUnchecked(getModuleInfos());
     }
 
-    protected EffectiveModelContext getSchemaContext() throws Exception {
-        return getRuntimeContext().getEffectiveModelContext();
+    protected EffectiveModelContext modelContext() throws Exception {
+        return getRuntimeContext().modelContext();
     }
 
     protected void setupWithRuntimeContext(final BindingRuntimeContext runtimeContext) {
-        setupWithSchema(runtimeContext.getEffectiveModelContext());
+        setupWithSchema(runtimeContext.modelContext());
     }
 
     /**
index 5a80df68ce56a8aea8c7a7e49bfc310e7435e4e8..3d347256a51404ce6ed1130fa47eea6e2f0b054e 100644 (file)
@@ -99,10 +99,8 @@ public class BindingTestContext implements AutoCloseable {
 
     public void startNewDomDataBroker() {
         checkState(executor != null, "Executor needs to be set");
-        final InMemoryDOMDataStore operStore = new InMemoryDOMDataStore("OPER",
-            MoreExecutors.newDirectExecutorService());
-        final InMemoryDOMDataStore configStore = new InMemoryDOMDataStore("CFG",
-            MoreExecutors.newDirectExecutorService());
+        final var operStore = new InMemoryDOMDataStore("OPER", MoreExecutors.newDirectExecutorService());
+        final var configStore = new InMemoryDOMDataStore("CFG", MoreExecutors.newDirectExecutorService());
         newDatastores = ImmutableMap.<LogicalDatastoreType, DOMStore>builder()
                 .put(LogicalDatastoreType.OPERATIONAL, operStore)
                 .put(LogicalDatastoreType.CONFIGURATION, configStore)
@@ -110,8 +108,8 @@ public class BindingTestContext implements AutoCloseable {
 
         newDOMDataBroker = new SerializedDOMDataBroker(newDatastores, executor);
 
-        mockSchemaService.registerSchemaContextListener(configStore);
-        mockSchemaService.registerSchemaContextListener(operStore);
+        mockSchemaService.registerSchemaContextListener(configStore::onModelContextUpdated);
+        mockSchemaService.registerSchemaContextListener(operStore::onModelContextUpdated);
     }
 
     public void startBindingDataBroker() {
@@ -139,7 +137,7 @@ public class BindingTestContext implements AutoCloseable {
     }
 
     public EffectiveModelContext getContext() {
-        return mockSchemaService.getEffectiveModelContext();
+        return mockSchemaService.getGlobalContext();
     }
 
     public void start() {
@@ -167,8 +165,7 @@ public class BindingTestContext implements AutoCloseable {
 
     private void startDomBroker() {
         checkState(executor != null);
-        domRouter = new DOMRpcRouter();
-        mockSchemaService.registerSchemaContextListener(domRouter);
+        domRouter = new DOMRpcRouter(mockSchemaService);
     }
 
     public void startBindingNotificationBroker() {
index 2d8a1de7201b300ee9346bde6941d9b105c0d026..313a16eb45faed451e0942d88ae219565c42b58d 100644 (file)
@@ -13,19 +13,18 @@ import com.google.common.cache.CacheBuilder;
 import com.google.common.cache.CacheLoader;
 import com.google.common.cache.LoadingCache;
 import java.util.ServiceLoader;
+import java.util.function.Consumer;
 import org.opendaylight.mdsal.binding.dom.adapter.AdapterContext;
 import org.opendaylight.mdsal.binding.dom.adapter.CurrentAdapterSerializer;
 import org.opendaylight.mdsal.binding.dom.codec.spi.BindingDOMCodecFactory;
 import org.opendaylight.mdsal.binding.dom.codec.spi.BindingDOMCodecServices;
 import org.opendaylight.mdsal.binding.runtime.api.BindingRuntimeContext;
 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.util.ListenerRegistry;
+import org.opendaylight.yangtools.concepts.Registration;
+import org.opendaylight.yangtools.util.ObjectRegistry;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextProvider;
 
-public final class MockSchemaService implements DOMSchemaService, EffectiveModelContextProvider, AdapterContext {
+public final class MockSchemaService implements DOMSchemaService, AdapterContext {
     // Codec has some amount of non-trivial state, such as generated classes. Its operation should not be affected by
     // anything except BindingRuntimeContext, hence we should be able to reuse it.
     private static final LoadingCache<BindingRuntimeContext, BindingDOMCodecServices> CODEC_CACHE =
@@ -38,31 +37,25 @@ public final class MockSchemaService implements DOMSchemaService, EffectiveModel
                 }
             });
 
-    private EffectiveModelContext schemaContext;
+    private EffectiveModelContext modelContext;
     private CurrentAdapterSerializer serializer;
 
-    final ListenerRegistry<EffectiveModelContextListener> listeners = ListenerRegistry.create();
+    final ObjectRegistry<Consumer<EffectiveModelContext>> listeners = ObjectRegistry.createConcurrent("mock schema");
 
     @Override
     public synchronized EffectiveModelContext getGlobalContext() {
-        return schemaContext;
+        return modelContext;
     }
 
     @Override
-    public ListenerRegistration<EffectiveModelContextListener> registerSchemaContextListener(
-            final EffectiveModelContextListener listener) {
+    public Registration registerSchemaContextListener(final Consumer<EffectiveModelContext> listener) {
         return listeners.register(listener);
     }
 
-    @Override
-    public synchronized EffectiveModelContext getEffectiveModelContext() {
-        return schemaContext;
-    }
-
     public synchronized void changeSchema(final BindingRuntimeContext newContext) {
         serializer = new CurrentAdapterSerializer(CODEC_CACHE.getUnchecked(newContext));
-        schemaContext = newContext.getEffectiveModelContext();
-        listeners.streamListeners().forEach(listener -> listener.onModelContextUpdated(schemaContext));
+        modelContext = newContext.modelContext();
+        listeners.streamObjects().forEach(listener -> listener.accept(modelContext));
     }
 
     @Override
index cc65a621bc4a769ee47591650734dfce43766653..827c420d9a8dd63f01cf847fa9d16fd86169bded 100644 (file)
@@ -54,12 +54,6 @@ public abstract class AbstractBindingLazyContainerNode<T extends DataObject, C>
         return identifier;
     }
 
-    @Override
-    @Deprecated(since = "12.0.0", forRemoval = true)
-    public final NodeIdentifier getIdentifier() {
-        return identifier;
-    }
-
     @Override
     public final ContainerNode getDelegate() {
         return delegate();
index 33d9e2ad89fa5fd26afa3c59820429b899041b49..c3e327ec9a2d518aeaabde3bd378e6dd70a77aee 100644 (file)
@@ -185,7 +185,7 @@ public final class BindingCodecContext extends AbstractBindingNormalizedNodeSeri
                 final var child = type.schemaTreeChild(qname);
                 if (child == null) {
                     final var module = qname.getModule();
-                    if (context.getEffectiveModelContext().findModule(module).isEmpty()) {
+                    if (context.modelContext().findModule(module).isEmpty()) {
                         throw new MissingSchemaException(
                             "Module " + module + " is not present in current schema context.");
                     }
@@ -649,7 +649,7 @@ public final class BindingCodecContext extends AbstractBindingNormalizedNodeSeri
                     final Class<?> valueType = method.getReturnType();
                     final ValueCodec<Object, Object> codec = getCodec(valueType, leafSchema.getType());
                     valueNode = LeafNodeCodecContext.of(leafSchema, codec, method.getName(), valueType,
-                        context.getEffectiveModelContext());
+                        context.modelContext());
                 } else if (schema instanceof LeafListSchemaNode leafListSchema) {
                     final Optional<Type> optType = ClassLoaderUtils.getFirstGenericParameter(
                         method.getGenericReturnType());
index 65e40086155a3d804c3262dbc1d05ef2105a6643..173ccccd44bb2d00e61194c9deb110c1e2fc5d62 100644 (file)
@@ -45,8 +45,8 @@ public abstract class CodecDataObject<T extends DataObject> implements DataObjec
     private final @NonNull DataContainerNode data;
 
     // Accessed via a VarHandle
-    @SuppressWarnings("unused")
     // FIXME: consider using a primitive int-based cache (with 0 being uninit)
+    @SuppressWarnings("unused")
     @SuppressFBWarnings(value = "UUF_UNUSED_FIELD", justification = "https://github.com/spotbugs/spotbugs/issues/2749")
     private volatile Integer cachedHashcode;
 
index 403e3dc57e22088fe3c2da6baf2a22394ade2b8c..67cbc1aa3b47a521cfdc929bd6156fa73a41f685 100644 (file)
@@ -43,7 +43,6 @@ import org.opendaylight.yangtools.yang.binding.DataContainer;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
@@ -194,8 +193,8 @@ abstract sealed class DataContainerCodecContext<D extends BindingObject & DataCo
 
     @CheckReturnValue
     private IllegalArgumentException childNullException(final QName child, final String message, final Object... args) {
-        final QNameModule module = child.getModule();
-        if (!factory().getRuntimeContext().getEffectiveModelContext().findModule(module).isPresent()) {
+        final var module = child.getModule();
+        if (!factory().getRuntimeContext().modelContext().findModule(module).isPresent()) {
             return new MissingSchemaException("Module " + module + " is not present in current schema context.");
         }
         return new IncorrectNestingException(message, args);
index 104f07911107aebf971d9c6e5085712035bb5108..b21aed113cce3a38a7f71b3088034df8b7f39e79 100644 (file)
@@ -21,7 +21,7 @@ import org.opendaylight.yang.gen.v1.mdsal668.norev.bar.BarBuilder;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 
 public class Mdsal673Test extends AbstractBindingCodecTest {
     private static final NodeIdentifier FOO = new NodeIdentifier(Foo.QNAME);
@@ -33,7 +33,7 @@ public class Mdsal673Test extends AbstractBindingCodecTest {
     @Test
     public void testNonnullContainer() {
         final var entry = codecContext.fromNormalizedNode(YangInstanceIdentifier.of(FOO),
-            Builders.containerBuilder().withNodeIdentifier(FOO).build());
+            ImmutableNodes.newContainerBuilder().withNodeIdentifier(FOO).build());
         assertNotNull(entry);
         assertEquals(InstanceIdentifier.create(Foo.class), entry.getKey());
 
@@ -52,9 +52,9 @@ public class Mdsal673Test extends AbstractBindingCodecTest {
     @Test
     public void testEmptyContainer() {
         final var entry = codecContext.fromNormalizedNode(YangInstanceIdentifier.of(FOO),
-            Builders.containerBuilder()
+            ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(FOO)
-                .withChild(Builders.containerBuilder().withNodeIdentifier(BAR).build())
+                .withChild(ImmutableNodes.newContainerBuilder().withNodeIdentifier(BAR).build())
                 .build());
         assertNotNull(entry);
         assertEquals(InstanceIdentifier.create(Foo.class), entry.getKey());
@@ -73,14 +73,13 @@ public class Mdsal673Test extends AbstractBindingCodecTest {
     @Test
     public void testNotEmptyContainer() {
         // FIXME: MDSAL-670: these should get translated to YangInstanceIdentifier.of(FOO)
-        final var identifier = new YangInstanceIdentifier.NodeWithValue<>(Bar.QNAME, FOO);
-        final var data = Builders.containerBuilder()
+        final var data = ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(FOO)
-            .withChild(Builders.containerBuilder()
+            .withChild(ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(BAR)
-                .withChild(Builders.leafSetBuilder()
+                .withChild(ImmutableNodes.newSystemLeafSetBuilder()
                     .withNodeIdentifier(BAR)
-                    .withChild(Builders.leafSetEntryBuilder().withNodeIdentifier(identifier).withValue(FOO).build())
+                    .withChild(ImmutableNodes.leafSetEntry(Bar.QNAME, FOO))
                     .build())
                 .build())
             .build();
index 3a4017a50cc3f41effe09b7a00d59123e2bafb94..6f2cd64b7e73c6e5f000a2550b4e36c26aacaa57 100644 (file)
@@ -17,14 +17,14 @@ import org.mockito.Mock;
 import org.mockito.junit.MockitoJUnitRunner;
 import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeCodec;
 import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 
 @RunWith(MockitoJUnitRunner.StrictStubs.class)
 public class NonCachingCodecTest {
     @Mock
     public BindingNormalizedNodeCodec<DataObject> codec;
     @Mock
-    public NormalizedNode node;
+    public ContainerNode node;
     @Mock
     public DataObject object;
 
index 8d28821b532e1febe233272966b5de3ea8a291b0..8617b250b9ecafb804d482b297ff899dde2ea309 100644 (file)
@@ -52,15 +52,15 @@ final class BindingRuntimeTypesFactory implements Mutable {
         // Hidden on purpose
     }
 
-    static @NonNull BindingRuntimeTypes createTypes(final @NonNull EffectiveModelContext context) {
-        final var moduleGens = new GeneratorReactor(context).execute(TypeBuilderFactory.runtime());
+    static @NonNull BindingRuntimeTypes createTypes(final @NonNull EffectiveModelContext modelContext) {
+        final var moduleGens = new GeneratorReactor(modelContext).execute(TypeBuilderFactory.runtime());
 
         final var sw = Stopwatch.createStarted();
         final var factory = new BindingRuntimeTypesFactory();
         factory.indexModules(moduleGens);
         LOG.debug("Indexed {} generators in {}", moduleGens.size(), sw);
 
-        return new DefaultBindingRuntimeTypes(context, factory.modules, factory.allTypes, factory.identities,
+        return new DefaultBindingRuntimeTypes(modelContext, factory.modules, factory.allTypes, factory.identities,
             factory.choiceToCases);
     }
 
index f8ba855ea371e08a279901d981cb8f7de0782c25..1abbcc0d36903a5745feff75036a7dbc4fde2799 100644 (file)
@@ -26,8 +26,8 @@ public class DefaultBindingRuntimeGenerator implements BindingRuntimeGenerator {
     private static final Logger LOG = LoggerFactory.getLogger(DefaultBindingRuntimeGenerator.class);
 
     @Override
-    public BindingRuntimeTypes generateTypeMapping(final EffectiveModelContext context) {
-        return BindingRuntimeTypesFactory.createTypes(context);
+    public BindingRuntimeTypes generateTypeMapping(final EffectiveModelContext modelContext) {
+        return BindingRuntimeTypesFactory.createTypes(modelContext);
     }
 
     @Activate
index a3edbfde57f745c618b980e15a7d2c2ec687d128..92ca3341c03cc44abe9a61e0f5b7165b5df125cf 100644 (file)
@@ -7,6 +7,8 @@
  */
 package org.opendaylight.mdsal.binding.generator.impl.reactor;
 
+import static java.util.Objects.requireNonNull;
+
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -14,14 +16,19 @@ import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.PathExpression;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
-import org.opendaylight.yangtools.yang.model.spi.AbstractEffectiveModelContextProvider;
 
 /**
  * Abstract view on generation tree as viewed by a particular {@link Generator}.
  */
-abstract class GeneratorContext extends AbstractEffectiveModelContextProvider {
+abstract class GeneratorContext {
+    private final @NonNull EffectiveModelContext modelContext;
+
     GeneratorContext(final EffectiveModelContext modelContext) {
-        super(modelContext);
+        this.modelContext = requireNonNull(modelContext);
+    }
+
+    final @NonNull EffectiveModelContext modelContext() {
+        return modelContext;
     }
 
     /**
index a954560bdbf1376b0c69721fef0902b816cf6192..8f4f6c6167ee97d793662dd5f25205d8d9159758 100644 (file)
@@ -37,18 +37,18 @@ import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
  * The result of BindingGenerator run. Contains mapping between Types and SchemaNodes.
  */
 public final class DefaultBindingRuntimeTypes implements BindingRuntimeTypes {
-    private final @NonNull EffectiveModelContext context;
+    private final @NonNull EffectiveModelContext modelContext;
     private final ImmutableSetMultimap<JavaTypeName, CaseRuntimeType> choiceToCases;
     private final ImmutableMap<QNameModule, ModuleRuntimeType> modulesByNamespace;
     private final ImmutableSortedMap<String, ModuleRuntimeType> modulesByPackage;
     private final ImmutableMap<QName, IdentityRuntimeType> identities;
     private final ImmutableMap<JavaTypeName, RuntimeType> types;
 
-    public DefaultBindingRuntimeTypes(final EffectiveModelContext context,
+    public DefaultBindingRuntimeTypes(final EffectiveModelContext modelContext,
             final Map<QNameModule, ModuleRuntimeType> modules, final Map<JavaTypeName, RuntimeType> types,
             final Map<QName, IdentityRuntimeType> identities,
             final SetMultimap<JavaTypeName, CaseRuntimeType> choiceToCases) {
-        this.context = requireNonNull(context);
+        this.modelContext = requireNonNull(modelContext);
         this.identities = ImmutableMap.copyOf(identities);
         this.types = ImmutableMap.copyOf(types);
         this.choiceToCases = ImmutableSetMultimap.copyOf(choiceToCases);
@@ -59,8 +59,8 @@ public final class DefaultBindingRuntimeTypes implements BindingRuntimeTypes {
     }
 
     @Override
-    public EffectiveModelContext getEffectiveModelContext() {
-        return context;
+    public EffectiveModelContext modelContext() {
+        return modelContext;
     }
 
     @Override
index 9c77304381ad9e2051ce1ac198bdc5f32007a604..47f1a0200f553676c3439f111253a5a83d780afc 100644 (file)
@@ -12,29 +12,24 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertSame;
 
 import java.util.Set;
-import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.mdsal.binding.model.api.JavaTypeName;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public class Mdsal829Test {
-    private static EffectiveModelContext CONTEXT;
-
-    @BeforeClass
-    public static void beforeClass() {
-        CONTEXT = YangParserTestUtils.parseYangResource("/mdsal829.yang", Set.of());
-    }
+    private static final EffectiveModelContext MODEL_CONTEXT =
+        YangParserTestUtils.parseYangResource("/mdsal829.yang", Set.of());
 
     @Test
     public void testCompileTimeTypes() {
-        assertEquals(1, DefaultBindingGenerator.generateFor(CONTEXT).size());
+        assertEquals(1, DefaultBindingGenerator.generateFor(MODEL_CONTEXT).size());
     }
 
     @Test
     public void testRunTimeTypes() {
-        final var types = BindingRuntimeTypesFactory.createTypes(CONTEXT);
-        assertSame(CONTEXT, types.getEffectiveModelContext());
+        final var types = BindingRuntimeTypesFactory.createTypes(MODEL_CONTEXT);
+        assertSame(MODEL_CONTEXT, types.modelContext());
         final var schema = types.findSchema(
             JavaTypeName.create("org.opendaylight.yang.gen.v1.mdsal829.norev", "Mdsal829Data")).orElseThrow();
         assertNotNull(schema);
index f890b0a9d46dad3705fa396c8dd1a1bee96145c9..aed52dea0869d61049bba78a4d4a8bf48867884d 100644 (file)
@@ -35,7 +35,7 @@ import org.opendaylight.yangtools.yang.binding.YangModelBindingProvider;
 import org.opendaylight.yangtools.yang.binding.contract.Naming;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.api.source.YangTextSource;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -76,7 +76,7 @@ final class JavaFileGenerator implements FileGenerator {
         final Builder<String> bindingProviders = ImmutableSet.builder();
         for (Module module : localModules) {
             final YangModuleInfoTemplate template = new YangModuleInfoTemplate(module, context,
-                mod -> moduleResourcePathResolver.findModuleResourcePath(mod, YangTextSchemaSource.class));
+                mod -> moduleResourcePathResolver.findModuleResourcePath(mod, YangTextSource.class));
             final String path = DOT_MATCHER.replaceFrom(template.getPackageName(), '/') + "/";
 
             result.put(GeneratedFileType.SOURCE, GeneratedFilePath.ofPath(path + MODULE_INFO),
index c9e3ed1cb8e76c438e9685e50f451ed1ee1589ed..06a9bd48547fa96f0214ec918811f13fd5cf7bf8 100644 (file)
             <groupId>org.opendaylight.yangtools</groupId>
             <artifactId>rfc8040-model-api</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.opendaylight.yangtools</groupId>
-            <artifactId>yang-repo-api</artifactId>
-        </dependency>
         <dependency>
             <groupId>org.opendaylight.yangtools</groupId>
             <artifactId>yang-repo-spi</artifactId>
index 8d9ab777f9b08b2a3c92ca981aa0292ca7fa62bc..e39a79178395cbc8a8d465055d56692f3c45cb18 100644 (file)
@@ -12,7 +12,6 @@ module org.opendaylight.mdsal.binding.runtime.api {
     requires transitive org.opendaylight.yangtools.yang.common;
     requires transitive org.opendaylight.yangtools.yang.model.api;
     requires transitive org.opendaylight.yangtools.yang.binding;
-    requires transitive org.opendaylight.yangtools.yang.repo.api;
     requires transitive org.opendaylight.yangtools.yang.repo.spi;
     requires transitive org.opendaylight.yangtools.rfc8040.model.api;
     requires transitive org.opendaylight.mdsal.binding.model.api;
index 43cd0cb71209b13d8c11207c01357afc56062b15..b9219d34756230a5821a60a342b06702c33b9e7f 100644 (file)
@@ -25,7 +25,6 @@ import org.opendaylight.yangtools.yang.common.YangDataName;
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextProvider;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
 
@@ -35,7 +34,8 @@ import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absol
  */
 @Beta
 // FIXME: refactor return to follow foo()/getFoo()/findFoo() naming
-public interface BindingRuntimeContext extends EffectiveModelContextProvider, Immutable {
+public interface BindingRuntimeContext extends Immutable {
+
     @NonNull BindingRuntimeTypes getTypes();
 
     @NonNull <T> Class<T> loadClass(JavaTypeName type) throws ClassNotFoundException;
@@ -44,9 +44,8 @@ public interface BindingRuntimeContext extends EffectiveModelContextProvider, Im
         return loadClass(type.getIdentifier());
     }
 
-    @Override
-    default EffectiveModelContext getEffectiveModelContext() {
-        return getTypes().getEffectiveModelContext();
+    default @NonNull EffectiveModelContext modelContext() {
+        return getTypes().modelContext();
     }
 
     /**
index a44af58f0d4b3da5aaf7e8753e8312b6b8d811bf..0e6fb1ce415ce9cf0336341baed22e5b372acd82 100644 (file)
@@ -23,8 +23,8 @@ public interface BindingRuntimeGenerator {
      * The EffectiveModelContext MUST contain all of the sub modules otherwise the there is no guarantee that result
      * List of Generated Types will contain correct Generated Types.
      *
-     * @param context Schema Context
+     * @param modelContext effective model context
      * @return Generated type mapping.
      */
-    BindingRuntimeTypes generateTypeMapping(EffectiveModelContext context);
+    BindingRuntimeTypes generateTypeMapping(EffectiveModelContext modelContext);
 }
index 8114e0df1b10bf805cad79053a8c943d0cd3696a..46369f132fca22b391ce95b40fef4e9b52f2bfc8 100644 (file)
@@ -17,14 +17,21 @@ import org.opendaylight.mdsal.binding.model.api.JavaTypeName;
 import org.opendaylight.yangtools.concepts.Immutable;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.YangDataName;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextProvider;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
 
 /**
  * The result of BindingGenerator run. Contains mapping between Types and SchemaNodes.
  */
 @Beta
-public interface BindingRuntimeTypes extends EffectiveModelContextProvider, RuntimeTypeContainer, Immutable {
+public interface BindingRuntimeTypes extends RuntimeTypeContainer, Immutable {
+    /**
+     * Return the {@link EffectiveModelContext} underlying this object.
+     *
+     * @return the {@link EffectiveModelContext} underlying this object
+     */
+    @NonNull EffectiveModelContext modelContext();
+
     /**
      * Lookup {@link IdentityRuntimeType} by its QNamme.
      *
index 733511d47727a636ec297adc318370d5d245ec63..fa70bfb1f69accd2492e45ef5432433921ba407b 100644 (file)
@@ -8,14 +8,24 @@
 package org.opendaylight.mdsal.binding.runtime.api;
 
 import com.google.common.annotations.Beta;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.concepts.Immutable;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextProvider;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.model.api.source.YangTextSource;
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider;
 
+/**
+ * A snapshot of a set of {@link YangModuleInfo}s, assembled to form an {@link EffectiveModelContext}.
+ */
 @Beta
-public interface ModuleInfoSnapshot extends Immutable, EffectiveModelContextProvider,
-        SchemaSourceProvider<YangTextSchemaSource> {
+public interface ModuleInfoSnapshot extends Immutable, SchemaSourceProvider<YangTextSource> {
+    /**
+     * The {@link EffectiveModelContext} resulting from all models exposed from constituent module infos.
+     *
+     * @return the resulting model context
+     */
+    @NonNull EffectiveModelContext modelContext();
 
     <T> Class<T> loadClass(String fullyQualifiedName) throws ClassNotFoundException;
 }
index 4b9982df53936ab062070c4e9f75466f4bd541e7..95dadcd1e108e7cbc96b77ee143e0ea0041cc5e2 100644 (file)
@@ -19,9 +19,7 @@ import java.util.Set;
 import org.checkerframework.checker.lock.qual.GuardedBy;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.mdsal.binding.runtime.api.BindingRuntimeGenerator;
-import org.opendaylight.mdsal.binding.runtime.api.BindingRuntimeTypes;
 import org.opendaylight.mdsal.binding.runtime.api.DefaultBindingRuntimeContext;
-import org.opendaylight.mdsal.binding.runtime.api.ModuleInfoSnapshot;
 import org.opendaylight.mdsal.dom.schema.osgi.OSGiModuleInfoSnapshot;
 import org.osgi.service.component.ComponentFactory;
 import org.osgi.service.component.ComponentInstance;
@@ -101,12 +99,12 @@ public final class OSGiBindingRuntime {
 
         @Override
         void add(final OSGiModuleInfoSnapshot snapshot) {
-            final ModuleInfoSnapshot context = snapshot.getService();
-            final BindingRuntimeTypes types = generator.generateTypeMapping(context.getEffectiveModelContext());
+            final var infoSnapshot = snapshot.getService();
+            final var types = generator.generateTypeMapping(infoSnapshot.modelContext());
 
             instances.put(snapshot, factory.newInstance(OSGiBindingRuntimeContextImpl.props(
                 snapshot.getGeneration(), snapshot.getServiceRanking(),
-                new DefaultBindingRuntimeContext(types, context))));
+                new DefaultBindingRuntimeContext(types, infoSnapshot))));
         }
 
         @Override
index ec3a29dcb480a0fce28e14f60ae5205794823bec..a0ad3891819db4efa503ddcc4c19700d5888fa23 100644 (file)
         <dependency>
             <groupId>org.opendaylight.yangtools</groupId>
             <artifactId>yang-model-api</artifactId>
+        </dependency>
+         <dependency>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>yang-model-spi</artifactId>
         </dependency>
         <dependency>
             <groupId>org.opendaylight.yangtools</groupId>
index ec3c2e23cee6429928d9cb981e0d52c12a026a4b..36e8fba403b5bf3123a0669b18685e77edc1d92f 100644 (file)
@@ -13,6 +13,7 @@ module org.opendaylight.mdsal.binding.runtime.spi {
     requires org.opendaylight.yangtools.concepts;
     requires org.opendaylight.yangtools.util;
     requires org.opendaylight.yangtools.yang.model.api;
+    requires org.opendaylight.yangtools.yang.model.spi;
     requires org.opendaylight.yangtools.yang.parser.impl;
     requires org.opendaylight.mdsal.binding.model.api;
     requires org.opendaylight.mdsal.binding.spec.util;
index ea026071a3b8c8e47ce10528f37bd4dce170d226..e4db5c3d441f88462926c9c125ba3c2ee8056275 100644 (file)
@@ -55,7 +55,7 @@ public final class BindingRuntimeHelpers {
 
     public static @NonNull EffectiveModelContext createEffectiveModel(final YangParserFactory parserFactory,
             final Iterable<? extends YangModuleInfo> moduleInfos) throws YangParserException {
-        return prepareContext(parserFactory, moduleInfos).getEffectiveModelContext();
+        return prepareContext(parserFactory, moduleInfos).modelContext();
     }
 
     public static @NonNull BindingRuntimeContext createRuntimeContext() {
@@ -66,7 +66,7 @@ public final class BindingRuntimeHelpers {
             throw new IllegalStateException("Failed to parse models", e);
         }
         return new DefaultBindingRuntimeContext(ServiceLoaderState.Generator.INSTANCE.generateTypeMapping(
-            infos.getEffectiveModelContext()), infos);
+            infos.modelContext()), infos);
     }
 
     public static @NonNull BindingRuntimeContext createRuntimeContext(final Class<?>... classes) {
@@ -89,7 +89,7 @@ public final class BindingRuntimeHelpers {
         }
 
         return new DefaultBindingRuntimeContext(
-            ServiceLoaderState.Generator.INSTANCE.generateTypeMapping(snapshot.getEffectiveModelContext()), snapshot);
+            ServiceLoaderState.Generator.INSTANCE.generateTypeMapping(snapshot.modelContext()), snapshot);
     }
 
     public static @NonNull BindingRuntimeContext createRuntimeContext(final YangParserFactory parserFactory,
@@ -99,10 +99,10 @@ public final class BindingRuntimeHelpers {
 
     public static @NonNull BindingRuntimeContext createRuntimeContext(final YangParserFactory parserFactory,
             final BindingRuntimeGenerator generator, final Collection<Class<?>> classes) throws YangParserException {
-        final ModuleInfoSnapshot infos = prepareContext(parserFactory, classes.stream()
+        final var infos = prepareContext(parserFactory, classes.stream()
             .map(BindingRuntimeHelpers::getYangModuleInfo)
             .collect(Collectors.toList()));
-        return new DefaultBindingRuntimeContext(generator.generateTypeMapping(infos.getEffectiveModelContext()), infos);
+        return new DefaultBindingRuntimeContext(generator.generateTypeMapping(infos.modelContext()), infos);
     }
 
     public static @NonNull YangModuleInfo getYangModuleInfo(final Class<?> clazz) {
index d5f4971a98cb0fcebcbffb49f3115064492a9310..94298c1bb1bae829a7640a8899e3207d7baf22f3 100644 (file)
@@ -18,47 +18,45 @@ import org.opendaylight.mdsal.binding.runtime.api.ModuleInfoSnapshot;
 import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
 import org.opendaylight.yangtools.yang.binding.contract.Naming;
 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.repo.api.MissingSchemaSourceException;
-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;
 
 final class DefaultModuleInfoSnapshot implements ModuleInfoSnapshot {
     private final ImmutableMap<SourceIdentifier, YangModuleInfo> moduleInfos;
     private final ImmutableMap<String, ClassLoader> classLoaders;
-    private final @NonNull EffectiveModelContext effectiveModel;
+    private final @NonNull EffectiveModelContext modelContext;
 
-    DefaultModuleInfoSnapshot(final EffectiveModelContext effectiveModel,
+    DefaultModuleInfoSnapshot(final EffectiveModelContext modelContext,
             final Map<SourceIdentifier, YangModuleInfo> moduleInfos, final Map<String, ClassLoader> classLoaders) {
-        this.effectiveModel = requireNonNull(effectiveModel);
+        this.modelContext = requireNonNull(modelContext);
         this.moduleInfos = ImmutableMap.copyOf(moduleInfos);
         this.classLoaders = ImmutableMap.copyOf(classLoaders);
     }
 
     @Override
-    public EffectiveModelContext getEffectiveModelContext() {
-        return effectiveModel;
+    public EffectiveModelContext modelContext() {
+        return modelContext;
     }
 
     @Override
-    public ListenableFuture<? extends YangTextSchemaSource> getSource(final SourceIdentifier sourceIdentifier) {
-        final YangModuleInfo info = moduleInfos.get(sourceIdentifier);
-        if (info == null) {
-            return Futures.immediateFailedFuture(
-                new MissingSchemaSourceException("No source registered", sourceIdentifier));
-        }
-        return Futures.immediateFuture(YangTextSchemaSource.delegateForCharSource(sourceIdentifier,
-                    info.getYangTextCharSource()));
+    public ListenableFuture<? extends YangTextSource> getSource(final SourceIdentifier sourceId) {
+        final var info = moduleInfos.get(sourceId);
+        return info == null
+            ? Futures.immediateFailedFuture(new MissingSchemaSourceException(sourceId, "No source registered"))
+                : Futures.immediateFuture(new DelegatedYangTextSource(sourceId, info.getYangTextCharSource()));
     }
 
     @Override
     public <T> Class<T> loadClass(final String fullyQualifiedName) throws ClassNotFoundException {
-        final String packageName = Naming.getModelRootPackageName(fullyQualifiedName);
-        final ClassLoader loader = classLoaders.get(packageName);
+        final var packageName = Naming.getModelRootPackageName(fullyQualifiedName);
+        final var loader = classLoaders.get(packageName);
         if (loader == null) {
             throw new ClassNotFoundException("Package " + packageName + " not found");
         }
         @SuppressWarnings("unchecked")
-        final Class<T> loaded = (Class<T>) loader.loadClass(fullyQualifiedName);
+        final var loaded = (Class<T>) loader.loadClass(fullyQualifiedName);
         return loaded;
     }
 }
index 90454856ee7d5356d8af7d8afffe9901378cd5db..1564797e7e51908819449b7fad3260030120a627 100644 (file)
@@ -13,8 +13,8 @@ import com.google.common.util.concurrent.ListenableFuture;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.mdsal.binding.runtime.api.ModuleInfoSnapshot;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
-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.YangTextSource;
 
 @Beta
 public abstract class ForwardingModuleInfoSnapshot extends ForwardingObject implements ModuleInfoSnapshot {
@@ -27,12 +27,12 @@ public abstract class ForwardingModuleInfoSnapshot extends ForwardingObject impl
     }
 
     @Override
-    public @NonNull EffectiveModelContext getEffectiveModelContext() {
-        return delegate().getEffectiveModelContext();
+    public @NonNull EffectiveModelContext modelContext() {
+        return delegate().modelContext();
     }
 
     @Override
-    public ListenableFuture<? extends YangTextSchemaSource> getSource(final SourceIdentifier sourceIdentifier) {
+    public ListenableFuture<? extends YangTextSource> getSource(final SourceIdentifier sourceIdentifier) {
         return delegate().getSource(sourceIdentifier);
     }
 }
index b4cce3390cd1ab61a8dc6904ff81521114ee665d..363cdab4a37cfc42144e32c027c95ed7c6fa55d4 100644 (file)
@@ -29,8 +29,8 @@ 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.QNameModule;
+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.api.YangParser;
 import org.opendaylight.yangtools.yang.parser.api.YangParserException;
 import org.opendaylight.yangtools.yang.parser.api.YangParserFactory;
@@ -107,7 +107,7 @@ public final class ModuleInfoSnapshotBuilder {
 
         for (var info : moduleInfos) {
             final var source = ModuleInfoSnapshotResolver.toYangTextSource(info);
-            mappedInfos.put(source.getIdentifier(), info);
+            mappedInfos.put(source.sourceId(), info);
 
             final Class<?> infoClass = info.getClass();
             final String infoRoot = Naming.getModelRootPackageName(infoClass.getPackage().getName());
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) {
index 69306a65fcede737bb7bab7534584e99e1341b21..babc6783d94784d5940e0fefd9c582a7d424506b 100644 (file)
@@ -7,40 +7,31 @@
  */
 package org.opendaylight.mdsal.binding.runtime.spi;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
-import java.util.Map;
 import java.util.Set;
-import org.junit.Test;
-import org.opendaylight.mdsal.binding.runtime.api.ModuleInfoSnapshot;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yang.gen.v1.mdsal767.norev.$YangModuleInfoImpl;
 import org.opendaylight.yang.gen.v1.mdsal767.norev.Mdsal767Data;
 import org.opendaylight.yang.gen.v1.mdsal767.norev.One$F;
 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.api.EffectiveModelContext;
-import org.opendaylight.yangtools.yang.model.api.stmt.FeatureEffectiveStatement;
-import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement;
-import org.opendaylight.yangtools.yang.parser.api.YangParserException;
-import org.opendaylight.yangtools.yang.parser.api.YangParserFactory;
 import org.opendaylight.yangtools.yang.parser.impl.DefaultYangParserFactory;
 
-public class ModuleInfoSnapshotBuilderTest {
-    private static final YangParserFactory PARSER_FACTORY = new DefaultYangParserFactory();
-
+class ModuleInfoSnapshotBuilderTest {
     @Test
-    public void testModuleRegistration() throws YangParserException {
-        final ModuleInfoSnapshotBuilder snapshotBuilder = new ModuleInfoSnapshotBuilder(PARSER_FACTORY);
+    void testModuleRegistration() throws Exception {
+        final var snapshotBuilder = new ModuleInfoSnapshotBuilder(new DefaultYangParserFactory());
         snapshotBuilder.add($YangModuleInfoImpl.getInstance());
         snapshotBuilder.addModuleFeatures(Mdsal767Data.class, Set.of(One$F.VALUE));
 
-        final ModuleInfoSnapshot snapshot = snapshotBuilder.build();
-        final EffectiveModelContext modelContext = snapshot.getEffectiveModelContext();
-        final Map<QNameModule, ModuleEffectiveStatement> modules = modelContext.getModuleStatements();
-        final ModuleEffectiveStatement module = modules.get(QNameModule.create(XMLNamespace.of("mdsal767")));
+        final var snapshot = snapshotBuilder.build();
+        final var modelContext = snapshot.modelContext();
+        final var modules = modelContext.getModuleStatements();
+        final var module = modules.get(QNameModule.create(XMLNamespace.of("mdsal767")));
         assertEquals(1, module.features().size());
-        final FeatureEffectiveStatement feature = module.features().stream().findAny().orElseThrow();
+        final var feature = module.features().stream().findAny().orElseThrow();
         assertEquals(QName.create("mdsal767", "one"), feature.argument());
     }
 }
index 6d87d67129871715f28b6fe2276d72024d2cba33..79a86e25161d2164159a9bbddbbb2274b76b68a7 100644 (file)
@@ -9,13 +9,14 @@ package org.opendaylight.mdsal.binding.testutils;
 
 import com.google.common.annotations.Beta;
 import com.google.common.base.Throwables;
+import java.util.function.Supplier;
 import org.opendaylight.mdsal.binding.api.DataBroker;
 import org.opendaylight.mdsal.binding.dom.adapter.CurrentAdapterSerializer;
 import org.opendaylight.mdsal.binding.dom.adapter.test.AbstractConcurrentDataBrokerTest;
 import org.opendaylight.mdsal.dom.api.DOMDataBroker;
 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
 import org.opendaylight.mdsal.dom.broker.DOMNotificationRouter;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextProvider;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 
 @Beta
 public class DataBrokerTestModule {
@@ -65,7 +66,7 @@ public class DataBrokerTestModule {
         return dataBrokerTest.getDataBrokerTestCustomizer().getSchemaService();
     }
 
-    public EffectiveModelContextProvider getSchemaContextProvider() {
+    public Supplier<EffectiveModelContext> getModelContextSupplier() {
         return dataBrokerTest.getDataBrokerTestCustomizer().getSchemaService()::getGlobalContext;
     }
 }
index d1db0ff01151ce27bce769f1c5f1ab27c10e58ab..1dbb8ae3884334c5a5cf588037f2e3f18e34162a 100644 (file)
                         <link>https://commons.apache.org/proper/commons-lang/javadocs/api-release/</link>
 
                         <link>https://www.javadoc.io/doc/org.opendaylight.odlparent/odlparent-docs/13.0.10/</link>
-                        <link>https://www.javadoc.io/doc/org.opendaylight.yangtools/yangtools-docs/11.0.5/</link>
+                        <link>https://www.javadoc.io/doc/org.opendaylight.yangtools/yangtools-docs/13.0.0/</link>
                     </links>
                     <groups>
                         <group>
index 2df5ffd31a26030adf37e08dcac358b638cfbe25..7aaaa62de666d0c52f9250791e27b2bcb35225f3 100644 (file)
@@ -29,7 +29,7 @@
             <dependency>
                 <groupId>org.opendaylight.yangtools</groupId>
                 <artifactId>yangtools-artifacts</artifactId>
-                <version>11.0.5</version>
+                <version>13.0.0</version>
                 <type>pom</type>
                 <scope>import</scope>
             </dependency>
index 33e30eb1204146ab258ceb3af1d74472bfccc65d..37d322d84e220e619419db5e3e56ef1b2c4621bc 100644 (file)
@@ -73,7 +73,7 @@
         </dependency>
         <dependency>
             <groupId>org.opendaylight.yangtools</groupId>
-            <artifactId>yang-repo-api</artifactId>
+            <artifactId>yang-model-spi</artifactId>
         </dependency>
         <dependency>
             <groupId>org.opendaylight.yangtools</groupId>
index 96c88e0be4ca1ad4b47d23eeeb8869671ea4eeda..dad7ab6946865553d51f0b74e085a6229fb57d9f 100644 (file)
@@ -14,7 +14,7 @@ module org.opendaylight.mdsal.dom.api {
     requires transitive org.opendaylight.yangtools.yang.data.api;
     requires transitive org.opendaylight.yangtools.yang.data.tree.api;
     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.yang.repo.spi;
     requires transitive org.opendaylight.mdsal.common.api;
     requires transitive org.opendaylight.yangtools.concepts;
index b8022ce455bf03079749cf1613bd499d495f7e3a..8770f96f204975a2227262285348876866875970 100644 (file)
@@ -7,11 +7,12 @@
  */
 package org.opendaylight.mdsal.dom.api;
 
-import org.eclipse.jdt.annotation.NonNull;
+import java.util.function.Consumer;
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.opendaylight.yangtools.concepts.Registration;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener;
 
+@NonNullByDefault
 public interface DOMSchemaService extends DOMService<DOMSchemaService, DOMSchemaService.Extension> {
     /**
      * Type capture of a {@link DOMService.Extension} applicable to {@link DOMSchemaService} implementations.
@@ -34,5 +35,5 @@ public interface DOMSchemaService extends DOMService<DOMSchemaService, DOMSchema
      * @return Listener registration handle
      * @throws NullPointerException if {@code listener} is {@code null}
      */
-    @NonNull Registration registerSchemaContextListener(EffectiveModelContextListener listener);
+    Registration registerSchemaContextListener(Consumer<EffectiveModelContext> listener);
 }
index 0f13330889362016b1548c297888c4cdac802bd0..c547b94f6a58298b8301ed4b3e90c5198f23265b 100644 (file)
@@ -8,15 +8,15 @@
 package org.opendaylight.mdsal.dom.api;
 
 import com.google.common.annotations.Beta;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.api.source.YangTextSource;
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider;
 
 /**
- * A {@link DOMSchemaService.Extension} exposing access to {@link YangTextSchemaSource}. Instances of this method should
+ * A {@link DOMSchemaService.Extension} exposing access to {@link YangTextSource}. Instances of this method should
  * be acquired from {@link DOMSchemaService}.
  */
 @Beta
 public interface DOMYangTextSourceProvider
-        extends DOMSchemaService.Extension, SchemaSourceProvider<YangTextSchemaSource> {
+        extends DOMSchemaService.Extension, SchemaSourceProvider<YangTextSource> {
 
 }
index da6c07040d88e071bed986ed5d4626a8195a6a5a..1ccdb90429ad2af13e108d95572fe9eb05a10f88 100644 (file)
@@ -75,7 +75,7 @@
         </dependency>
         <dependency>
             <groupId>org.opendaylight.yangtools</groupId>
-            <artifactId>yang-repo-api</artifactId>
+            <artifactId>yang-model-spi</artifactId>
         </dependency>
         <dependency>
             <groupId>com.guicedee.services</groupId>
index 3b6587a80285a68bdfb22af085506872a8a4ce40..a8daf7fe9129c47d214d7eca1818b98540569502 100644 (file)
@@ -62,7 +62,6 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener;
 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
 import org.osgi.service.component.annotations.Activate;
 import org.osgi.service.component.annotations.Component;
@@ -73,7 +72,7 @@ import org.slf4j.LoggerFactory;
 
 @Singleton
 @Component(service = DOMRpcRouter.class)
-public final class DOMRpcRouter extends AbstractRegistration implements EffectiveModelContextListener {
+public final class DOMRpcRouter extends AbstractRegistration {
     private static final Logger LOG = LoggerFactory.getLogger(DOMRpcRouter.class);
     private static final ThreadFactory THREAD_FACTORY = new ThreadFactoryBuilder().setNameFormat(
             "DOMRpcRouter-listener-%s").setDaemon(true).build();
@@ -106,7 +105,7 @@ public final class DOMRpcRouter extends AbstractRegistration implements Effectiv
     @Inject
     @Activate
     public DOMRpcRouter(@Reference final DOMSchemaService schemaService) {
-        listenerRegistration = schemaService.registerSchemaContextListener(this);
+        listenerRegistration = schemaService.registerSchemaContextListener(this::onModelContextUpdated);
         LOG.info("DOM RPC/Action router started");
     }
 
@@ -209,8 +208,8 @@ public final class DOMRpcRouter extends AbstractRegistration implements Effectiv
         }
     }
 
-    @Override
-    public synchronized void onModelContextUpdated(final EffectiveModelContext newModelContext) {
+
+    synchronized void onModelContextUpdated(final @NonNull EffectiveModelContext newModelContext) {
         final DOMRpcRoutingTable oldTable = routingTable;
         final DOMRpcRoutingTable newTable = (DOMRpcRoutingTable) oldTable.setSchemaContext(newModelContext);
         routingTable = newTable;
index 22f77b047101ffacaf8ede1f2b385a39100991ab..6182099b024ca9e8b5b85dc694e0ce45a5733324 100644 (file)
@@ -11,7 +11,9 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.yang.extension.yang.ext.rev130709.$YangModuleInfoImpl;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
-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.DelegatedYangTextSource;
+import org.opendaylight.yangtools.yang.model.spi.source.URLYangTextSource;
 import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
@@ -19,9 +21,9 @@ import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 final class Rpcs {
     static final EffectiveModelContext CONTEXT = YangParserTestUtils.parseYangSources(YangParserConfiguration.DEFAULT,
         null,
-        YangTextSchemaSource.delegateForCharSource("yang-ext.yang",
+        new DelegatedYangTextSource(new SourceIdentifier("yang-ext.yang"),
             $YangModuleInfoImpl.getInstance().getYangTextCharSource()),
-        YangTextSchemaSource.forResource(Rpcs.class, "/rpcs.yang"));
+        new URLYangTextSource(Rpcs.class.getResource("/rpcs.yang")));
 
     static final QName FOO = QName.create("rpcs", "foo");
     static final QName BAR = QName.create(FOO, "bar");
index 15f5fde879ec3326bb1552548b09bfe024e9b260..abcfd7a9656900624313e9cbe17531fef3f5150d 100644 (file)
@@ -37,7 +37,6 @@ import org.opendaylight.yangtools.yang.data.tree.api.DataTreeSnapshot;
 import org.opendaylight.yangtools.yang.data.tree.api.DataValidationFailedException;
 import org.opendaylight.yangtools.yang.data.tree.impl.di.InMemoryDataTreeFactory;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -47,7 +46,7 @@ import org.slf4j.LoggerFactory;
  * {@link org.opendaylight.mdsal.dom.spi.store.SnapshotBackedReadTransaction} to implement {@link DOMStore} contract.
  */
 public class InMemoryDOMDataStore extends TransactionReadyPrototype<String> implements DOMStore,
-        Identifiable<String>, EffectiveModelContextListener, AutoCloseable, DOMStoreTreeChangePublisher {
+        Identifiable<String>, AutoCloseable, DOMStoreTreeChangePublisher {
     private static final Logger LOG = LoggerFactory.getLogger(InMemoryDOMDataStore.class);
 
     private final AtomicLong txCounter = new AtomicLong(0);
@@ -97,6 +96,10 @@ public class InMemoryDOMDataStore extends TransactionReadyPrototype<String> impl
         return name;
     }
 
+    public final synchronized void onModelContextUpdated(final EffectiveModelContext newModelContext) {
+        dataTree.setEffectiveModelContext(newModelContext);
+    }
+
     @Override
     public DOMStoreReadTransaction newReadOnlyTransaction() {
         return SnapshotBackedTransactions.newReadTransaction(nextIdentifier(), debugTransactions,
@@ -120,11 +123,6 @@ public class InMemoryDOMDataStore extends TransactionReadyPrototype<String> impl
         return new DOMStoreTransactionChainImpl(this);
     }
 
-    @Override
-    public synchronized void onModelContextUpdated(final EffectiveModelContext newModelContext) {
-        dataTree.setEffectiveModelContext(newModelContext);
-    }
-
     @SuppressWarnings("checkstyle:IllegalCatch")
     @Override
     public void close() {
index 0db38fe3aa3df5c1188640391edf05c15507544c..f780b4cbbc40aa5bb40188284d2ab22b56e8b019 100644 (file)
@@ -50,7 +50,7 @@ public final class InMemoryDOMDataStoreFactory {
             properties.getMaxDataChangeListenerQueueSize(), properties.getDebugTransactions());
 
         if (schemaService != null) {
-            schemaService.registerSchemaContextListener(dataStore);
+            schemaService.registerSchemaContextListener(dataStore::onModelContextUpdated);
         }
 
         return dataStore;
index d774f698c6c498545ebad06210689b82cf48cb90..86ce3e5d23372938c377f36b200a28ba83c7ea7e 100644 (file)
@@ -7,43 +7,45 @@
  */
 package org.opendaylight.mdsal.dom.store.inmemory;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.atLeast;
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 
-import org.junit.Test;
+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.mdsal.dom.api.DOMDataTreeChangeListener;
 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener;
 
-public class InMemoryDOMDataStoreFactoryTest {
+@ExtendWith(MockitoExtension.class)
+class InMemoryDOMDataStoreFactoryTest {
+    @Mock
+    private DOMSchemaService domSchemaService;
+    @Mock
+    private DOMDataTreeChangeListener domDataTreeChangeListener;
+    @Mock
+    private AutoCloseable autoCloseable;
 
     @Test
     public void basicTest() throws Exception {
         final String testStoreName = "TestStore";
-        final DOMSchemaService domSchemaService = mock(DOMSchemaService.class);
-        doReturn(null).when(domSchemaService).registerSchemaContextListener(any(EffectiveModelContextListener.class));
+        doReturn(null).when(domSchemaService).registerSchemaContextListener(any());
 
-        final InMemoryDOMDataStore inMemoryDOMDataStore =
-                InMemoryDOMDataStoreFactory.create(testStoreName, domSchemaService);
+        final var inMemoryDOMDataStore = InMemoryDOMDataStoreFactory.create(testStoreName, domSchemaService);
         assertNotNull(inMemoryDOMDataStore);
         assertEquals(testStoreName, inMemoryDOMDataStore.getIdentifier());
 
-        final DOMDataTreeChangeListener domDataTreeChangeListener = mock(DOMDataTreeChangeListener.class);
-        doReturn("testListener").when(domDataTreeChangeListener).toString();
-        doNothing().when(domDataTreeChangeListener).onDataTreeChanged(any());
         doNothing().when(domDataTreeChangeListener).onInitialData();
         inMemoryDOMDataStore.onModelContextUpdated(TestModel.createTestContext());
         inMemoryDOMDataStore.registerTreeChangeListener(YangInstanceIdentifier.of(), domDataTreeChangeListener);
 
-        final AutoCloseable autoCloseable = mock(AutoCloseable.class);
         doNothing().when(autoCloseable).close();
         inMemoryDOMDataStore.setCloseable(autoCloseable);
         inMemoryDOMDataStore.close();
index accfeb6e607e1fd52179f312c674c6a45eef9d0b..af320a17b2c9f89e580c656d40351ff5a071744e 100644 (file)
@@ -22,7 +22,7 @@
     <dependencies>
         <dependency>
             <groupId>org.opendaylight.mdsal</groupId>
-            <artifactId>mdsal-dom-spi</artifactId>
+            <artifactId>mdsal-dom-api</artifactId>
         </dependency>
         <dependency>
             <groupId>org.opendaylight.mdsal</groupId>
index 464e8b18db1b0dba0fdbed3c88ca9d62a040cad7..48f5d80afff7df6b919793d165109eb6a89b9ab3 100644 (file)
@@ -11,7 +11,7 @@ module org.opendaylight.mdsal.dom.schema.osgi {
     requires transitive com.google.common;
     requires transitive org.opendaylight.mdsal.binding.runtime.api;
     requires org.opendaylight.mdsal.binding.runtime.spi;
-    requires org.opendaylight.mdsal.dom.spi;
+    requires org.opendaylight.mdsal.dom.api;
     requires org.opendaylight.yangtools.yang.binding;
     requires org.opendaylight.yangtools.yang.model.api;
     requires org.opendaylight.yangtools.yang.parser.api;
@@ -23,4 +23,4 @@ module org.opendaylight.mdsal.dom.schema.osgi {
     // Annotations
     requires static org.apache.karaf.features.core;
     requires static org.osgi.service.component.annotations;
-}
\ No newline at end of file
+}
similarity index 57%
rename from dom/mdsal-dom-schema-osgi/src/main/java/org/opendaylight/mdsal/dom/schema/osgi/impl/EffectiveModelContextImpl.java
rename to dom/mdsal-dom-schema-osgi/src/main/java/org/opendaylight/mdsal/dom/schema/osgi/impl/ModelContextListener.java
index c790345e2a9dc00c4f90496baf26392fb8adbe4f..14dc0e9e52cd5fc22c54146f92f8deb2a3b4c810 100644 (file)
@@ -12,34 +12,29 @@ import static com.google.common.base.Verify.verifyNotNull;
 import com.google.common.annotations.VisibleForTesting;
 import java.util.Dictionary;
 import java.util.Map;
+import java.util.function.Consumer;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener;
 import org.osgi.framework.FrameworkUtil;
 import org.osgi.service.component.annotations.Activate;
 import org.osgi.service.component.annotations.Component;
 import org.osgi.service.component.annotations.Deactivate;
 
 /**
- * A Factory Component which implements {@link EffectiveModelContextListener}. Instances of this component are created
- * through by {@link OSGiDOMSchemaService} each time a listener is registered.
+ * A Factory Component for OSGi SR manifestation of a {@code Consumer<EffectiveModelContext>}. Instances of this
+ * component are created through by {@link OSGiDOMSchemaService} each time a listener is registered.
  */
-@Component(factory = EffectiveModelContextImpl.FACTORY_NAME, service = EffectiveModelContextListener.class)
-public final class EffectiveModelContextImpl implements EffectiveModelContextListener {
+@Component(factory = ModelContextListener.FACTORY_NAME, service = ModelContextListener.class)
+public final class ModelContextListener {
     static final String FACTORY_NAME = "org.opendaylight.mdsal.dom.schema.osgi.impl.SchemaSchemaContextListener";
 
     @VisibleForTesting
     static final String DELEGATE = "org.opendaylight.mdsal.dom.schema.osgi.SchemaSchemaContextListener";
 
-    private EffectiveModelContextListener delegate = null;
-
-    @Override
-    public void onModelContextUpdated(final EffectiveModelContext newModelContext) {
-        delegate.onModelContextUpdated(newModelContext);
-    }
+    private Consumer<EffectiveModelContext> delegate = null;
 
     @Activate
-    void activate(final Map<String, ?> properties) {
-        delegate = (EffectiveModelContextListener) verifyNotNull(properties.get(DELEGATE));
+    public ModelContextListener(final Map<String, ?> properties) {
+        delegate = (Consumer<EffectiveModelContext>) verifyNotNull(properties.get(DELEGATE));
     }
 
     @Deactivate
@@ -47,7 +42,11 @@ public final class EffectiveModelContextImpl implements EffectiveModelContextLis
         delegate = null;
     }
 
-    static Dictionary<String, ?> props(final EffectiveModelContextListener delegate) {
+    void onModelContextUpdated(final EffectiveModelContext newModelContext) {
+        delegate.accept(newModelContext);
+    }
+
+    static Dictionary<String, ?> props(final Consumer<EffectiveModelContext> delegate) {
         return FrameworkUtil.asDictionary(Map.of(DELEGATE, delegate));
     }
 }
index 0512f65cbe890b50a17cf4972574d6d9b7c1cdf9..a1ace089a0279b82e352dcfa8e9565ada4d1b4ae 100644 (file)
@@ -13,17 +13,17 @@ import com.google.common.util.concurrent.ListenableFuture;
 import java.util.List;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.atomic.AtomicReference;
+import java.util.function.Consumer;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.mdsal.binding.runtime.api.ModuleInfoSnapshot;
 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
+import org.opendaylight.mdsal.dom.api.DOMYangTextSourceProvider;
 import org.opendaylight.mdsal.dom.schema.osgi.OSGiModuleInfoSnapshot;
-import org.opendaylight.mdsal.dom.spi.AbstractDOMSchemaService;
 import org.opendaylight.yangtools.concepts.AbstractRegistration;
 import org.opendaylight.yangtools.concepts.Registration;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener;
-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.YangTextSource;
 import org.osgi.service.component.ComponentFactory;
 import org.osgi.service.component.annotations.Activate;
 import org.osgi.service.component.annotations.Component;
@@ -39,20 +39,19 @@ import org.slf4j.LoggerFactory;
  * OSGi Service Registry-backed implementation of {@link DOMSchemaService}.
  */
 @Component(service = DOMSchemaService.class, immediate = true)
-public final class OSGiDOMSchemaService extends AbstractDOMSchemaService.WithYangTextSources {
+public final class OSGiDOMSchemaService implements DOMSchemaService, DOMYangTextSourceProvider {
     private static final Logger LOG = LoggerFactory.getLogger(OSGiDOMSchemaService.class);
 
-
-    private final List<EffectiveModelContextListener> listeners = new CopyOnWriteArrayList<>();
+    private final List<Consumer<EffectiveModelContext>> listeners = new CopyOnWriteArrayList<>();
     private final AtomicReference<ModuleInfoSnapshot> currentSnapshot = new AtomicReference<>();
-    private final ComponentFactory<EffectiveModelContextImpl> listenerFactory;
+    private final ComponentFactory<ModelContextListener> listenerFactory;
 
     private boolean deactivated;
 
     @Activate
     public OSGiDOMSchemaService(
-            @Reference(target = "(component.factory=" + EffectiveModelContextImpl.FACTORY_NAME + ")")
-            final ComponentFactory<EffectiveModelContextImpl> listenerFactory) {
+            @Reference(target = "(component.factory=" + ModelContextListener.FACTORY_NAME + ")")
+            final ComponentFactory<ModelContextListener> listenerFactory) {
         this.listenerFactory = requireNonNull(listenerFactory);
         LOG.info("DOM Schema services activated");
     }
@@ -67,7 +66,7 @@ public final class OSGiDOMSchemaService extends AbstractDOMSchemaService.WithYan
     void bindSnapshot(final OSGiModuleInfoSnapshot newContext) {
         LOG.info("Updating context to generation {}", newContext.getGeneration());
         final var snapshot = newContext.getService();
-        final var modelContext = snapshot.getEffectiveModelContext();
+        final var modelContext = snapshot.modelContext();
         final var previous = currentSnapshot.getAndSet(snapshot);
         LOG.debug("Snapshot updated from {} to {}", previous, snapshot);
 
@@ -83,25 +82,25 @@ public final class OSGiDOMSchemaService extends AbstractDOMSchemaService.WithYan
 
     @Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC,
             policyOption = ReferencePolicyOption.GREEDY)
-    void addListener(final EffectiveModelContextListener listener) {
+    void addListener(final Consumer<EffectiveModelContext> listener) {
         LOG.trace("Adding listener {}", listener);
         listeners.add(listener);
-        listener.onModelContextUpdated(getGlobalContext());
+        listener.accept(getGlobalContext());
     }
 
-    void removeListener(final EffectiveModelContextListener listener) {
+    void removeListener(final Consumer<EffectiveModelContext> listener) {
         LOG.trace("Removing listener {}", listener);
         listeners.remove(listener);
     }
 
     @Override
     public @NonNull EffectiveModelContext getGlobalContext() {
-        return currentSnapshot.get().getEffectiveModelContext();
+        return currentSnapshot.get().modelContext();
     }
 
     @Override
-    public Registration registerSchemaContextListener(final EffectiveModelContextListener listener) {
-        final var reg = listenerFactory.newInstance(EffectiveModelContextImpl.props(listener));
+    public Registration registerSchemaContextListener(final Consumer<EffectiveModelContext> listener) {
+        final var reg = listenerFactory.newInstance(ModelContextListener.props(listener));
         return new AbstractRegistration() {
             @Override
             protected void removeRegistration() {
@@ -111,15 +110,15 @@ public final class OSGiDOMSchemaService extends AbstractDOMSchemaService.WithYan
     }
 
     @Override
-    public ListenableFuture<? extends YangTextSchemaSource> getSource(final SourceIdentifier sourceIdentifier) {
+    public ListenableFuture<? extends YangTextSource> getSource(final SourceIdentifier sourceIdentifier) {
         return currentSnapshot.get().getSource(sourceIdentifier);
     }
 
     @SuppressWarnings("checkstyle:illegalCatch")
     private static void notifyListener(final @NonNull EffectiveModelContext modelContext,
-            final EffectiveModelContextListener listener) {
+            final Consumer<EffectiveModelContext> listener) {
         try {
-            listener.onModelContextUpdated(modelContext);
+            listener.accept(modelContext);
         } catch (RuntimeException e) {
             LOG.warn("Failed to notify listener {}", listener, e);
         }
diff --git a/dom/mdsal-dom-spi/src/main/java/org/opendaylight/mdsal/dom/spi/AbstractDOMSchemaService.java b/dom/mdsal-dom-spi/src/main/java/org/opendaylight/mdsal/dom/spi/AbstractDOMSchemaService.java
deleted file mode 100644 (file)
index cd3e663..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2019 Red Hat, Inc. 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
- */
-package org.opendaylight.mdsal.dom.spi;
-
-import java.util.List;
-import org.opendaylight.mdsal.dom.api.DOMSchemaService;
-import org.opendaylight.mdsal.dom.api.DOMYangTextSourceProvider;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextProvider;
-
-/**
- * Base class to implement DOMSchemaService more easily while providing a bridge between MD-SAL DOM Schema services
- * and YANG Tools Schema consumers.
- *
- * @author Michael Vorburger.ch
- */
-public abstract class AbstractDOMSchemaService implements DOMSchemaService, EffectiveModelContextProvider {
-    public abstract static class WithYangTextSources extends AbstractDOMSchemaService
-            implements DOMYangTextSourceProvider {
-        @Override
-        public List<Extension> supportedExtensions() {
-            return List.of(this);
-        }
-    }
-
-    @Override
-    public final EffectiveModelContext getEffectiveModelContext() {
-        final var ret = getGlobalContext();
-        if (ret == null) {
-            throw new IllegalStateException("Global context is not available in " + this);
-        }
-        return ret;
-    }
-}
index 42b364665a6864a7602dea3786d44b221ee2e513..c2d49c449237274506249139283002e760e31328 100644 (file)
@@ -12,32 +12,33 @@ import static java.util.Objects.requireNonNull;
 import com.google.common.annotations.Beta;
 import com.google.common.util.concurrent.ListenableFuture;
 import java.util.List;
-import org.eclipse.jdt.annotation.NonNull;
+import java.util.function.Consumer;
+import java.util.function.Supplier;
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
 import org.opendaylight.mdsal.dom.api.DOMYangTextSourceProvider;
 import org.opendaylight.yangtools.concepts.Registration;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextProvider;
-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.YangTextSource;
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider;
 
 /**
  * {@link DOMSchemaService} (and {@link DOMYangTextSourceProvider}) implementations backed by a
- * {@link EffectiveModelContextProvider} (and {@link SchemaSourceProvider}) which are known to be fixed and never change
- * schemas.
+ * {@code Supplier<EffectiveModelContext>} (and {@link SchemaSourceProvider}) which are known to be fixed and never
+ * change schemas.
  *
  * @author Michael Vorburger.ch
  */
 @Beta
-public class FixedDOMSchemaService extends AbstractDOMSchemaService {
+@NonNullByDefault
+public sealed class FixedDOMSchemaService implements DOMSchemaService {
     private static final class WithYangTextSources extends FixedDOMSchemaService implements DOMYangTextSourceProvider {
-        private final @NonNull SchemaSourceProvider<YangTextSchemaSource> schemaSourceProvider;
+        private final SchemaSourceProvider<YangTextSource> schemaSourceProvider;
 
-        WithYangTextSources(final EffectiveModelContextProvider schemaContextProvider,
-                final SchemaSourceProvider<YangTextSchemaSource> schemaSourceProvider) {
-            super(schemaContextProvider);
+        WithYangTextSources(final Supplier<EffectiveModelContext> modelContextSupplier,
+                final SchemaSourceProvider<YangTextSource> schemaSourceProvider) {
+            super(modelContextSupplier);
             this.schemaSourceProvider = requireNonNull(schemaSourceProvider);
         }
 
@@ -47,39 +48,39 @@ public class FixedDOMSchemaService extends AbstractDOMSchemaService {
         }
 
         @Override
-        public ListenableFuture<? extends YangTextSchemaSource> getSource(final SourceIdentifier sourceIdentifier) {
+        public ListenableFuture<? extends YangTextSource> getSource(final SourceIdentifier sourceIdentifier) {
             return schemaSourceProvider.getSource(sourceIdentifier);
         }
     }
 
-    private final @NonNull EffectiveModelContextProvider schemaContextProvider;
+    private final Supplier<EffectiveModelContext> modelContextSupplier;
 
-    private FixedDOMSchemaService(final EffectiveModelContextProvider schemaContextProvider) {
-        this.schemaContextProvider = requireNonNull(schemaContextProvider);
+    private FixedDOMSchemaService(final Supplier<EffectiveModelContext> modelContextSupplier) {
+        this.modelContextSupplier = requireNonNull(modelContextSupplier);
     }
 
-    public static @NonNull DOMSchemaService of(final EffectiveModelContext effectiveModel) {
+    public static DOMSchemaService of(final EffectiveModelContext effectiveModel) {
         final var checked = requireNonNull(effectiveModel);
-        return of(() -> checked);
+        return new FixedDOMSchemaService(() -> checked);
     }
 
-    public static @NonNull DOMSchemaService of(final EffectiveModelContextProvider schemaContextProvider) {
-        return new FixedDOMSchemaService(schemaContextProvider);
+    public static DOMSchemaService of(final Supplier<EffectiveModelContext> modelContextSupplier) {
+        return new FixedDOMSchemaService(modelContextSupplier);
     }
 
-    public static @NonNull DOMSchemaService of(final EffectiveModelContextProvider schemaContextProvider,
-            final SchemaSourceProvider<YangTextSchemaSource> yangTextSourceProvider) {
-        return new WithYangTextSources(schemaContextProvider, requireNonNull(yangTextSourceProvider));
+    public static DOMSchemaService of(final Supplier<EffectiveModelContext> modelContextSupplier,
+            final SchemaSourceProvider<YangTextSource> yangTextSourceProvider) {
+        return new WithYangTextSources(modelContextSupplier, requireNonNull(yangTextSourceProvider));
     }
 
     @Override
-    public final @NonNull EffectiveModelContext getGlobalContext() {
-        return schemaContextProvider.getEffectiveModelContext();
+    public final EffectiveModelContext getGlobalContext() {
+        return modelContextSupplier.get();
     }
 
     @Override
-    public final Registration registerSchemaContextListener(final EffectiveModelContextListener listener) {
-        listener.onModelContextUpdated(getGlobalContext());
+    public final Registration registerSchemaContextListener(final Consumer<EffectiveModelContext> listener) {
+        listener.accept(getGlobalContext());
         return () -> { };
     }
 }
index 93d97f1097f848138f6239606279e290f7da1dfd..0fd28da92a026b310361a32f024b8414cbb82d3f 100644 (file)
@@ -18,8 +18,10 @@ import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.yang.extension.yang.ext.rev130709.$YangModuleInfoImpl;
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.api.stmt.RpcEffectiveStatement;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.spi.source.DelegatedYangTextSource;
+import org.opendaylight.yangtools.yang.model.spi.source.URLYangTextSource;
 import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
@@ -29,9 +31,9 @@ public class ContentRoutedRpcContextTest {
     @BeforeClass
     public static void beforeClass() {
         final var ctx = YangParserTestUtils.parseYangSources(YangParserConfiguration.DEFAULT, null,
-            YangTextSchemaSource.delegateForCharSource("yang-ext.yang",
+            new DelegatedYangTextSource(new SourceIdentifier("yang-ext.yang"),
                 $YangModuleInfoImpl.getInstance().getYangTextCharSource()),
-            YangTextSchemaSource.forResource(ContentRoutedRpcContext.class, "/rpc-routing-strategy.yang"));
+            new URLYangTextSource(ContentRoutedRpcContext.class.getResource("/rpc-routing-strategy.yang")));
 
         RPCS = ctx.findModuleStatements("foo").iterator().next()
             .streamEffectiveSubstatements(RpcEffectiveStatement.class)
@@ -56,4 +58,4 @@ public class ContentRoutedRpcContextTest {
         assertEquals(QName.create("foo", "identity"), context.identity());
         assertEquals(QName.create("foo", "ctx"), context.leaf());
     }
-}
\ No newline at end of file
+}
index 7b9f49794ef3ce7b37699f6b08249b7d6e3f7e06..cd6ae75e140ba954b873309960a6ce0296c43c73 100644 (file)
@@ -48,7 +48,7 @@ import org.opendaylight.mdsal.dom.api.DOMTransactionChain;
 import org.opendaylight.mdsal.dom.api.DOMTransactionChainListener;
 import org.opendaylight.yangtools.util.concurrent.FluentFutures;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 
 @RunWith(MockitoJUnitRunner.StrictStubs.class)
 public class PingPongTransactionChainTest {
@@ -151,7 +151,7 @@ public class PingPongTransactionChainTest {
         tx.delete(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.of());
         verify(rwTx).delete(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.of());
 
-        final var data = mock(NormalizedNode.class);
+        final var data = mock(ContainerNode.class);
         doNothing().when(rwTx).merge(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.of(), data);
         tx.merge(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.of(), data);
         verify(rwTx).merge(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.of(), data);
index 772d660fe7a7b8b4a298c7e51e65db386b91eaff..afde8a25c4ff565f03a7abd5d58d39faaf661b35 100644 (file)
@@ -21,13 +21,12 @@ import static org.mockito.Mockito.doThrow;
 import static org.mockito.Mockito.mock;
 
 import com.google.common.util.concurrent.Futures;
-import java.lang.reflect.Field;
 import java.util.Optional;
 import java.util.concurrent.ExecutionException;
 import org.junit.Test;
 import org.opendaylight.mdsal.common.api.ReadFailedException;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeSnapshot;
 
 public class SnapshotBackedReadTransactionTest {
@@ -39,14 +38,14 @@ public class SnapshotBackedReadTransactionTest {
 
     @Test
     public void basicTest() throws Exception {
-        final NormalizedNode testNode = mock(NormalizedNode.class);
-        final Optional<NormalizedNode> optional = Optional.of(testNode);
+        final var testNode = mock(ContainerNode.class);
+        final var optional = Optional.of(testNode);
         doReturn("testNode").when(testNode).toString();
         doReturn(Optional.of(testNode)).when(DATA_TREE_SNAPSHOT).readNode(YangInstanceIdentifier.of());
         assertTrue(snapshotBackedReadTransaction.exists(YangInstanceIdentifier.of()).get());
 
         assertEquals(optional, snapshotBackedReadTransaction.read(YangInstanceIdentifier.of()).get());
-        final Field stableSnapshotField = SnapshotBackedReadTransaction.class.getDeclaredField("stableSnapshot");
+        final var stableSnapshotField = SnapshotBackedReadTransaction.class.getDeclaredField("stableSnapshot");
         stableSnapshotField.setAccessible(true);
 
         DataTreeSnapshot stableSnapshot = (DataTreeSnapshot) stableSnapshotField.get(snapshotBackedReadTransaction);
index 14608d1f82f1da3bded3aa59a7390067afa09c3d..a0ff3fca7def889c53cf5e06d1b1185ee4be990c 100644 (file)
@@ -26,7 +26,7 @@ import org.junit.Test;
 import org.opendaylight.mdsal.common.api.ReadFailedException;
 import org.opendaylight.mdsal.dom.spi.store.SnapshotBackedWriteTransaction.TransactionReadyPrototype;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeSnapshot;
 
@@ -47,8 +47,8 @@ public class SnapshotBackedReadWriteTransactionTest {
 
     @Test
     public void basicTest() throws Exception {
-        final NormalizedNode testNode = mock(NormalizedNode.class);
-        final Optional<NormalizedNode> optional = Optional.of(testNode);
+        final var testNode = mock(ContainerNode.class);
+        final var optional = Optional.of(testNode);
         doReturn("testNode").when(testNode).toString();
         doReturn(Optional.of(testNode)).when(DATA_TREE_MODIFICATION).readNode(YangInstanceIdentifier.of());
         assertTrue(snapshotBackedReadWriteTransaction.exists(YangInstanceIdentifier.of()).get());
index 41e11f524b55b4a95ceb5a933f3b9411ce352d87..de792167cdda7d1d0806eca830baf016092ca630 100644 (file)
@@ -27,7 +27,7 @@ import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.mdsal.dom.spi.store.SnapshotBackedWriteTransaction.TransactionReadyPrototype;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeSnapshot;
 
@@ -39,8 +39,8 @@ public class SnapshotBackedWriteTransactionTest {
             mock(TransactionReadyPrototype.class);
     private static final DOMStoreThreePhaseCommitCohort DOM_STORE_THREE_PHASE_COMMIT_COHORT =
             mock(DOMStoreThreePhaseCommitCohort.class);
-    private static final NormalizedNode NORMALIZED_NODE = mock(NormalizedNode.class);
-    private static final Optional<NormalizedNode> NORMALIZED_NODE_OPTIONAL = Optional.of(NORMALIZED_NODE);
+    private static final ContainerNode NORMALIZED_NODE = mock(ContainerNode.class);
+    private static final Optional<ContainerNode> NORMALIZED_NODE_OPTIONAL = Optional.of(NORMALIZED_NODE);
     private static SnapshotBackedWriteTransaction<Object> snapshotBackedWriteTransaction;
 
     @Before
index 53bdd85427e5de90ca3da24bf65d26ce291497b2..8b791a0288f0e2f25a33bcf37054e09763d5a4cd 100644 (file)
@@ -27,7 +27,7 @@
             <dependency>
                 <groupId>org.opendaylight.yangtools</groupId>
                 <artifactId>yangtools-artifacts</artifactId>
-                <version>11.0.5</version>
+                <version>13.0.0</version>
                 <type>pom</type>
                 <scope>import</scope>
             </dependency>
index 998fc20dba342c030d680e441265b5fcb3d26ed5..d316d875d9e938734dd661ea7b7144c55442a679 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="odl-mdsal-binding-api">
     <feature name="odl-mdsal-binding-api">
-        <feature version="[11,12)">odl-yangtools-data-api</feature>
+        <feature version="[13,14)">odl-yangtools-data-api</feature>
     </feature>
 </features>
index 01f47d6dee1e0eca18351e3824c42327e866753f..4b948cf74a84b9ee1ef4bd5c765743ac81e7424b 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="odl-mdsal-binding-base">
     <feature name="odl-mdsal-binding-base">
-        <feature version="[11,12)">odl-yangtools-common</feature>
+        <feature version="[13,14)">odl-yangtools-common</feature>
     </feature>
 </features>
index 119c5baab395c4c126f2a8bb911a790eeebfd2ee..01e5171e5856dac7b686f87dd6ec3d2fb75c89ce 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="odl-mdsal-runtime-api">
     <feature name="odl-mdsal-binding-runtime-api">
-        <feature version="[11,12)">odl-yangtools-data</feature>
-        <feature version="[11,12)">odl-yangtools-parser</feature>
+        <feature version="[13,14)">odl-yangtools-data</feature>
+        <feature version="[13,14)">odl-yangtools-parser</feature>
     </feature>
 </features>
index f4e3c49a0ceaff4acf6b25b1be4ebcd59fd0dc74..d3257d3697132ca8edb1e617d81b85231c11eed1 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="odl-mdsal-common">
     <feature name="odl-mdsal-common">
-        <feature version="[11,12)">odl-yangtools-common</feature>
+        <feature version="[13,14)">odl-yangtools-common</feature>
     </feature>
 </features>
index f3aa0821ea5e1a5079af7d8ee84027a0f7b166f8..b264cda5fe17d6a7ab73dbf7191b3bfc92ef7951 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="odl-mdsal-dom-api">
     <feature name="odl-mdsal-dom-api">
-        <feature version="[11,12)">odl-yangtools-data-api</feature>
+        <feature version="[13,14)">odl-yangtools-data-api</feature>
     </feature>
 </features>
index 1f9cfcd7be22e9ec33b0e46d3b141e89a5a49b40..04fcd00c6c8c9704fb5513c4921902afb4fa9b41 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="odl-mdsal-eos-common">
     <feature name="odl-mdsal-eos-common">
-        <feature version="[11,12)">odl-yangtools-data-api</feature>
+        <feature version="[13,14)">odl-yangtools-data-api</feature>
     </feature>
 </features>
index db599fc1928ccab23e5d224e11f2d4532729a7dd..cec4bd16ee6184b3cfee068e913b7cf742596a56 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="odl-mdsal-exp-yanglib-api">
     <feature name="odl-mdsal-exp-yanglib-api">
-        <feature version="[11,12)">odl-yangtools-data-api</feature>
+        <feature version="[13,14)">odl-yangtools-data-api</feature>
     </feature>
 </features>
index 8819e78312b0ab4843765b61cfc46efb2fe7f37f..ce337af671fb5aeaeb0c5f1b6eea92133992beb5 100644 (file)
@@ -4,6 +4,6 @@
         <configfile finalname="etc/org.opendaylight.mdsal.replicate.netty.sink.cfg">mvn:org.opendaylight.mdsal/mdsal-replicate-netty/${project.version}/config/sink</configfile>
         <configfile finalname="etc/org.opendaylight.mdsal.replicate.netty.source.cfg">mvn:org.opendaylight.mdsal/mdsal-replicate-netty/${project.version}/config/source</configfile>
         <feature version="[12,14)">odl-netty-4</feature>
-        <feature version="[11,12)">odl-yangtools-codec</feature>
+        <feature version="[13,14)">odl-yangtools-codec</feature>
     </feature>
 </features>
index ecf2161ecd675e2e5590ceaa820ae61a739b597a..18a66a0240489b82794f3a31b95c8a8e44665631 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="odl-mdsal-uint24-netty">
     <feature name="odl-mdsal-uint24-netty">
-        <feature version="[11,12)">odl-yangtools-netty</feature>
+        <feature version="[13,14)">odl-yangtools-netty</feature>
     </feature>
 </features>
index eefbc639f212354e29f1d22f9e9deefcd8cbd70b..9ecf490fbdb97cc9e7c02928e818169b1c898d68 100644 (file)
@@ -69,7 +69,7 @@ final class DOMDataBrokerModification implements DataTreeModification {
     }
 
     @Override
-    public EffectiveModelContext getEffectiveModelContext() {
+    public EffectiveModelContext modelContext() {
         throw new UnsupportedOperationException();
     }
 }
index 95e63cf12288b4a64934d91a8cfc55d4091a068f..543d159c18ab8148ea62e2caafb0054b445617e7 100644 (file)
@@ -52,7 +52,7 @@ final class DOMStoreModification implements DataTreeModification {
     }
 
     @Override
-    public EffectiveModelContext getEffectiveModelContext() {
+    public EffectiveModelContext modelContext() {
         throw new UnsupportedOperationException();
     }
 
index b264245f584d5c056a51959175a22c1f1be32360..91ad211a319569954df483a98c85e3b301d5803c 100644 (file)
@@ -48,10 +48,6 @@ public final class NettyReplicationSource {
 
     private Registration reg;
 
-    public NettyReplicationSource() {
-        // Visible for DI
-    }
-
     @Activate
     public NettyReplicationSource(@Reference final BootstrapSupport bootstrapSupport,
             @Reference final DOMDataBroker dataBroker,
index ebcd0b2e8f9bde22b220a3487e61612ba9f32dd4..8e49288941cf1dadb00ef5a9d5caa94d3838af60 100644 (file)
             <groupId>org.opendaylight.yangtools</groupId>
             <artifactId>yang-parser-api</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.opendaylight.yangtools</groupId>
-            <artifactId>yang-repo-api</artifactId>
-        </dependency>
     </dependencies>
 
     <scm>
index 50c14ec3e50cc429fecf7d91461ba816fc3c1bd0..0d691ffd608399736fa3542d1fc06936427b00c0 100644 (file)
@@ -17,7 +17,7 @@ import java.util.Collection;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.opendaylight.yangtools.concepts.AbstractSimpleIdentifiable;
 import org.opendaylight.yangtools.concepts.Immutable;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 
 /**
  * A reference to a YANG source, potentially containing a location hint.
index 2145c83f3a4243c589d64eb8b6772837b51ea8dd..85b725b20a6878c700028f4445641ab05af88ac5 100644 (file)
@@ -49,7 +49,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.MountPointContextFactory;
 import org.opendaylight.yangtools.yang.data.api.schema.MountPointException;
 import org.opendaylight.yangtools.yang.data.util.AbstractMountPointContextFactory;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
-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.YangParserException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
index 015d4cdf8c7467884c8be5bf7c04907dbb324aaa..7cc6eee3c8aa9b0d0b3650d03842d3f8d1403a18 100644 (file)
@@ -46,7 +46,7 @@ public final class YangLibrarySupport implements YangLibSupport {
     @SuppressWarnings("deprecation")
     private final BindingDataObjectCodecTreeNode<ModulesState> legacyCodec;
     private final BindingIdentityCodec identityCodec;
-    private final EffectiveModelContext context;
+    private final EffectiveModelContext modelContext;
     private final BindingCodecTree codecTree;
 
     @Inject
@@ -57,10 +57,10 @@ public final class YangLibrarySupport implements YangLibSupport {
         final ModuleInfoSnapshot snapshot = new ModuleInfoSnapshotBuilder(parserFactory)
                 .add(YangLibrary.class)
                 .build();
-        context = snapshot.getEffectiveModelContext();
+        modelContext = snapshot.modelContext();
 
         codecTree = codecFactory.create(new DefaultBindingRuntimeContext(
-            generator.generateTypeMapping(context), snapshot));
+            generator.generateTypeMapping(modelContext), snapshot));
 
         identityCodec = codecTree.getIdentityCodec();
         codec = codecTree.getDataObjectCodec(InstanceIdentifier.create(YangLibrary.class));
@@ -70,7 +70,7 @@ public final class YangLibrarySupport implements YangLibSupport {
     @Override
     public MountPointContextFactory createMountPointContextFactory(final MountPointLabel label,
             final SchemaContextResolver resolver) {
-        return new MountPointContextFactoryImpl(label, resolver, context, identityCodec, codec, legacyCodec);
+        return new MountPointContextFactoryImpl(label, resolver, modelContext, identityCodec, codec, legacyCodec);
     }
 
     @Override
index 3a0fff17c6aeed44aeb3fc45f1a0f25a9a272993..204cb95514f6134401d195768275fd572425c6b4 100644 (file)
@@ -8,8 +8,7 @@
 package org.opendaylight.mdsal.yanglib.rfc8525;
 
 import java.util.ServiceLoader;
-import org.junit.Before;
-import org.junit.BeforeClass;
+import org.junit.jupiter.api.BeforeEach;
 import org.opendaylight.mdsal.binding.dom.codec.api.BindingCodecTree;
 import org.opendaylight.mdsal.binding.dom.codec.api.BindingCodecTreeFactory;
 import org.opendaylight.mdsal.binding.runtime.api.BindingRuntimeContext;
@@ -26,18 +25,12 @@ abstract class AbstractYangLibraryTest {
     private static final BindingCodecTreeFactory CODEC_FACTORY = ServiceLoader.load(BindingCodecTreeFactory.class)
         .findFirst().orElseThrow();
 
-    static BindingRuntimeContext runtimeContext;
-    static BindingCodecTree codecTree;
+    static final BindingRuntimeContext RUNTIME_CONTEXT = BindingRuntimeHelpers.createRuntimeContext();
+    static final BindingCodecTree CODEC_TREE = CODEC_FACTORY.create(RUNTIME_CONTEXT);
 
     YangLibrarySupport yangLib;
 
-    @BeforeClass
-    public static void beforeClass() {
-        runtimeContext = BindingRuntimeHelpers.createRuntimeContext();
-        codecTree = CODEC_FACTORY.create(runtimeContext);
-    }
-
-    @Before
+    @BeforeEach
     public void before() throws YangParserException {
         yangLib = new YangLibrarySupport(YANG_PARSER_FACTORY, BINDING_RUNTIME_GENERATOR, CODEC_FACTORY);
     }
index 8ce1e350de571065d869622e14c63b4b744c1cb7..b97039d3974c1e1a321dbb6f47aba8c511c2e245 100644 (file)
@@ -7,13 +7,11 @@
  */
 package org.opendaylight.mdsal.yanglib.rfc8525;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
-import java.util.Map;
-import java.util.Optional;
 import java.util.Set;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.ModulesState;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.RevisionIdentifier;
@@ -21,45 +19,38 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.librar
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.module.list.Module;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.module.list.Module.ConformanceType;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.module.list.ModuleBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.module.list.ModuleKey;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.YangIdentifier;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.util.BindingMap;
-import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 
-public class LegacyYangLibraryFormatTest extends AbstractYangLibraryTest {
+class LegacyYangLibraryFormatTest extends AbstractYangLibraryTest {
     @Test
-    public void testLegacyFormat() {
-        final var legacyCodec = codecTree.getDataObjectCodec(InstanceIdentifier.create(ModulesState.class));
+    void testLegacyFormat() {
+        final var legacyCodec = CODEC_TREE.getDataObjectCodec(InstanceIdentifier.create(ModulesState.class));
 
-        final Optional<ContainerNode> legacyContent = yangLib.newContentBuilder()
-            .defaultContext(runtimeContext.getEffectiveModelContext())
+        final var legacyContent = yangLib.newContentBuilder()
+            .defaultContext(RUNTIME_CONTEXT.modelContext())
             .includeLegacy()
             .formatYangLibraryLegacyContent();
 
         assertTrue(legacyContent.isPresent());
 
-        final ModulesState modulesState = legacyCodec.deserialize(legacyContent.orElseThrow());
-
-        assertEquals(4, modulesState.nonnullModule().size());
-        assertEquals(createControlModules(), modulesState.getModule());
-    }
-
-    private static Map<ModuleKey, Module> createControlModules() {
-        return BindingMap.of(
+        final var modulesState = legacyCodec.deserialize(legacyContent.orElseThrow());
+        assertEquals(BindingMap.of(
             createModule("ietf-yang-library", "urn:ietf:params:xml:ns:yang:ietf-yang-library", "2019-01-04"),
             createModule("ietf-inet-types", "urn:ietf:params:xml:ns:yang:ietf-inet-types", "2013-07-15"),
             createModule("ietf-datastores", "urn:ietf:params:xml:ns:yang:ietf-datastores", "2018-02-14"),
-            createModule("ietf-yang-types", "urn:ietf:params:xml:ns:yang:ietf-yang-types", "2013-07-15"));
+            createModule("ietf-yang-types", "urn:ietf:params:xml:ns:yang:ietf-yang-types", "2013-07-15")),
+            modulesState.getModule());
     }
 
     private static Module createModule(final String name, final String namespace, final String revision) {
         return new ModuleBuilder()
-                .setName(new YangIdentifier(name))
-                .setNamespace(new Uri(namespace))
-                .setRevision(new Revision(new RevisionIdentifier(revision)))
-                .setConformanceType(ConformanceType.Implement)
-                .setFeature(Set.of())
-                .build();
+            .setName(new YangIdentifier(name))
+            .setNamespace(new Uri(namespace))
+            .setRevision(new Revision(new RevisionIdentifier(revision)))
+            .setConformanceType(ConformanceType.Implement)
+            .setFeature(Set.of())
+            .build();
     }
 }
\ No newline at end of file
index 147acdacbbeb54446471923955b0a76cef62ffb3..34dccc647c19cc608f394a5096dc0f087764c11c 100644 (file)
@@ -7,45 +7,42 @@
  */
 package org.opendaylight.mdsal.yanglib.rfc8525;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 import java.util.Map;
 import java.util.Set;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.RevisionIdentifier;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.YangLibrary;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.module.set.parameters.Module;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.module.set.parameters.ModuleBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.module.set.parameters.ModuleKey;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.yang.library.parameters.ModuleSet;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.yang.library.parameters.ModuleSetKey;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.YangIdentifier;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.util.BindingMap;
-import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 
-public class YangLibrarySupportTest extends AbstractYangLibraryTest {
+class YangLibrarySupportTest extends AbstractYangLibraryTest {
     @Test
-    public void testFormatSchema() {
-        final var codec = codecTree.getDataObjectCodec(InstanceIdentifier.create(YangLibrary.class));
+    void testFormatSchema() {
+        final var codec = CODEC_TREE.getDataObjectCodec(InstanceIdentifier.create(YangLibrary.class));
 
-        final ContainerNode nonLegacyContent = yangLib.newContentBuilder()
-                .defaultContext(runtimeContext.getEffectiveModelContext()).formatYangLibraryContent();
-        final YangLibrary yangLibrary = codec.deserialize(nonLegacyContent);
+        final var nonLegacyContent = yangLib.newContentBuilder()
+                .defaultContext(RUNTIME_CONTEXT.modelContext()).formatYangLibraryContent();
+        final var yangLibrary = codec.deserialize(nonLegacyContent);
 
-        assertEquals(1, yangLibrary.nonnullModuleSet().size());
-        final ModuleSet moduleSet = yangLibrary.nonnullModuleSet().get(new ModuleSetKey("ODL_modules"));
-        assertEquals(4, moduleSet.nonnullModule().size());
-        assertEquals(moduleSet.getModule(), createControlModules());
-    }
-
-    private static Map<ModuleKey, Module> createControlModules() {
-        return BindingMap.of(
+        final var modulesSets = yangLibrary.nonnullModuleSet();
+        assertNotNull(modulesSets);
+        assertEquals(1, modulesSets.size());
+        final var moduleSet = modulesSets.get(new ModuleSetKey("ODL_modules"));
+        assertNotNull(moduleSet);
+        assertEquals(BindingMap.of(
             createModule("ietf-yang-library", "urn:ietf:params:xml:ns:yang:ietf-yang-library", "2019-01-04"),
             createModule("ietf-inet-types", "urn:ietf:params:xml:ns:yang:ietf-inet-types", "2013-07-15"),
             createModule("ietf-datastores", "urn:ietf:params:xml:ns:yang:ietf-datastores", "2018-02-14"),
-            createModule("ietf-yang-types", "urn:ietf:params:xml:ns:yang:ietf-yang-types", "2013-07-15"));
+            createModule("ietf-yang-types", "urn:ietf:params:xml:ns:yang:ietf-yang-types", "2013-07-15")),
+            moduleSet.getModule());
     }
 
     private static Module createModule(final String name, final String namespace, final String revision) {