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 NormalizedNode.
26 public interface BindingCodecTreeNode<T extends DataObject> extends BindingNormalizedNodeCodec<T> {
29 * Returns binding class of interface which represents API of current schema node. The result is same as invoking
30 * {@link DataObject#getImplementedInterface()} on instance of data.
32 * @return interface which defines API of binding representation of data.
35 Class<T> getBindingClass();
38 * Returns child context as if it was walked by {@link BindingStreamEventWriter}. This means that to enter case,
39 * one must issue getChild(ChoiceClass).getChild(CaseClass).
41 * @param childClass Child class by Biding Stream navigation
42 * @return Context of child
43 * @throws IllegalArgumentException
44 * If supplied child class is not valid in specified context.
47 <E extends DataObject> BindingCodecTreeNode<E> streamChild(@Nonnull Class<E> childClass);
50 * Returns child context as if it was walked by {@link BindingStreamEventWriter}. This means that to enter case,
51 * one must issue getChild(ChoiceClass).getChild(CaseClass).
54 * This method differs from {@link #streamChild(Class)}, that is less strict for interfaces representing
55 * augmentation and cases, that may return {@link BindingCodecTreeNode} even if augmentation interface containing
56 * same data was supplied and does not represent augmentation of this node.
59 * @return Context of child or Optional absent is supplied class is not
60 * applicable in context.
62 <E extends DataObject> Optional<? extends BindingCodecTreeNode<E>> possibleStreamChild(
63 @Nonnull Class<E> childClass);
66 * Returns nested node context using supplied YANG Instance Identifier.
69 * Yang Instance Identifier Argument
70 * @return Context of child
71 * @throws IllegalArgumentException
72 * If supplied argument does not represent valid child.
75 BindingCodecTreeNode<?> yangPathArgumentChild(@Nonnull YangInstanceIdentifier.PathArgument child);
78 * Returns nested node context using supplied Binding Instance Identifier and adds YANG instance identifiers to
82 * Binding Instance Identifier Argument
84 * Mutable instance of list, which is appended by YangInstanceIdentifiers
85 * as tree is walked. Use null if such side-product is not needed.
86 * @return Context of child
87 * @throws IllegalArgumentException
88 * If supplied argument does not represent valid child.
91 BindingCodecTreeNode<?> bindingPathArgumentChild(@Nonnull InstanceIdentifier.PathArgument arg,
92 @Nullable List<YangInstanceIdentifier.PathArgument> builder);
95 * Returns codec which uses caches serialization / deserialization results.
98 * Caching may introduce performance penalty to serialization / deserialization
99 * but may decrease use of heap for repetitive objects.
101 * @param cacheSpecifier Set of objects, for which cache may be in place
102 * @return Codec whihc uses cache for serialization / deserialization.
105 BindingNormalizedNodeCachingCodec<T> createCachingCodec(@Nonnull
106 ImmutableCollection<Class<? extends DataObject>> cacheSpecifier);
109 void writeAsNormalizedNode(T data, NormalizedNodeStreamWriter writer);
112 * Serializes path argument for current node.
114 * @param arg Binding Path Argument, may be null if Binding Instance Identifier does not have
115 * representation for current node (e.g. choice or case).
116 * @return Yang Path Argument, may be null if Yang Instance Identifier does not have
117 * representation for current node (e.g. case).
118 * @throws IllegalArgumentException If supplied {@code arg} is not valid.
121 @Nullable YangInstanceIdentifier.PathArgument serializePathArgument(@Nullable InstanceIdentifier.PathArgument arg);
124 * Deserializes path argument for current node.
126 * @param arg Yang Path Argument, may be null if Yang Instance Identifier does not have
127 * representation for current node (e.g. case).
128 * @return Binding Path Argument, may be null if Binding Instance Identifier does not have
129 * representation for current node (e.g. choice or case).
130 * @throws IllegalArgumentException If supplied {@code arg} is not valid.
133 @Nullable InstanceIdentifier.PathArgument deserializePathArgument(
134 @Nullable YangInstanceIdentifier.PathArgument arg);