Add yang-data-api API evolution guidance
[yangtools.git] / yang / yang-data-api / src / main / java / org / opendaylight / yangtools / yang / data / api / schema / NormalizedNode.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 javax.annotation.Nonnull;
11 import org.opendaylight.yangtools.concepts.Identifiable;
12 import org.opendaylight.yangtools.yang.common.QName;
13 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
14
15 /**
16  * Node which is normalized according to the YANG schema
17  * is identifiable by a {@link org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier}.
18  *
19  * <p>
20  * See subinterfaces of this interface for concretization of node.
21  *
22  * @param <K> Local identifier of node
23  * @param <V> Value of node
24  */
25 /*
26  * FIXME: 3.0.0: NormalizedNode represents the perfectly-compliant view of the data, as evaluated by an implementation,
27  *               which is currently singular, with respect of its interpretation of a SchemaContext. This includes
28  *               leaf values, which are required to hold normalized representation for a particular implementation,
29  *               which may be affected by its understanding of any YANG extensions present -- such as optional type
30  *               handling hints and bindings.
31  *
32  *               Implementations (i.e. the reference implementation and parsers) will need to start using
33  *               yang.common.Uint8 and friends and, if possible, express data validation in terms
34  *               of yang.common.CanonicalValue and yang.common.CanonicalValueValidator.
35  *
36  *               This notably means that to efficiently implement any sort of lenient parsing, we need a separate
37  *               concept which contains an unverified, potentially non-conformant data tree, which the consumer needs
38  *               to check/fixup if it wishes to use it as a NormalizedNode. Such a concept should be called
39  *               "UnverifiedData".
40  */
41 /*
42  * FIXME: 4.0.0: Once we have UnverifiedData, we should really rename this to "NormalizedData" or similar to unload
43  *               some "Node" ambiguity. "Node" should be a generic term reserved for a particular domain -- hence 'node'
44  *               can be used to refer to either a 'schema node' in context of yang.model.api, or to
45  *               a 'normalized data node' in context of yang.data.api.
46  */
47 public interface NormalizedNode<K extends PathArgument, V> extends Identifiable<K> {
48     /**
49      * QName of the node as defined in YANG schema.
50      *
51      * @return QName of this node, non-null.
52      */
53     QName getNodeType();
54
55     /**
56      * Locally unique identifier of the node.
57      *
58      * @return Node identifier, non-null.
59      */
60     @Override
61     @Nonnull K getIdentifier();
62
63     /**
64      * Value of node.
65      *
66      * @return Value of the node, may be null.
67      */
68     @Nonnull V getValue();
69 }