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
28 public interface BindingCodecTreeNode<T extends DataObject> extends BindingNormalizedNodeCodec<T>,
29 org.opendaylight.yangtools.binding.data.codec.api.BindingCodecTreeNode<T> {
33 * Returns binding class of interface which represents API of current
36 * The result is same as invoking {@link DataObject#getImplementedInterface()}
37 * on instance of data.
39 * @return interface which defines API of binding representation of data.
43 Class<T> getBindingClass();
47 * Returns child context as if it was walked by
48 * {@link BindingStreamEventWriter}. This means that to enter case, one must
49 * issue getChild(ChoiceClass).getChild(CaseClass).
51 * @param childClass Child class by Biding Stream navigation
52 * @return Context of child
53 * @throws IllegalArgumentException
54 * If supplied child class is not valid in specified context.
58 <E extends DataObject> BindingCodecTreeNode<E> streamChild(@Nonnull Class<E> childClass);
62 * Returns child context as if it was walked by
63 * {@link BindingStreamEventWriter}. This means that to enter case, one must
64 * issue getChild(ChoiceClass).getChild(CaseClass).
66 * This method differs from {@link #streamChild(Class)}, that is less
67 * stricter for interfaces representing augmentation and cases, that
68 * may return {@link BindingCodecTreeNode} even if augmentation interface
69 * containing same data was supplied and does not represent augmentation
73 * @return Context of child or Optional absent is supplied class is not
74 * applicable in context.
77 <E extends DataObject> Optional<? extends BindingCodecTreeNode<E>> possibleStreamChild(@Nonnull Class<E> childClass);
80 * Returns nested node context using supplied YANG Instance Identifier
83 * Yang Instance Identifier Argument
84 * @return Context of child
85 * @throws IllegalArgumentException
86 * If supplied argument does not represent valid child.
90 BindingCodecTreeNode<?> yangPathArgumentChild(@Nonnull YangInstanceIdentifier.PathArgument child);
93 * Returns nested node context using supplied Binding Instance Identifier
94 * and adds YANG instance identifiers to supplied list.
97 * Binding Instance Identifier Argument
99 * Mutable instance of list, which is appended by YangInstanceIdentifiers
100 * as tree is walked. Use null if such side-product is not needed.
101 * @return Context of child
102 * @throws IllegalArgumentException
103 * If supplied argument does not represent valid child.
107 BindingCodecTreeNode<?> bindingPathArgumentChild(@Nonnull InstanceIdentifier.PathArgument arg,
108 @Nullable List<YangInstanceIdentifier.PathArgument> builder);
112 * Returns codec which uses caches serialization / deserialization results
114 * Caching may introduce performance penalty to serialization / deserialization
115 * but may decrease use of heap for repetitive objects.
118 * @param cacheSpecifier Set of objects, for which cache may be in place
119 * @return Codec whihc uses cache for serialization / deserialization.
123 BindingNormalizedNodeCachingCodec<T> createCachingCodec(@Nonnull
124 ImmutableCollection<Class<? extends DataObject>> cacheSpecifier);
128 void writeAsNormalizedNode(T data, NormalizedNodeStreamWriter writer);
131 * Serializes path argument for current node.
133 * @param arg Binding Path Argument, may be null if Binding Instance Identifier does not have
134 * representation for current node (e.g. choice or case).
135 * @return Yang Path Argument, may be null if Yang Instance Identifier does not have
136 * representation for current node (e.g. case).
137 * @throws IllegalArgumentException If supplied {@code arg} is not valid.
141 @Nullable YangInstanceIdentifier.PathArgument serializePathArgument(@Nullable InstanceIdentifier.PathArgument arg);
144 * Deserializes path argument for current node.
146 * @param arg Yang Path Argument, may be null if Yang Instance Identifier does not have
147 * representation for current node (e.g. case).
148 * @return Binding Path Argument, may be null if Binding Instance Identifier does not have
149 * representation for current node (e.g. choice or case).
150 * @throws IllegalArgumentException If supplied {@code arg} is not valid.
154 @Nullable InstanceIdentifier.PathArgument deserializePathArgument(@Nullable YangInstanceIdentifier.PathArgument arg);