Hide BindingReflections.getModuleInfo() 85/106585/2
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 21 Jun 2023 11:45:57 +0000 (13:45 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 21 Jun 2023 12:38:38 +0000 (14:38 +0200)
We have a replacement in BindingRuntimeHelpers.getYangModuleInfo(). This
patch migrates users and eliminates getModuleInfo() from public view.

JIRA: MDSAL-781
Change-Id: Ifd1cdbee440e8f14c1f53b2432b3b8cf3a7fc8df
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
binding/mdsal-binding-dom-adapter/src/test/java/org/opendaylight/mdsal/binding/dom/adapter/BindingDOMRpcIntegrationTest.java
binding/mdsal-binding-dom-adapter/src/test/java/org/opendaylight/mdsal/binding/dom/adapter/Bug1125RegressionTest.java
binding/mdsal-binding-dom-adapter/src/test/java/org/opendaylight/mdsal/binding/dom/adapter/Bug1333DataChangeListenerTest.java
binding/mdsal-binding-dom-adapter/src/test/java/org/opendaylight/mdsal/binding/dom/adapter/Bug1418AugmentationTest.java
binding/mdsal-binding-dom-adapter/src/test/java/org/opendaylight/mdsal/binding/dom/adapter/Bug2562DeserializedUnkeyedListTest.java
binding/mdsal-binding-dom-adapter/src/test/java/org/opendaylight/mdsal/binding/dom/adapter/Bug3090MultiKeyList.java
binding/mdsal-binding-dom-adapter/src/test/java/org/opendaylight/mdsal/binding/dom/adapter/DataTreeChangeListenerTest.java
binding/mdsal-binding-dom-adapter/src/test/java/org/opendaylight/mdsal/binding/dom/adapter/ForwardedNotificationAdapterTest.java
binding/mdsal-binding-dom-adapter/src/test/java/org/opendaylight/mdsal/binding/dom/adapter/ListInsertionDataChangeListenerTest.java
binding/mdsal-binding-dom-adapter/src/test/java/org/opendaylight/mdsal/binding/dom/adapter/Mdsal500Test.java
binding/mdsal-binding-spec-util/src/main/java/org/opendaylight/mdsal/binding/spec/reflect/BindingReflections.java

index 2c370d5d221bb469f939b338798fedbd22eb0ec3..1287fdeda9234e27e90932d8e93b0a471a433251 100644 (file)
@@ -26,7 +26,7 @@ import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
 import org.opendaylight.mdsal.binding.api.RpcProviderService;
 import org.opendaylight.mdsal.binding.dom.adapter.test.util.BindingBrokerTestFactory;
 import org.opendaylight.mdsal.binding.dom.adapter.test.util.BindingTestContext;
-import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
+import org.opendaylight.mdsal.binding.runtime.spi.BindingRuntimeHelpers;
 import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier;
 import org.opendaylight.mdsal.dom.api.DOMRpcProviderService;
 import org.opendaylight.mdsal.dom.api.DOMRpcResult;
@@ -69,8 +69,8 @@ public class BindingDOMRpcIntegrationTest {
         testContext = testFactory.getTestContext();
 
         testContext.setSchemaModuleInfos(ImmutableSet.of(
-                BindingReflections.getModuleInfo(OpendaylightKnockKnockRpcService.class),
-                BindingReflections.getModuleInfo(Top.class)));
+            BindingRuntimeHelpers.getYangModuleInfo(OpendaylightKnockKnockRpcService.class),
+            BindingRuntimeHelpers.getYangModuleInfo(Top.class)));
         testContext.start();
         baRpcProviderService = testContext.getBindingRpcProviderRegistry();
         baRpcConsumerService = testContext.getBindingRpcConsumerRegistry();
index 4a77244bafa13a0ca60ea7f4806a58fc94c1263a..c1ffd9d88aae251aa21ca1f1228e51a1b5730e7a 100644 (file)
@@ -14,7 +14,7 @@ import static org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.t
 import java.util.Set;
 import org.junit.Test;
 import org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataTreeChangeListenerTest;
