Integrate rfc7952-data-api into yang-data-api
[yangtools.git] / data / yang-data-api / src / main / java / org / opendaylight / yangtools / yang / data / api / schema / NormalizedMetadata.java
1 /*
2  * Copyright (c) 2019 PANTHEON.tech, s.r.o. 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 com.google.common.collect.ImmutableMap;
12 import java.util.Map;
13 import org.eclipse.jdt.annotation.NonNull;
14 import org.opendaylight.yangtools.concepts.Identifiable;
15 import org.opendaylight.yangtools.concepts.Immutable;
16 import org.opendaylight.yangtools.yang.common.QName;
17 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
18
19 /**
20  * RFC7952 metadata counterpart to a {@link NormalizedNode}. This interface is meant to be used as a companion to
21  * a NormalizedNode instance, hence it does not support iterating over its structure like it is possible with
22  * {@link NormalizedNode#body()}. Children may be inquired through {@link #getChildren()}.
23  *
24  * <p>
25  * This model of metadata <em>does not</em> have the RFC7952 restriction on metadata attachment to {@code list}s and
26  * {@code leaf-list}s because NormalizedNode data model has {@link LeafSetNode}, {@link MapNode} and
27  * {@link UnkeyedListNode} to which metadata can be attached.
28  *
29  * @author Robert Varga
30  */
31 @Beta
32 public interface NormalizedMetadata extends Identifiable<PathArgument>, Immutable {
33     /**
34      * Return the set of annotations defined in this metadata node. Values are expected to be effectively-immutable
35      * scalar types, like {@link String}s, {@link Number}s and similar. The map must also be effectively-immutable.
36      *
37      * @return The set of annotations attached to the corresponding data node.
38      */
39     @NonNull Map<QName, Object> getAnnotations();
40
41     /**
42      * Returns child nodes. Default implementation returns an empty immutable map.
43      *
44      * @return Child metadata nodes.
45      */
46     default @NonNull Map<PathArgument, NormalizedMetadata> getChildren() {
47         return ImmutableMap.of();
48     }
49 }