Bump to odlparent-9.0.0/yangtools-7.0.1-SNAPSHOT
[mdsal.git] / binding / mdsal-binding-dom-codec / src / main / java / org / opendaylight / mdsal / binding / dom / codec / impl / LeafSetNodeCodecContext.java
index 42253271e5d7b8c294176eeba75368f5e1b6305f..8ab953f844831c43cd109183f534862934262a3a 100644 (file)
@@ -9,48 +9,32 @@ 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.concepts.IllegalArgumentCodec;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
 
 final class LeafSetNodeCodecContext extends ValueNodeCodecContext.WithCodec {
-    LeafSetNodeCodecContext(final LeafListSchemaNode schema, final Codec<Object, Object> codec,
+    LeafSetNodeCodecContext(final LeafListSchemaNode schema, final IllegalArgumentCodec<Object, Object> codec,
         final String getterName) {
         // FIXME: add support for defaults
         super(schema, codec, getterName, null);
     }
 
     @Override
-    protected Object deserializeObject(final NormalizedNode<?, ?> normalizedNode) {
+    protected Object deserializeObject(final NormalizedNode normalizedNode) {
         if (normalizedNode instanceof LeafSetNode<?>) {
             @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 Collection<LeafSetEntryNode<Object>> domValues = ((LeafSetNode<Object>) normalizedNode).body();
+            final IllegalArgumentCodec<Object, Object> codec = getValueCodec();
+            final Builder<Object> builder = ImmutableList.builderWithExpectedSize(domValues.size());
+            for (final LeafSetEntryNode<Object> valueNode : domValues) {
+                builder.add(codec.deserialize(valueNode.body()));
+            }
+            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();
-    }
 }