2 * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.javav2.dom.codec.api.codecs;
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.mdsal.binding.javav2.spec.base.TreeArgument;
17 import org.opendaylight.mdsal.binding.javav2.spec.base.TreeNode;
18 import org.opendaylight.mdsal.binding.javav2.spec.runtime.BindingStreamEventWriter;
19 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
20 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
23 * Specific subtree codec to model subtree between Java Binding and DOM.
26 * - Binding representation of data
29 public interface BindingTreeNodeCodec<T extends TreeNode> extends BindingNormalizedNodeCodec<T> {
32 * Returns binding class of interface which represents API of current schema
35 * @return interface which defines API of binding representation of data.
38 Class<T> getBindingClass();
41 * Returns child context as if it was walked by
42 * {@link BindingStreamEventWriter}. This means that to enter case, one must
43 * issue getChild(ChoiceClass).getChild(CaseClass).
46 * - 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 TreeNode> BindingTreeNodeCodec<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 may
61 * return {@link BindingTreeNodeCodec} even if augmentation interface
62 * containing same data was supplied and does not represent augmentation of
66 * - child class by Binding Stream navigation
67 * @return context of child or Optional absent if supplied is not applicable
70 <E extends TreeNode> Optional<? extends BindingTreeNodeCodec<E>> possibleStreamChild(@Nonnull Class<E> childClass);
73 * Returns nested node context using supplied YANG Instance Identifier.
76 * - Yang Instance Identifier Argument
77 * @return context of child
78 * @throws IllegalArgumentException
79 * - if supplied argument does not represent valid child
82 BindingTreeNodeCodec<?> yangPathArgumentChild(@Nonnull YangInstanceIdentifier.PathArgument child);
85 * Returns nested node context using supplied Binding Instance Identifier
86 * and adds YANG instance identifiers to supplied list.
89 * - Binding Instance Identifier Argument
91 * - mutable instance of list, which is appended by
92 * YangInstanceIdentifiers as tree is walked, use null if such
93 * side-product is not needed
94 * @return context of child
95 * @throws IllegalArgumentException
96 * - if supplied argument does not represent valid child.
99 BindingTreeNodeCodec<?> bindingPathArgumentChild(@Nonnull TreeArgument<?> arg,
100 @Nullable List<YangInstanceIdentifier.PathArgument> builder);
103 * Returns codec which uses caches serialization / deserialization results.
105 * Caching may introduce performance penalty to serialization /
106 * deserialization but may decrease use of heap for repetitive objects.
108 * @param cacheSpecifier
109 * - set of objects, for which cache may be in place
110 * @return codec which uses cache for serialization / deserialization
113 BindingNormalizedNodeCachingCodec<T>
114 createCachingCodec(@Nonnull ImmutableCollection<Class<? extends TreeNode>> cacheSpecifier);
117 * Writes data representing object to supplied stream.
120 * - representing object
124 void writeAsNormalizedNode(T data, NormalizedNodeStreamWriter writer);
127 * Serializes path argument for current node.
130 * - Binding Path Argument, may be null if Binding Instance
131 * Identifier does not have representation for current node (e.g.
133 * @return Yang Path Argument, may be null if Yang Instance Identifier does
134 * not have representation for current node (e.g. case).
135 * @throws IllegalArgumentException
136 * - if supplied {@code arg} is not valid.
139 YangInstanceIdentifier.PathArgument serializePathArgument(@Nullable TreeArgument<?> arg);
142 * Deserializes path argument for current node.
145 * - Yang Path Argument, may be null if Yang Instance Identifier
146 * does not have representation for current node (e.g. case)
147 * @return Binding Path Argument, may be null if Binding Instance Identifier
148 * does not have representation for current node (e.g. choice or
150 * @throws IllegalArgumentException
151 * - if supplied {@code arg} is not valid.
154 TreeArgument<?> deserializePathArgument(@Nullable YangInstanceIdentifier.PathArgument arg);
157 * Return schema of node codec context.
159 * @return {@link Object} as schema of specific node context