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;
@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();
- }
}
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;
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) {
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) {
}
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;
- }
}
* </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.
*