2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.mdsal.binding.dom.codec.api;
10 import static java.util.Objects.requireNonNull;
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;
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
27 // TODO: Add more detailed documentation
28 public interface BindingCodecTree extends BindingDataObjectCodecTreeParent<Empty> {
30 * A DTO holding a {@link CommonDataObjectCodecTreeNode} and the corresponding {@link YangInstanceIdentifier}.
32 * @param <T> {@link DataObject} type
34 record CodecWithPath<T extends DataObject>(
35 @NonNull CommonDataObjectCodecTreeNode<T> codec,
36 @NonNull YangInstanceIdentifier path) {
37 public CodecWithPath {
38 requireNonNull(codec);
44 * Look up the codec for specified augmentation path.
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
52 <A extends Augmentation<?>> @NonNull BindingAugmentationCodecTreeNode<A> getAugmentationCodec(
53 InstanceIdentifier<A> path);
56 * Look up the codec for specified ordinary DataObject path.
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
64 <T extends DataObject> @NonNull BindingDataObjectCodecTreeNode<T> getDataObjectCodec(InstanceIdentifier<T> path);
67 * Look up the codec for specified path, constructing the {@link YangInstanceIdentifier} corresponding to it.
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
75 <T extends DataObject> @NonNull CodecWithPath<T> getSubtreeCodecWithPath(InstanceIdentifier<T> path);
78 * Look up the codec for specified path.
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
86 <T extends DataObject> @NonNull CommonDataObjectCodecTreeNode<T> getSubtreeCodec(InstanceIdentifier<T> path);
88 // FIXME: NonNull and throwing exception
89 @Nullable BindingCodecTreeNode getSubtreeCodec(YangInstanceIdentifier path);
91 // FIXME: NonNull and throwing exception
92 @Nullable BindingCodecTreeNode getSubtreeCodec(Absolute path);
95 * Get the {@link BindingIdentityCodec} associated with this tree.
97 * @return A BindingIdentityCodec instance.
100 @NonNull BindingIdentityCodec getIdentityCodec();
103 * Get the {@link BindingInstanceIdentifierCodec} associated with this tree.
105 * @return A BindingInstanceIdentifierCodec instance.
108 @NonNull BindingInstanceIdentifierCodec getInstanceIdentifierCodec();