Do not pretty-print body class
[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 org.eclipse.jdt.annotation.NonNull;
11 import org.opendaylight.yangtools.concepts.Identifiable;
12 import org.opendaylight.yangtools.concepts.PrettyTreeAware;
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 /*
23  * FIXME: 8.0.0: NormalizedNode represents the perfectly-compliant view of the data, as evaluated by an implementation,
24  *               which is currently singular, with respect of its interpretation of a SchemaContext. This includes
25  *               leaf values, which are required to hold normalized representation for a particular implementation,
26  *               which may be affected by its understanding of any YANG extensions present -- such as optional type
27  *               handling hints and bindings.
28  *
29  *               Implementations (i.e. the reference implementation and parsers) will need to start using
30  *               yang.common.Uint8 and friends and, if possible, express data validation in terms
31  *               of yang.common.CanonicalValue and yang.common.CanonicalValueValidator.
32  *
33  *               This notably means that to efficiently implement any sort of lenient parsing, we need a separate
34  *               concept which contains an unverified, potentially non-conformant data tree, which the consumer needs
35  *               to check/fixup if it wishes to use it as a NormalizedNode. Such a concept should be called
36  *               "UnverifiedData".
37  *
38  * FIXME: 8.0.0: Once we have UnverifiedData, we should really rename this to "NormalizedData" or similar to unload
39  *               some "Node" ambiguity. "Node" should be a generic term reserved for a particular domain -- hence 'node'
40  *               can be used to refer to either a 'schema node' in context of yang.model.api, or to
41  *               a 'normalized data node' in context of yang.data.api.
42  *
43  * FIXME: 8.0.0: Well, not quite. The structure of unverified data is really codec specific -- and JSON and XML
44  *               do not agree on details. Furthermore things get way more complicated when we have a cross-schema
45  *               boundary -- like RFC8528. Hence we cannot really have a reasonably-structured concept of unverified
46  *               data. Nevertheless, this interface should be named 'NormalizedData'.
47  */
48 public interface NormalizedNode extends Identifiable<PathArgument>, PrettyTreeAware {
49     @Override
50     // We override here, so that NormalizedNode.getIdentifier() has fewer implementations
51     PathArgument getIdentifier();
52
53     /**
54      * Return the contract governing this {@link NormalizedNode} instance.
55      *
56      * @apiNote
57      *     This method should be specialized in intermediate contracts like {@link MapNode} and implemented as a default
58      *     method by interfaces which form the contracts themselves, for example {@link ContainerNode}, {@link LeafNode}
59      *     and similar.
60      *
61      * @return A class identifying the NormalizedNode contract.
62      */
63     @NonNull Class<? extends NormalizedNode> contract();
64
65     /**
66      * Returns the body of this node. While the return value specifies {@link Object}, this method's return value has
67      * further semantics. The returned object must be a well-published contract, such as {@code String},
68      * {@code Collection<NormalizedNode>} or {@code DOMSource}.
69      *
70      * @return Returned value of this node.
71      */
72     @NonNull Object body();
73 }