Update binding-dom adaptation to remove AugmentationNode
[mdsal.git] / binding / mdsal-binding-dom-codec-api / src / main / java / org / opendaylight / mdsal / binding / dom / codec / api / BindingCodecTree.java
1 /*
2  * Copyright (c) 2015 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.mdsal.binding.dom.codec.api;
9
10 import static java.util.Objects.requireNonNull;
11
12 import com.google.common.annotations.Beta;
13 import org.eclipse.jdt.annotation.NonNull;
14 import org.eclipse.jdt.annotation.Nullable;
15 import org.opendaylight.yangtools.yang.binding.DataObject;
16 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
17 import org.opendaylight.yangtools.yang.common.Empty;
18 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
19 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
20
21 /**
22  * Navigable tree representing hierarchy of Binding to Normalized Node codecs. This navigable tree is associated to
23  * a concrete set of YANG models, represented by SchemaContext and provides access to subtree specific serialization
24  * context.
25  */
26 // TODO: Add more detailed documentation
27 public interface BindingCodecTree extends BindingDataObjectCodecTreeParent<Empty> {
28     /**
29      * A DTO holding a {@link CommonDataObjectCodecTreeNode} and the corresponding {@link YangInstanceIdentifier}.
30      *
31      * @param <T> {@link DataObject} type
32      */
33     record CodecWithPath<T extends DataObject>(
34             @NonNull CommonDataObjectCodecTreeNode<T> codec,
35             @NonNull YangInstanceIdentifier path) {
36         public CodecWithPath {
37             requireNonNull(codec);
38             requireNonNull(path);
39         }
40     }
41
42     /**
43      * Look up the codec for specified path, constructing the {@link YangInstanceIdentifier} corresponding to it.
44      *
45      * @param <T> DataObject type
46      * @param path Binding path
47      * @return A {@link CodecWithPath}
48      * @throws NullPointerException if {@code path} is {@code null}
49      * @throws IllegalArgumentException if the codec cannot be resolved
50      */
51     <T extends DataObject> @NonNull CodecWithPath<T> getSubtreeCodecWithPath(InstanceIdentifier<T> path);
52
53     /**
54      * Look up the codec for specified path.
55      *
56      * @param <T> DataObject type
57      * @param path Binding path
58      * @return A {@link BindingDataObjectCodecTreeNode}
59      * @throws NullPointerException if {@code path} is {@code null}
60      * @throws IllegalArgumentException if the codec cannot be resolved
61      */
62     <T extends DataObject> @NonNull CommonDataObjectCodecTreeNode<T> getSubtreeCodec(InstanceIdentifier<T> path);
63
64     // FIXME: NonNull and throwing exception
65     @Nullable BindingCodecTreeNode getSubtreeCodec(YangInstanceIdentifier path);
66
67     // FIXME: NonNull and throwing exception
68     @Nullable BindingCodecTreeNode getSubtreeCodec(Absolute path);
69
70     /**
71      * Get the {@link BindingIdentityCodec} associated with this tree.
72      *
73      * @return A BindingIdentityCodec instance.
74      */
75     @Beta
76     @NonNull BindingIdentityCodec getIdentityCodec();
77
78     /**
79      * Get the {@link BindingInstanceIdentifierCodec} associated with this tree.
80      *
81      * @return A BindingInstanceIdentifierCodec instance.
82      */
83     @Beta
84     @NonNull BindingInstanceIdentifierCodec getInstanceIdentifierCodec();
85 }