Add Honeynode emulator for device221
[transportpce.git] / tests / honeynode / 2.2.1 / honeynode-common / src / main / java / io / fd / honeycomb / transportpce / binding / converter / api / DataObjectConverter.java
1 /*
2  * Copyright (c) 2018 AT&T and/or its affiliates.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package io.fd.honeycomb.transportpce.binding.converter.api;
17
18 import java.io.InputStream;
19 import java.io.Reader;
20 import java.io.Writer;
21 import java.util.Optional;
22
23 import javax.annotation.Nonnull;
24
25 import org.opendaylight.yangtools.yang.binding.DataContainer;
26 import org.opendaylight.yangtools.yang.binding.DataObject;
27 import org.opendaylight.yangtools.yang.binding.Notification;
28 import org.opendaylight.yangtools.yang.common.QName;
29 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
30 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
31 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
32 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
33
34 public interface DataObjectConverter {
35
36     <T extends DataObject> Optional<T> getDataObject(
37             @Nonnull NormalizedNode<? extends YangInstanceIdentifier.PathArgument, ?> normalizedNode,
38             @Nonnull QName rootNode);
39
40     <T extends DataObject> Optional<T> getDataObjectFromRpc(
41             @Nonnull NormalizedNode<? extends YangInstanceIdentifier.PathArgument, ?> normalizedNode,
42             @Nonnull SchemaPath rpcSchemaPath);
43
44     Optional<NormalizedNode<? extends YangInstanceIdentifier.PathArgument, ?>> transformIntoNormalizedNode(
45             @Nonnull InputStream inputStream);
46
47     Optional<NormalizedNode<? extends YangInstanceIdentifier.PathArgument, ?>> transformIntoNormalizedNode(
48             @Nonnull Reader inputReader, SchemaNode parentSchema);
49
50     Optional<NormalizedNode<? extends YangInstanceIdentifier.PathArgument, ?>> transformIntoNormalizedNode(
51             @Nonnull Reader inputReader);
52
53     <T extends DataObject> Writer writerFromDataObject(@Nonnull DataObject object, Class<T> dataObjectClass,
54             ConvertType<T> convertType);
55
56     <T extends DataObject> Writer writerFromRpcDataObject(@Nonnull DataObject object, Class<T> dataObjectClass,
57             ConvertType<T> convertType, QName rpcOutputQName, String rpcName);
58
59     <T extends DataObject> Optional<NormalizedNode<?, ?>> toNormalizedNodes(@Nonnull T object,
60             Class<T> dataObjectClass);
61
62     public interface ConvertType<T> {
63         Optional<NormalizedNode<?, ?>> toNormalizedNodes(T object, Class<T> clazz);
64     }
65
66     /**
67      * Returns a converter for {@link DataObject} container type.
68      *
69      * @return {@link ConvertType} converter for {@link DataContainer}
70      */
71     <T extends DataObject> ConvertType<T> dataContainer();
72
73     /**
74      * Returns converter for {@link DataContainer} rpc type.
75      *
76      * @return {@link ConvertType} converter for {@link DataContainer}
77      * representing rpc data
78      */
79     <T extends DataContainer> ConvertType<T> rpcData();
80
81     /**
82      * Return converter for {@link Notification}.
83      *
84      * @return {@link ConvertType} converter for {@link Notification}
85      */
86     <T extends Notification> ConvertType<T> notification();
87
88 }