Remove the ability to return mutable lists 06/82306/7
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 29 May 2019 12:07:21 +0000 (14:07 +0200)
committerRobert Varga <nite@hq.sk>
Mon, 19 Aug 2019 15:47:37 +0000 (15:47 +0000)
This patch removes the legacy opt-in to return mutable lists instead
of immutable ones.

JIRA: MDSAL-446
Change-Id: I73c09e036f8c3f92d27e6706ef4133da2c4232a2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/LeafSetNodeCodecContext.java
binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/ListNodeCodecContext.java
binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/NodeCodecContext.java

index 42253271e5d7b8c294176eeba75368f5e1b6305f..0d887abc2f150e0644b85cd34d80cbbcb03b9cf5 100644 (file)
@@ -9,9 +9,7 @@ package org.opendaylight.mdsal.binding.dom.codec.impl;
 
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableList.Builder;
-import java.util.ArrayList;
 import java.util.Collection;
-import java.util.List;
 import org.opendaylight.yangtools.concepts.Codec;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode;
@@ -31,26 +29,12 @@ final class LeafSetNodeCodecContext extends ValueNodeCodecContext.WithCodec {
             @SuppressWarnings("unchecked")
             final Collection<LeafSetEntryNode<Object>> domValues = ((LeafSetNode<Object>) normalizedNode).getValue();
             final Codec<Object, Object> codec = getValueCodec();
-            return COMPAT_MUTABLE_LISTS ? createMutableList(codec, domValues) : createImmutableList(codec, domValues);
+            final Builder<Object> builder = ImmutableList.builderWithExpectedSize(domValues.size());
+            for (final LeafSetEntryNode<Object> valueNode : domValues) {
+                builder.add(codec.deserialize(valueNode.getValue()));
+            }
+            return builder.build();
         }
         return null;
     }
-
-    private static List<Object> createMutableList(final Codec<Object, Object> codec,
-            final Collection<LeafSetEntryNode<Object>> domValues) {
-        final List<Object> result = new ArrayList<>(domValues.size());
-        for (final LeafSetEntryNode<Object> valueNode : domValues) {
-            result.add(codec.deserialize(valueNode.getValue()));
-        }
-        return result;
-    }
-
-    private static ImmutableList<Object> createImmutableList(final Codec<Object, Object> codec,
-            final Collection<LeafSetEntryNode<Object>> domValues) {
-        final Builder<Object> builder = ImmutableList.builderWithExpectedSize(domValues.size());
-        for (final LeafSetEntryNode<Object> valueNode : domValues) {
-            builder.add(codec.deserialize(valueNode.getValue()));
-        }
-        return builder.build();
-    }
 }
index c937f20d1c2ca0d2f8096823f1d38617b03a0a83..9d38ded24d93fc7e5eb2e8e700779a72658db84c 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.mdsal.binding.dom.codec.impl;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableList.Builder;
 import java.lang.reflect.Method;
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import org.opendaylight.yangtools.yang.binding.DataObject;
@@ -59,19 +58,6 @@ class ListNodeCodecContext<D extends DataObject> extends DataObjectCodecContext<
 
     private List<D> fromMap(final MapNode nodes) {
         final Collection<MapEntryNode> value = nodes.getValue();
-        return COMPAT_MUTABLE_LISTS ? mutableFromMap(value) : immutableFromMap(value);
-    }
-
-    @Deprecated
-    private List<D> mutableFromMap(final Collection<MapEntryNode> value) {
-        final List<D> ret = new ArrayList<>(value.size());
-        for (MapEntryNode node : value) {
-            ret.add(fromMapEntry(node));
-        }
-        return ret;
-    }
-
-    private ImmutableList<D> immutableFromMap(final Collection<MapEntryNode> value) {
         final Builder<D> builder = ImmutableList.builderWithExpectedSize(value.size());
         // FIXME: Could be this lazy transformed list?
         for (MapEntryNode node : value) {
@@ -90,10 +76,6 @@ class ListNodeCodecContext<D extends DataObject> extends DataObjectCodecContext<
 
     private List<D> fromUnkeyedList(final UnkeyedListNode nodes) {
         final Collection<UnkeyedListEntryNode> value = nodes.getValue();
-        return COMPAT_MUTABLE_LISTS ? mutableUnkeyedList(value) : immutableUnkeyedList(value);
-    }
-
-    private ImmutableList<D> immutableUnkeyedList(final Collection<UnkeyedListEntryNode> value) {
         // FIXME: Could be this lazy transformed list?
         final Builder<D> builder = ImmutableList.builderWithExpectedSize(value.size());
         for (UnkeyedListEntryNode node : value) {
@@ -101,13 +83,4 @@ class ListNodeCodecContext<D extends DataObject> extends DataObjectCodecContext<
         }
         return builder.build();
     }
-
-    @Deprecated
-    private List<D> mutableUnkeyedList(final Collection<UnkeyedListEntryNode> value) {
-        final List<D> ret = new ArrayList<>(value.size());
-        for (UnkeyedListEntryNode node : value) {
-            ret.add(fromUnkeyedListEntry(node));
-        }
-        return ret;
-    }
 }
index 2820b352f45425d7ef193a9fc653d7c93468d3cf..dade657723b2633710959a2eb349120e674f9932 100644 (file)
@@ -36,13 +36,6 @@ import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
  * </ul>
  */
 abstract class NodeCodecContext implements BindingCodecTreeNode {
-    /**
-     * Transition runtime constant to allow choosing between legacy mutable lists and immutable lists.
-     */
-    // FIXME: 5.0.0: MDSAL-446: remove this knob completely
-    static final boolean COMPAT_MUTABLE_LISTS = Boolean.getBoolean(
-        "org.opendaylight.mdsal.binding.dom.codec.impl.compat-mutable-lists");
-
     /**
      * Returns Yang Instance Identifier Path Argument of current node.
      *