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 org.eclipse.jdt.annotation.NonNull;
13 import org.eclipse.jdt.annotation.Nullable;
14 import org.opendaylight.yangtools.yang.binding.Augmentation;
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;
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
26 // TODO: Add more detailed documentation
27 public interface BindingCodecTree extends BindingDataObjectCodecTreeParent<Empty> {
29 * A DTO holding a {@link CommonDataObjectCodecTreeNode} and the corresponding {@link YangInstanceIdentifier}.
31 * @param <T> {@link DataObject} type
33 record CodecWithPath<T extends DataObject>(
34 @NonNull CommonDataObjectCodecTreeNode<T> codec,
35 @NonNull YangInstanceIdentifier path) {
36 public CodecWithPath {
37 requireNonNull(codec);
43 * Look up the codec for specified augmentation path.
45 * @param <A> DataObject type
46 * @param path Binding path
47 * @return A {@link BindingAugmentationCodecTreeNode}
48 * @throws NullPointerException if {@code path} is {@code null}
49 * @throws IllegalArgumentException if the codec cannot be resolved
51 <A extends Augmentation<?>> @NonNull BindingAugmentationCodecTreeNode<A> getAugmentationCodec(
52 InstanceIdentifier<A> path);
55 * Look up the codec for specified ordinary DataObject path.
57 * @param <T> DataObject type
58 * @param path Binding path
59 * @return A {@link BindingDataObjectCodecTreeNode}
60 * @throws NullPointerException if {@code path} is {@code null}
61 * @throws IllegalArgumentException if the codec cannot be resolved or refers to an Augmentation
63 <T extends DataObject> @NonNull BindingDataObjectCodecTreeNode<T> getDataObjectCodec(InstanceIdentifier<T> path);
66 * Look up the codec for specified path, constructing the {@link YangInstanceIdentifier} corresponding to it.
68 * @param <T> DataObject type
69 * @param path Binding path
70 * @return A {@link CodecWithPath}
71 * @throws NullPointerException if {@code path} is {@code null}
72 * @throws IllegalArgumentException if the codec cannot be resolved
74 <T extends DataObject> @NonNull CodecWithPath<T> getSubtreeCodecWithPath(InstanceIdentifier<T> path);
77 * Look up the codec for specified path.
79 * @param <T> DataObject type
80 * @param path Binding path
81 * @return A {@link BindingDataObjectCodecTreeNode}
82 * @throws NullPointerException if {@code path} is {@code null}
83 * @throws IllegalArgumentException if the codec cannot be resolved
85 <T extends DataObject> @NonNull CommonDataObjectCodecTreeNode<T> getSubtreeCodec(InstanceIdentifier<T> path);
87 // FIXME: NonNull and throwing exception
88 @Nullable BindingCodecTreeNode getSubtreeCodec(YangInstanceIdentifier path);
90 // FIXME: NonNull and throwing exception
91 @Nullable BindingCodecTreeNode getSubtreeCodec(Absolute path);
94 * Get the {@link BindingIdentityCodec} associated with this tree.
96 * @return A BindingIdentityCodec instance.
98 @NonNull BindingIdentityCodec getIdentityCodec();
101 * Get the {@link BindingInstanceIdentifierCodec} associated with this tree.
103 * @return A BindingInstanceIdentifierCodec instance.
105 @NonNull BindingInstanceIdentifierCodec getInstanceIdentifierCodec();