d48f2b8323a852daa8a002a1604cb831e3a87329
[yangtools.git] / data / yang-data-api / src / main / java / org / opendaylight / yangtools / yang / data / api / schema / MapNode.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.yangtools.yang.data.api.schema;
9
10 import com.google.common.annotations.Beta;
11 import java.util.Collection;
12 import java.util.Map;
13 import org.eclipse.jdt.annotation.NonNull;
14 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
15 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
16
17 /**
18  * Containment node, which contains {@link MapEntryNode} of the same type, which may be quickly retrieved using a key.
19  *
20  * <p>
21  * This node maps to the list node in YANG schema, schema and semantics of this node, its children and key construction
22  * is defined by YANG {@code list} statement and its {@code key} and {@code ordered-by} substatements.
23  */
24 public interface MapNode
25         extends DistinctNodeContainer<NodeIdentifierWithPredicates, MapEntryNode>, DataContainerChild, MixinNode {
26     @Override
27     Class<? extends MapNode> contract();
28
29     @Override
30     NodeIdentifier getIdentifier();
31
32     /**
33      * Return a {@link Map} view of this node. Note that the iteration order of the returned is map is not defined in
34      * this interface.
35      *
36      * @return Map view of this node.
37      */
38     @Beta
39     @NonNull Map<NodeIdentifierWithPredicates, MapEntryNode> asMap();
40
41     @Override
42     default Collection<@NonNull MapEntryNode> body() {
43         return asMap().values();
44     }
45
46     @Override
47     default int size() {
48         return asMap().size();
49     }
50
51     @Override
52     default boolean isEmpty() {
53         return asMap().isEmpty();
54     }
55 }