Seal {LeafSet,Map}Node
[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 sealed interface MapNode
25         extends DistinctNodeContainer<NodeIdentifierWithPredicates, MapEntryNode>, DataContainerChild, MixinNode
26         permits SystemMapNode, UserMapNode {
27     @Override
28     Class<? extends MapNode> contract();
29
30     @Override
31     NodeIdentifier getIdentifier();
32
33     /**
34      * Return a {@link Map} view of this node. Note that the iteration order of the returned is map is not defined in
35      * this interface.
36      *
37      * @return Map view of this node.
38      */
39     @Beta
40     @NonNull Map<NodeIdentifierWithPredicates, MapEntryNode> asMap();
41
42     @Override
43     default Collection<@NonNull MapEntryNode> body() {
44         return asMap().values();
45     }
46
47     @Override
48     default int size() {
49         return asMap().size();
50     }
51
52     @Override
53     default boolean isEmpty() {
54         return asMap().isEmpty();
55     }
56 }