Fix checkstyle in mdsal-binding-dom-codec
[mdsal.git] / binding / mdsal-binding-dom-codec / src / main / java / org / opendaylight / mdsal / binding / dom / codec / api / BindingCodecTreeNode.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.mdsal.binding.dom.codec.api;
9
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;
21
22 /**
23  * Subtree codec specific to model subtree between Java Binding and NormalizedNode.
24  */
25 @Beta
26 public interface BindingCodecTreeNode<T extends DataObject> extends BindingNormalizedNodeCodec<T> {
27
28     /**
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.
31      *
32      * @return interface which defines API of binding representation of data.
33      */
34     @Nonnull
35     Class<T> getBindingClass();
36
37     /**
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).
40      *
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.
45      */
46     @Nonnull
47     <E extends DataObject> BindingCodecTreeNode<E> streamChild(@Nonnull Class<E> childClass);
48
49     /**
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).
52      *
53      * <p>
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.
57      *
58      * @param childClass
59      * @return Context of child or Optional absent is supplied class is not
60      *         applicable in context.
61      */
62     <E extends DataObject> Optional<? extends BindingCodecTreeNode<E>> possibleStreamChild(
63             @Nonnull Class<E> childClass);
64
65     /**
66      * Returns nested node context using supplied YANG Instance Identifier.
67      *
68      * @param child
69      *            Yang Instance Identifier Argument
70      * @return Context of child
71      * @throws IllegalArgumentException
72      *             If supplied argument does not represent valid child.
73      */
74     @Nonnull
75     BindingCodecTreeNode<?> yangPathArgumentChild(@Nonnull YangInstanceIdentifier.PathArgument child);
76
77     /**
78      * Returns nested node context using supplied Binding Instance Identifier and adds YANG instance identifiers to
79      * the supplied list.
80      *
81      * @param arg
82      *            Binding Instance Identifier Argument
83      * @param builder
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.
89      */
90     @Nonnull
91     BindingCodecTreeNode<?> bindingPathArgumentChild(@Nonnull InstanceIdentifier.PathArgument arg,
92             @Nullable List<YangInstanceIdentifier.PathArgument> builder);
93
94     /**
95      * Returns codec which uses caches serialization / deserialization results.
96      *
97      * <p>
98      * Caching may introduce performance penalty to serialization / deserialization
99      * but may decrease use of heap for repetitive objects.
100      *
101      * @param cacheSpecifier Set of objects, for which cache may be in place
102      * @return Codec whihc uses cache for serialization / deserialization.
103      */
104     @Nonnull
105     BindingNormalizedNodeCachingCodec<T> createCachingCodec(@Nonnull
106             ImmutableCollection<Class<? extends DataObject>> cacheSpecifier);
107
108     @Beta
109     void writeAsNormalizedNode(T data, NormalizedNodeStreamWriter writer);
110
111     /**
112      * Serializes path argument for current node.
113      *
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.
119      */
120     @Beta
121     @Nullable YangInstanceIdentifier.PathArgument serializePathArgument(@Nullable InstanceIdentifier.PathArgument arg);
122
123     /**
124      * Deserializes path argument for current node.
125      *
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.
131      */
132     @Beta
133     @Nullable InstanceIdentifier.PathArgument deserializePathArgument(
134             @Nullable YangInstanceIdentifier.PathArgument arg);
135
136     Object getSchema();
137 }