Move addYangPathArgument() 65/105565/3
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 21 Apr 2023 00:04:11 +0000 (02:04 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 15 May 2023 21:23:06 +0000 (23:23 +0200)
This method is only used for DataContainerCodecContext, there is just no
reason to pollute NodeCodecContext with this method. Reduces coupling
towards YangInstanceIdentifier.PathArgument a tiny bit.

Change-Id: Iecbb7c11f28a49282d6224229890f63eab33b311
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/CaseNodeCodecContext.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/KeyedListNodeCodecContext.java
binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/NodeCodecContext.java

index d93325a6905cb39b6ae0ecbc03cb2e2fc81fce1f..804640f03bbb6f0736f33077fbade2a9b45b2b6d 100644 (file)
@@ -35,8 +35,7 @@ final class CaseNodeCodecContext<D extends DataObject> extends DataObjectCodecCo
     }
 
     @Override
-    protected void addYangPathArgument(final PathArgument arg,
-            final List<YangInstanceIdentifier.PathArgument> builder) {
+    void addYangPathArgument(final PathArgument arg, final List<YangInstanceIdentifier.PathArgument> builder) {
         // NOOP
     }
 
index eade7cdcdce201f135140c5880faa839409702b5..413209aa0062ae79e54477824e10d6134d2a812f 100644 (file)
@@ -97,7 +97,7 @@ abstract class DataContainerCodecContext<D extends DataObject, T extends Runtime
     }
 
     @Override
-    protected YangInstanceIdentifier.PathArgument getDomPathArgument() {
+    protected final YangInstanceIdentifier.PathArgument getDomPathArgument() {
         return prototype.getYangArg();
     }
 
@@ -122,13 +122,25 @@ abstract class DataContainerCodecContext<D extends DataObject, T extends Runtime
     @Override
     public DataContainerCodecContext<?, ?> bindingPathArgumentChild(final PathArgument arg,
             final List<YangInstanceIdentifier.PathArgument> builder) {
-        final DataContainerCodecContext<?,?> child = streamChild(arg.getType());
+        final DataContainerCodecContext<?, ?> child = streamChild(arg.getType());
         if (builder != null) {
-            child.addYangPathArgument(arg,builder);
+            child.addYangPathArgument(arg, builder);
         }
         return child;
     }
 
+    /**
+     * Serializes supplied Binding Path Argument and adds all necessary YANG instance identifiers to supplied list.
+     *
+     * @param arg Binding Path Argument
+     * @param builder DOM Path argument.
+     */
+    void addYangPathArgument(final PathArgument arg, final List<YangInstanceIdentifier.PathArgument> builder) {
+        if (builder != null) {
+            builder.add(getDomPathArgument());
+        }
+    }
+
     /**
      * Returns deserialized Binding Path Argument from YANG instance identifier.
      */
index 9b62032a854410b198faf44ff3cf91d9b844d557..67dd1b5ad9dc110006c96f2d788267b686991ec5 100644 (file)
@@ -74,7 +74,7 @@ abstract class KeyedListNodeCodecContext<I extends Identifier<D>, D extends Data
     }
 
     @Override
-    protected void addYangPathArgument(final InstanceIdentifier.PathArgument arg,
+    void addYangPathArgument(final InstanceIdentifier.PathArgument arg,
             final List<YangInstanceIdentifier.PathArgument> builder) {
         /*
          * DOM Instance Identifier for list is always represent by two entries one for map and one for children. This
@@ -85,8 +85,8 @@ abstract class KeyedListNodeCodecContext<I extends Identifier<D>, D extends Data
         }
 
         super.addYangPathArgument(arg, builder);
-        if (arg instanceof IdentifiableItem) {
-            builder.add(codec.bindingToDom((IdentifiableItem<?, ?>) arg));
+        if (arg instanceof IdentifiableItem<?, ?> identifiable) {
+            builder.add(codec.bindingToDom(identifiable));
         } else {
             // Adding wildcarded
             super.addYangPathArgument(arg, builder);
index de20d86e6179b67d2ea85f2bc54d6d11b5ebac21..bf7ecc06367fdf0fd86a732c9c76e2b9156cfcfd 100644 (file)
@@ -9,14 +9,12 @@ package org.opendaylight.mdsal.binding.dom.codec.impl;
 
 import com.google.common.collect.ImmutableMap;
 import java.lang.reflect.Method;
-import java.util.List;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.mdsal.binding.dom.codec.api.BindingCodecTreeNode;
 import org.opendaylight.mdsal.binding.loader.BindingClassLoader;
 import org.opendaylight.mdsal.binding.runtime.api.BindingRuntimeContext;
 import org.opendaylight.mdsal.binding.runtime.api.ListRuntimeType;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
@@ -87,19 +85,6 @@ abstract class NodeCodecContext implements BindingCodecTreeNode {
         DataObjectSerializer getEventStreamSerializer(Class<?> type);
     }
 
-    /**
-     * Serializes supplied Binding Path Argument and adds all necessary YANG instance identifiers to supplied list.
-     *
-     * @param arg Binding Path Argument
-     * @param builder DOM Path argument.
-     */
-    protected void addYangPathArgument(final InstanceIdentifier.PathArgument arg,
-            final List<YangInstanceIdentifier.PathArgument> builder) {
-        if (builder != null) {
-            builder.add(getDomPathArgument());
-        }
-    }
-
     /**
      * Return the default value object. Implementations of this method are explicitly allowed to throw unchecked
      * exceptions, which are propagated as-is upwards the stack.