Add NormalizedNodeContainer.size()
[yangtools.git] / yang / yang-data-impl / src / main / java / org / opendaylight / yangtools / yang / data / impl / schema / builder / impl / ImmutableMapNodeBuilder.java
index d55c97ffae471c1e3f1aab3a37978f5fa65abd18..8152a2e3b01615a63ac28cc7a81bc3c5d8505208 100644 (file)
@@ -12,7 +12,7 @@ import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Optional;
-import org.opendaylight.yangtools.concepts.Immutable;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.util.MapAdaptor;
 import org.opendaylight.yangtools.util.UnmodifiableCollection;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
@@ -47,11 +47,11 @@ public class ImmutableMapNodeBuilder implements CollectionNodeBuilder<MapEntryNo
         this.value = MapAdaptor.getDefaultInstance().takeSnapshot(node.children);
     }
 
-    public static CollectionNodeBuilder<MapEntryNode, MapNode> create() {
+    public static @NonNull CollectionNodeBuilder<MapEntryNode, MapNode> create() {
         return new ImmutableMapNodeBuilder();
     }
 
-    public static CollectionNodeBuilder<MapEntryNode, MapNode> create(final int sizeHint) {
+    public static @NonNull CollectionNodeBuilder<MapEntryNode, MapNode> create(final int sizeHint) {
         return new ImmutableMapNodeBuilder(sizeHint);
     }
 
@@ -76,9 +76,9 @@ public class ImmutableMapNodeBuilder implements CollectionNodeBuilder<MapEntryNo
     }
 
     @Override
-    public CollectionNodeBuilder<MapEntryNode, MapNode> withValue(final Collection<MapEntryNode> value) {
+    public CollectionNodeBuilder<MapEntryNode, MapNode> withValue(final Collection<MapEntryNode> withValue) {
         // TODO replace or putAll ?
-        for (final MapEntryNode mapEntryNode : value) {
+        for (final MapEntryNode mapEntryNode : withValue) {
             withChild(mapEntryNode);
         }
 
@@ -86,8 +86,8 @@ public class ImmutableMapNodeBuilder implements CollectionNodeBuilder<MapEntryNo
     }
 
     @Override
-    public CollectionNodeBuilder<MapEntryNode, MapNode> withNodeIdentifier(final NodeIdentifier nodeIdentifier) {
-        this.nodeIdentifier = nodeIdentifier;
+    public CollectionNodeBuilder<MapEntryNode, MapNode> withNodeIdentifier(final NodeIdentifier withNodeIdentifier) {
+        this.nodeIdentifier = withNodeIdentifier;
         return this;
     }
 
@@ -102,7 +102,6 @@ public class ImmutableMapNodeBuilder implements CollectionNodeBuilder<MapEntryNo
         return withChild(child);
     }
 
-
     @Override
     public NormalizedNodeContainerBuilder<NodeIdentifier, PathArgument, MapEntryNode, MapNode> removeChild(
             final PathArgument key) {
@@ -110,8 +109,7 @@ public class ImmutableMapNodeBuilder implements CollectionNodeBuilder<MapEntryNo
     }
 
     protected static final class ImmutableMapNode
-            extends AbstractImmutableNormalizedNode<NodeIdentifier, Collection<MapEntryNode>>
-            implements Immutable, MapNode {
+            extends AbstractImmutableNormalizedNode<NodeIdentifier, Collection<MapEntryNode>> implements MapNode {
 
         private final Map<NodeIdentifierWithPredicates, MapEntryNode> children;
 
@@ -131,6 +129,11 @@ public class ImmutableMapNodeBuilder implements CollectionNodeBuilder<MapEntryNo
             return UnmodifiableCollection.create(children.values());
         }
 
+        @Override
+        public int size() {
+            return children.size();
+        }
+
         @Override
         protected int valueHashCode() {
             return children.hashCode();