Add NormalizedNode.contract()
[yangtools.git] / yang / yang-data-api / src / main / java / org / opendaylight / yangtools / yang / data / api / schema / MapNode.java
index eab5a121dee135263531de9e6546ac74f9844e83..d48f2b8323a852daa8a002a1604cb831e3a87329 100644 (file)
@@ -7,24 +7,49 @@
  */
 package org.opendaylight.yangtools.yang.data.api.schema;
 
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates;
+import com.google.common.annotations.Beta;
+import java.util.Collection;
+import java.util.Map;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 
 /**
- * Containment node, which contains {@link MapEntryNode} of the same type.
- *
- * This node maps to the list node in YANG schema.
+ * Containment node, which contains {@link MapEntryNode} of the same type, which may be quickly retrieved using a key.
  *
+ * <p>
+ * This node maps to the list node in YANG schema, schema and semantics of this node, its children and key construction
+ * is defined by YANG {@code list} statement and its {@code key} and {@code ordered-by} substatements.
  */
-public interface MapNode extends //
-        MixinNode,
-        DataContainerChild<NodeIdentifier, Iterable<MapEntryNode>>,
-        NormalizedNodeContainer<NodeIdentifier, NodeIdentifierWithPredicates, MapEntryNode> {
+public interface MapNode
+        extends DistinctNodeContainer<NodeIdentifierWithPredicates, MapEntryNode>, DataContainerChild, MixinNode {
+    @Override
+    Class<? extends MapNode> contract();
 
     @Override
-    public NodeIdentifier getIdentifier();
+    NodeIdentifier getIdentifier();
 
+    /**
+     * Return a {@link Map} view of this node. Note that the iteration order of the returned is map is not defined in
+     * this interface.
+     *
+     * @return Map view of this node.
+     */
+    @Beta
+    @NonNull Map<NodeIdentifierWithPredicates, MapEntryNode> asMap();
 
+    @Override
+    default Collection<@NonNull MapEntryNode> body() {
+        return asMap().values();
+    }
 
+    @Override
+    default int size() {
+        return asMap().size();
+    }
 
+    @Override
+    default boolean isEmpty() {
+        return asMap().isEmpty();
+    }
 }