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 com.google.common.annotations.Beta;
11 import com.google.common.base.Optional;
12 import com.google.common.collect.ImmutableCollection;
13 import java.util.List;
14 import javax.annotation.Nonnull;
15 import javax.annotation.Nullable;
16 import org.opendaylight.yangtools.yang.binding.BindingStreamEventWriter;
17 import org.opendaylight.yangtools.yang.binding.DataObject;
18 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
19 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
20 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
23 * Subtree codec specific to model subtree between Java Binding and
27 public interface BindingCodecTreeNode<T extends DataObject> extends BindingNormalizedNodeCodec<T> {
30 * Returns binding class of interface which represents API of current
33 * The result is same as invoking {@link DataObject#getImplementedInterface()}
34 * on instance of data.
36 * @return interface which defines API of binding representation of data.
39 Class<T> getBindingClass();
42 * Returns child context as if it was walked by
43 * {@link BindingStreamEventWriter}. This means that to enter case, one must
44 * issue getChild(ChoiceClass).getChild(CaseClass).
46 * @param childClass Child class by Biding Stream navigation
47 * @return Context of child
48 * @throws IllegalArgumentException
49 * If supplied child class is not valid in specified context.
52 <E extends DataObject> BindingCodecTreeNode<E> streamChild(@Nonnull Class<E> childClass);
55 * Returns child context as if it was walked by
56 * {@link BindingStreamEventWriter}. This means that to enter case, one must
57 * issue getChild(ChoiceClass).getChild(CaseClass).
59 * This method differs from {@link #streamChild(Class)}, that is less
60 * stricter for interfaces representing augmentation and cases, that
61 * may return {@link BindingCodecTreeNode} even if augmentation interface
62 * containing same data was supplied and does not represent augmentation
66 * @return Context of child or Optional absent is supplied class is not
67 * applicable in context.
69 <E extends DataObject> Optional<? extends BindingCodecTreeNode<E>> possibleStreamChild(@Nonnull Class<E> childClass);
72 * Returns nested node context using supplied YANG Instance Identifier
75 * Yang Instance Identifier Argument
76 * @return Context of child
77 * @throws IllegalArgumentException
78 * If supplied argument does not represent valid child.
81 BindingCodecTreeNode<?> yangPathArgumentChild(@Nonnull YangInstanceIdentifier.PathArgument child);
84 * Returns nested node context using supplied Binding Instance Identifier
85 * and adds YANG instance identifiers to supplied list.
88 * Binding Instance Identifier Argument
90 * Mutable instance of list, which is appended by YangInstanceIdentifiers
91 * as tree is walked. Use null if such side-product is not needed.
92 * @return Context of child
93 * @throws IllegalArgumentException
94 * If supplied argument does not represent valid child.
97 BindingCodecTreeNode<?> bindingPathArgumentChild(@Nonnull InstanceIdentifier.PathArgument arg,
98 @Nullable List<YangInstanceIdentifier.PathArgument> builder);
101 * Returns codec which uses caches serialization / deserialization results
103 * Caching may introduce performance penalty to serialization / deserialization
104 * but may decrease use of heap for repetitive objects.
107 * @param cacheSpecifier Set of objects, for which cache may be in place
108 * @return Codec whihc uses cache for serialization / deserialization.
111 BindingNormalizedNodeCachingCodec<T> createCachingCodec(@Nonnull
112 ImmutableCollection<Class<? extends DataObject>> cacheSpecifier);
115 void writeAsNormalizedNode(T data, NormalizedNodeStreamWriter writer);
118 * Serializes path argument for current node.
120 * @param arg Binding Path Argument, may be null if Binding Instance Identifier does not have
121 * representation for current node (e.g. choice or case).
122 * @return Yang Path Argument, may be null if Yang Instance Identifier does not have
123 * representation for current node (e.g. case).
124 * @throws IllegalArgumentException If supplied {@code arg} is not valid.
127 @Nullable YangInstanceIdentifier.PathArgument serializePathArgument(@Nullable InstanceIdentifier.PathArgument arg);
130 * Deserializes path argument for current node.
132 * @param arg Yang Path Argument, may be null if Yang Instance Identifier does not have
133 * representation for current node (e.g. case).
134 * @return Binding Path Argument, may be null if Binding Instance Identifier does not have
135 * representation for current node (e.g. choice or case).
136 * @throws IllegalArgumentException If supplied {@code arg} is not valid.
139 @Nullable InstanceIdentifier.PathArgument deserializePathArgument(@Nullable YangInstanceIdentifier.PathArgument arg);