-import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
+import org.opendaylight.mdsal.binding.runtime.spi.BindingRuntimeHelpers;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugment;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugmentBuilder;
@@ -43,8 +43,9 @@ public class Bug1125RegressionTest extends AbstractDataTreeChangeListenerTest {
 
     @Override
     protected Set<YangModuleInfo> getModuleInfos() throws Exception {
-        return Set.of(BindingReflections.getModuleInfo(Top.class),
-                BindingReflections.getModuleInfo(TreeComplexUsesAugment.class));
+        return Set.of(
+            BindingRuntimeHelpers.getYangModuleInfo(Top.class),
+            BindingRuntimeHelpers.getYangModuleInfo(TreeComplexUsesAugment.class));
     }
 
     @Test
index 50bfca66064edb82a85dda05513d209acd92bf7a..8e9e55cf607660906258e3ff23b7e5f34ba7b227 100644 (file)
@@ -15,11 +15,10 @@ import static org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.p
 import static org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.top;
 import static org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.topLevelList;
 
-import com.google.common.collect.ImmutableSet;
 import java.util.Set;
 import org.junit.Test;
 import org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataTreeChangeListenerTest;
-import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
+import org.opendaylight.mdsal.binding.runtime.spi.BindingRuntimeHelpers;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugment;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top;
@@ -41,8 +40,8 @@ public class Bug1333DataChangeListenerTest extends AbstractDataTreeChangeListene
 
     @Override
     protected Set<YangModuleInfo> getModuleInfos() throws Exception {
-        return ImmutableSet.of(BindingReflections.getModuleInfo(Top.class),
-                BindingReflections.getModuleInfo(TreeComplexUsesAugment.class));
+        return Set.of(BindingRuntimeHelpers.getYangModuleInfo(Top.class),
+            BindingRuntimeHelpers.getYangModuleInfo(TreeComplexUsesAugment.class));
     }
 
     private static Top topWithListItem() {
index eb4c0c637b556cfb6ae77438a1e8374b31500d4f..d8365e476419fb1927bdf49a31b87686971b07fb 100644 (file)
@@ -18,7 +18,7 @@ import static org.opendaylight.mdsal.common.api.LogicalDatastoreType.CONFIGURATI
 import java.util.Set;
 import org.junit.Test;
 import org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataTreeChangeListenerTest;
-import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
+import org.opendaylight.mdsal.binding.runtime.spi.BindingRuntimeHelpers;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugment;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeLeafOnlyUsesAugment;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.complex.from.grouping.ListViaUsesKey;
@@ -42,8 +42,8 @@ public class Bug1418AugmentationTest extends AbstractDataTreeChangeListenerTest
 
     @Override
     protected Set<YangModuleInfo> getModuleInfos() {
-        return Set.of(BindingReflections.getModuleInfo(Top.class),
-                BindingReflections.getModuleInfo(TreeComplexUsesAugment.class));
+        return Set.of(BindingRuntimeHelpers.getYangModuleInfo(Top.class),
+            BindingRuntimeHelpers.getYangModuleInfo(TreeComplexUsesAugment.class));
     }
 
     @Test
index 4aed5155bd265b955755af1e97d60099e79232d1..b35578160ce0539fa6cb6e1e32c7cad45702070f 100644 (file)
@@ -8,33 +8,33 @@
 package org.opendaylight.mdsal.binding.dom.adapter;
 
 import java.util.List;
-import java.util.Map;
 import java.util.Set;
 import org.junit.Test;
 import org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataTreeChangeListenerTest;
-import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
+import org.opendaylight.mdsal.binding.runtime.spi.BindingRuntimeHelpers;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.yang.gen.v1.opendaylight.test.bug._2562.namespace.rev160101.Root;
 import org.opendaylight.yang.gen.v1.opendaylight.test.bug._2562.namespace.rev160101.RootBuilder;
 import org.opendaylight.yang.gen.v1.opendaylight.test.bug._2562.namespace.rev160101.root.FoorootBuilder;
 import org.opendaylight.yang.gen.v1.opendaylight.test.bug._2562.namespace.rev160101.root.fooroot.BarrootBuilder;
-import org.opendaylight.yang.gen.v1.opendaylight.test.bug._2562.namespace.rev160101.root.fooroot.BarrootKey;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
+import org.opendaylight.yangtools.yang.binding.util.BindingMap;
 
 public class Bug2562DeserializedUnkeyedListTest extends AbstractDataTreeChangeListenerTest {
     private static final InstanceIdentifier<Root> ROOT_PATH = InstanceIdentifier.create(Root.class);
 
     @Override
     protected Set<YangModuleInfo> getModuleInfos() throws Exception {
-        return Set.of(BindingReflections.getModuleInfo(Root.class));
+        return Set.of(BindingRuntimeHelpers.getYangModuleInfo(Root.class));
     }
 
     @Test
     public void writeListToList2562Root() {
-        final var barRoot = new BarrootBuilder().setType(2).setValue(2).withKey(new BarrootKey(2)).build();
-        final var fooRoot = new FoorootBuilder().setBarroot(Map.of(barRoot.key(), barRoot)).build();
-        final var root = new RootBuilder().setFooroot(List.of(fooRoot)).build();
+        final var root = new RootBuilder()
+            .setFooroot(List.of(new FoorootBuilder()
+                .setBarroot(BindingMap.of(new BarrootBuilder().setType(2).setValue(2).build()))
+            .build())).build();
 
         try (var collector = createCollector(LogicalDatastoreType.CONFIGURATION, ROOT_PATH)) {
             collector.verifyModifications();
index 2afd118b394bc0a78b889668aa89ff3b4d74887d..368fb7951bfd646bcb81d15aac3ffdafabf1695c 100644 (file)
@@ -15,7 +15,7 @@ import java.util.stream.Collectors;
 import org.junit.Test;
 import org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType;
 import org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataTreeChangeListenerTest;
-import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
+import org.opendaylight.mdsal.binding.runtime.spi.BindingRuntimeHelpers;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.opendaylight.test.bug._3090.rev160101.Root;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.opendaylight.test.bug._3090.rev160101.RootBuilder;
@@ -30,7 +30,7 @@ public class Bug3090MultiKeyList extends AbstractDataTreeChangeListenerTest {
 
     @Override
     protected Set<YangModuleInfo> getModuleInfos() throws Exception {
-        return Set.of(BindingReflections.getModuleInfo(Root.class));
+        return Set.of(BindingRuntimeHelpers.getYangModuleInfo(Root.class));
     }
 
     @Test
index 7576509282c3d1b29b1104bf28380c5e788e51ea..14fca329f20f359053a96a0b4074faf38cd6663e 100644 (file)
@@ -33,7 +33,7 @@ import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
 import org.opendaylight.mdsal.binding.api.DataTreeModification;
 import org.opendaylight.mdsal.binding.api.WriteTransaction;
 import org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataBrokerTest;
-import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
+import org.opendaylight.mdsal.binding.runtime.spi.BindingRuntimeHelpers;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugment;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top;
@@ -67,7 +67,7 @@ public class DataTreeChangeListenerTest extends AbstractDataBrokerTest {
 
         @Override
         public void onDataTreeChanged(final Collection<DataTreeModification<T>> changes) {
-            this.futureChanges.set(changes);
+            futureChanges.set(changes);
 
         }
 
@@ -81,9 +81,8 @@ public class DataTreeChangeListenerTest extends AbstractDataBrokerTest {
     @Override
     protected Set<YangModuleInfo> getModuleInfos() throws Exception {
         return ImmutableSet.of(
-                BindingReflections.getModuleInfo(TwoLevelList.class),
-                BindingReflections.getModuleInfo(TreeComplexUsesAugment.class)
-                );
+            BindingRuntimeHelpers.getYangModuleInfo(TwoLevelList.class),
+            BindingRuntimeHelpers.getYangModuleInfo(TreeComplexUsesAugment.class));
     }
 
     @Override
index d998bcbea3178c8d1ec138d97860755f21c7fabd..024bf793a2a53b1292f31280bc6e42aa1cc088a8 100644 (file)
@@ -23,7 +23,7 @@ import org.junit.Test;
 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
 import org.opendaylight.mdsal.binding.api.NotificationService.Listener;
 import org.opendaylight.mdsal.binding.dom.adapter.test.AbstractNotificationBrokerTest;
-import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
+import org.opendaylight.mdsal.binding.runtime.spi.BindingRuntimeHelpers;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.OpendaylightMdsalBindingTestListener;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.TwoLevelListChanged;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.TwoLevelListChangedBuilder;
@@ -31,15 +31,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.te
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListKey;
 import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
 import org.opendaylight.yangtools.yang.binding.util.BindingMap;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 public class ForwardedNotificationAdapterTest extends AbstractNotificationBrokerTest {
-    private static final Logger LOG = LoggerFactory.getLogger(ForwardedNotificationAdapterTest.class);
-
     @Override
     protected Set<YangModuleInfo> getModuleInfos() throws Exception {
-        return Set.of(BindingReflections.getModuleInfo(TwoLevelListChanged.class));
+        return Set.of(BindingRuntimeHelpers.getYangModuleInfo(TwoLevelListChanged.class));
     }
 
     @Test
index 4a33fef41ed45dfd43a5a981a00ab78e19b27205..c02d18407dbfd85321805c5221538d67ed74e4d9 100644 (file)
@@ -13,7 +13,6 @@ import static org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.t
 import static org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.topLevelList;
 import static org.opendaylight.mdsal.common.api.LogicalDatastoreType.CONFIGURATION;
 
-import com.google.common.collect.ImmutableSet;
 import java.util.HashSet;
 import java.util.Objects;
 import java.util.Set;
@@ -23,7 +22,7 @@ import org.junit.Test;
 import org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType;
 import org.opendaylight.mdsal.binding.api.WriteTransaction;
 import org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataTreeChangeListenerTest;
-import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
+import org.opendaylight.mdsal.binding.runtime.spi.BindingRuntimeHelpers;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListBuilder;
@@ -42,7 +41,7 @@ public class ListInsertionDataChangeListenerTest extends AbstractDataTreeChangeL
 
     @Override
     protected Set<YangModuleInfo> getModuleInfos() throws Exception {
-        return ImmutableSet.of(BindingReflections.getModuleInfo(Top.class));
+        return Set.of(BindingRuntimeHelpers.getYangModuleInfo(Top.class));
     }
 
     @Before
index bc54e670eaeb1bcae19f415df417f25feb2aa716..16d11d0fe06e1f1dbbb2a4ff85dc0f3dcd2d88ac 100644 (file)
@@ -14,11 +14,11 @@ import static org.junit.Assert.assertSame;
 import static org.junit.Assert.assertTrue;
 
 import com.google.common.collect.HashMultimap;
-import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Multimap;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.MoreExecutors;
+import java.util.Set;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
@@ -29,7 +29,7 @@ import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
 import org.opendaylight.mdsal.binding.api.RpcProviderService;
 import org.opendaylight.mdsal.binding.dom.adapter.test.util.BindingBrokerTestFactory;
 import org.opendaylight.mdsal.binding.dom.adapter.test.util.BindingTestContext;
-import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
+import org.opendaylight.mdsal.binding.runtime.spi.BindingRuntimeHelpers;
 import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier;
 import org.opendaylight.mdsal.dom.api.DOMRpcProviderService;
 import org.opendaylight.mdsal.dom.api.DOMRpcResult;
@@ -65,8 +65,8 @@ public class Mdsal500Test {
         testFactory.setExecutor(MoreExecutors.newDirectExecutorService());
         testContext = testFactory.getTestContext();
 
-        testContext.setSchemaModuleInfos(ImmutableSet.of(
-                BindingReflections.getModuleInfo(Mdsal500Service.class)));
+        testContext.setSchemaModuleInfos(Set.of(
+            BindingRuntimeHelpers.getYangModuleInfo(Mdsal500Service.class)));
         testContext.start();
         baRpcProviderService = testContext.getBindingRpcProviderRegistry();
         baRpcConsumerService = testContext.getBindingRpcConsumerRegistry();
index a1dec50ca25bec897bf306e826b14006b3d33dc0..91ea6cdc4843c62a61c18d854e30076025849358 100644 (file)
@@ -138,7 +138,7 @@ public final class BindingReflections {
      * @param cls data object class
      * @return Instance of {@link YangModuleInfo} associated with model, from which this class was derived.
      */
-    public static @NonNull YangModuleInfo getModuleInfo(final Class<?> cls) {
+    private static @NonNull YangModuleInfo getModuleInfo(final Class<?> cls) {
         final String packageName = Naming.getModelRootPackageName(cls.getPackage().getName());
         final String potentialClassName = getModuleInfoClassName(packageName);
         final Class<?> moduleInfoClass;