Rename ChoiceNodeCodecContext 71/106471/1
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 13 Jun 2023 13:25:40 +0000 (15:25 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 13 Jun 2023 13:26:15 +0000 (15:26 +0200)
ChoiceCodecContext is a better and shorter name, as the 'Node' part does
not really make any sense.

JIRA: MDSAL-828
Change-Id: Ied868e2cecda87ccdd69dae9f6688c7d70cac924
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/AbstractDataObjectCodecContext.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/ChoiceCodecContext.java [moved from binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/ChoiceNodeCodecContext.java with 98% similarity]
binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/CodecDataObjectAnalysis.java
binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/DataContainerCodecContext.java
binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/DataObjectCodecPrototype.java
binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/RootCodecContext.java

index cb4d7d417b5d08a3519b0f53634f21d09a8a3a51..155f9863d601a2d420e20d9b8007c860b6024e0d 100644 (file)
@@ -98,7 +98,7 @@ public abstract sealed class AbstractDataObjectCodecContext<D extends DataObject
         final var context = childNonNull(pathChildPrototype(argType), argType,
             "Class %s is not valid child of %s", argType, getBindingClass())
             .get();
-        if (context instanceof ChoiceNodeCodecContext<?> choice) {
+        if (context instanceof ChoiceCodecContext<?> choice) {
             choice.addYangPathArgument(arg, builder);
 
             final var caseType = arg.getCaseType();
index 5a36251901cce18f614b6969c504fc94f431a55a..702036b509b2f6a33fe8a2c6a290e241ce0d1712 100644 (file)
@@ -314,7 +314,7 @@ public final class BindingCodecContext extends AbstractBindingNormalizedNodeSeri
                 // We enter list, we do not update current Node yet,
                 // since we need to verify
                 currentList = listNode;
-            } else if (nextNode instanceof ChoiceNodeCodecContext) {
+            } else if (nextNode instanceof ChoiceCodecContext) {
                 // We do not add path argument for choice, since
                 // it is not supported by binding instance identifier.
                 currentNode = nextNode;
@@ -331,7 +331,7 @@ public final class BindingCodecContext extends AbstractBindingNormalizedNodeSeri
 
         // Algorithm ended in list as whole representation
         // we sill need to emit identifier for list
-        if (currentNode instanceof ChoiceNodeCodecContext) {
+        if (currentNode instanceof ChoiceCodecContext) {
             LOG.debug("Instance identifier targeting a choice is not representable ({})", dom);
             return null;
         }
@@ -95,9 +95,9 @@ import org.slf4j.LoggerFactory;
  * ambiguous reference and issue warn once when they are encountered -- tracking warning information in
  * {@link #ambiguousByCaseChildWarnings}.
  */
-final class ChoiceNodeCodecContext<D extends DataObject> extends DataContainerCodecContext<D, ChoiceRuntimeType>
+final class ChoiceCodecContext<D extends DataObject> extends DataContainerCodecContext<D, ChoiceRuntimeType>
         implements BindingDataObjectCodecTreeNode<D> {
-    private static final Logger LOG = LoggerFactory.getLogger(ChoiceNodeCodecContext.class);
+    private static final Logger LOG = LoggerFactory.getLogger(ChoiceCodecContext.class);
 
     private final ImmutableMap<NodeIdentifier, DataContainerCodecPrototype<?>> byYangCaseChild;
     private final ImmutableListMultimap<Class<?>, DataContainerCodecPrototype<?>> ambiguousByCaseChildClass;
@@ -105,7 +105,7 @@ final class ChoiceNodeCodecContext<D extends DataObject> extends DataContainerCo
     private final ImmutableMap<Class<?>, DataContainerCodecPrototype<?>> byClass;
     private final Set<Class<?>> ambiguousByCaseChildWarnings;
 
-    ChoiceNodeCodecContext(final DataContainerCodecPrototype<ChoiceRuntimeType> prototype) {
+    ChoiceCodecContext(final DataContainerCodecPrototype<ChoiceRuntimeType> prototype) {
         super(prototype);
         final var byYangCaseChildBuilder = new HashMap<NodeIdentifier, DataContainerCodecPrototype<?>>();
         final var byClassBuilder = new HashMap<Class<?>, DataContainerCodecPrototype<?>>();
index 81ebb79ae514e553899ef09ac7c98af12446136e..af08f5d4a4b109a86378fa3d193985c42d520699 100644 (file)
@@ -99,7 +99,7 @@ final class CodecDataObjectAnalysis<R extends CompositeRuntimeType> {
             // FIXME: It really feels like we should be specializing DataContainerCodecPrototype so as to ditch
             //        createInstance() and then we could do an instanceof check instead.
             if (childProto.getType() instanceof ChoiceRuntimeType) {
-                final var choice = (ChoiceNodeCodecContext<?>) childProto.get();
+                final var choice = (ChoiceCodecContext<?>) childProto.get();
                 for (var cazeChild : choice.getCaseChildrenClasses()) {
                     byBindingArgClassBuilder.put(cazeChild, childProto);
                 }
index 1b1478d15023b9d7de1191558ef4bdcb66df01b0..f4c014acf91daa2cf1e908f251f8bff9fa21e059 100644 (file)
@@ -57,7 +57,7 @@ import org.slf4j.LoggerFactory;
 
 abstract sealed class DataContainerCodecContext<D extends DataObject, T extends RuntimeTypeContainer>
         extends CodecContext implements CommonDataObjectCodecTreeNode<D>
-        permits AbstractDataObjectCodecContext, ChoiceNodeCodecContext, RootCodecContext {
+        permits AbstractDataObjectCodecContext, ChoiceCodecContext, RootCodecContext {
     private static final Logger LOG = LoggerFactory.getLogger(DataContainerCodecContext.class);
     private static final VarHandle EVENT_STREAM_SERIALIZER;
 
index 3f5c6b52c19d729cf14b1c2801dd3c5d7df3cf1c..8a248e30b25e5ef4e1d1c1fad1cf512554d85c68 100644 (file)
@@ -58,7 +58,7 @@ non-sealed class DataObjectCodecPrototype<T extends RuntimeTypeContainer> extend
                     ? KeyedListNodeCodecContext.create((DataContainerCodecPrototype<ListRuntimeType>) this)
                             : new ListNodeCodecContext(this);
         } else if (type instanceof ChoiceRuntimeType) {
-            return new ChoiceNodeCodecContext(this);
+            return new ChoiceCodecContext(this);
         }
         throw new IllegalArgumentException("Unsupported type " + getBindingClass() + " " + type);
     }
index e677e28e989b1cac4847851a73861ebde4dce5ce..f49c3fdb661177644b29635edad3e4c988bcfc41 100644 (file)
@@ -102,10 +102,10 @@ final class RootCodecContext<D extends DataObject> extends DataContainerCodecCon
             }
         });
 
-    private final LoadingCache<Class<? extends DataObject>, ChoiceNodeCodecContext<?>> choicesByClass =
+    private final LoadingCache<Class<? extends DataObject>, ChoiceCodecContext<?>> choicesByClass =
         CacheBuilder.newBuilder().build(new CacheLoader<>() {
             @Override
-            public ChoiceNodeCodecContext<?> load(final Class<? extends DataObject> key) {
+            public ChoiceCodecContext<?> load(final Class<? extends DataObject> key) {
                 return createChoiceDataContext(key);
             }
         });
@@ -343,7 +343,7 @@ final class RootCodecContext<D extends DataObject> extends DataContainerCodecCon
         };
     }
 
-    ChoiceNodeCodecContext<?> createChoiceDataContext(final Class<? extends DataObject> caseType) {
+    ChoiceCodecContext<?> createChoiceDataContext(final Class<? extends DataObject> caseType) {
         final var choiceClass = findCaseChoice(caseType);
         if (choiceClass == null) {
             throw new IllegalArgumentException(caseType + " is not a valid case representation");
@@ -355,8 +355,8 @@ final class RootCodecContext<D extends DataObject> extends DataContainerCodecCon
         }
 
         final var choice = DataContainerCodecPrototype.from(choiceClass, choiceType, factory()).get();
-        verify(choice instanceof ChoiceNodeCodecContext);
-        return (ChoiceNodeCodecContext<?>) choice;
+        verify(choice instanceof ChoiceCodecContext);
+        return (ChoiceCodecContext<?>) choice;
     }
 
     @Override