Add NormalizedNode.contract()
[yangtools.git] / yang / yang-data-api / src / main / java / org / opendaylight / yangtools / yang / data / api / schema / MapNode.java
index d906050dea057a4053d4eff09d0c24c2edcb595c..d48f2b8323a852daa8a002a1604cb831e3a87329 100644 (file)
@@ -7,21 +7,49 @@
  */
 package org.opendaylight.yangtools.yang.data.api.schema;
 
+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, which may
- * be quickly retrieved using key.
- *
- * 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</code>
- * statement and its <code>key</code> and <code>ordered-by</code> substatements.
+ * 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
+    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();
+    }
 }