Add BindingDataObjectCodecTreeParent.getStream{Augmentation,DataObject}
[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.Augmentation;
16 import org.opendaylight.yangtools.yang.binding.DataObject;
17 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
18 import org.opendaylight.yangtools.yang.common.Empty;
19 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
20 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
21
22 /**
23  * Navigable tree representing hierarchy of Binding to Normalized Node codecs. This navigable tree is associated to
24  * a concrete set of YANG models, represented by SchemaContext and provides access to subtree specific serialization
25  * context.
26  */
27 // TODO: Add more detailed documentation
28 public interface BindingCodecTree extends BindingDataObjectCodecTreeParent<Empty> {
29     /**
30      * A DTO holding a {@link CommonDataObjectCodecTreeNode} and the corresponding {@link YangInstanceIdentifier}.
31      *
32      * @param <T> {@link DataObject} type
33      */
34     record CodecWithPath<T extends DataObject>(
35             @NonNull CommonDataObjectCodecTreeNode<T> codec,
36             @NonNull YangInstanceIdentifier path) {
37         public CodecWithPath {
38             requireNonNull(codec);
39             requireNonNull(path);
40         }
41     }
42
43     /**
44      * Look up the codec for specified augmentation path.
45      *
46      * @param <A> DataObject type
47      * @param path Binding path
48      * @return A {@link BindingAugmentationCodecTreeNode}
49      * @throws NullPointerException if {@code path} is {@code null}
50      * @throws IllegalArgumentException if the codec cannot be resolved
51      */
52     <A extends Augmentation<?>> @NonNull BindingAugmentationCodecTreeNode<A> getAugmentationCodec(
53         InstanceIdentifier<A> path);
54
55     /**
56      * Look up the codec for specified ordinary DataObject path.
57      *
58      * @param <T> DataObject type
59      * @param path Binding path
60      * @return A {@link BindingDataObjectCodecTreeNode}
61      * @throws NullPointerException if {@code path} is {@code null}
62      * @throws IllegalArgumentException if the codec cannot be resolved or refers to an Augmentation
63      */
64     <T extends DataObject> @NonNull BindingDataObjectCodecTreeNode<T> getDataObjectCodec(InstanceIdentifier<T> path);
65
66     /**
67      * Look up the codec for specified path, constructing the {@link YangInstanceIdentifier} corresponding to it.
68      *
69      * @param <T> DataObject type
70      * @param path Binding path
71      * @return A {@link CodecWithPath}
72      * @throws NullPointerException if {@code path} is {@code null}
73      * @throws IllegalArgumentException if the codec cannot be resolved
74      */
75     <T extends DataObject> @NonNull CodecWithPath<T> getSubtreeCodecWithPath(InstanceIdentifier<T> path);
76
77     /**
78      * Look up the codec for specified path.
79      *
80      * @param <T> DataObject type
81      * @param path Binding path
82      * @return A {@link BindingDataObjectCodecTreeNode}
83      * @throws NullPointerException if {@code path} is {@code null}
84      * @throws IllegalArgumentException if the codec cannot be resolved
85      */
86     <T extends DataObject> @NonNull CommonDataObjectCodecTreeNode<T> getSubtreeCodec(InstanceIdentifier<T> path);
87
88     // FIXME: NonNull and throwing exception
89     @Nullable BindingCodecTreeNode getSubtreeCodec(YangInstanceIdentifier path);
90
91     // FIXME: NonNull and throwing exception
92     @Nullable BindingCodecTreeNode getSubtreeCodec(Absolute path);
93
94     /**
95      * Get the {@link BindingIdentityCodec} associated with this tree.
96      *
97      * @return A BindingIdentityCodec instance.
98      */
99     @Beta
100     @NonNull BindingIdentityCodec getIdentityCodec();
101
102     /**
103      * Get the {@link BindingInstanceIdentifierCodec} associated with this tree.
104      *
105      * @return A BindingInstanceIdentifierCodec instance.
106      */
107     @Beta
108     @NonNull BindingInstanceIdentifierCodec getInstanceIdentifierCodec();
109 }