Relicensing a few files from EPL to Apache License
[transportpce.git] / tests / honeynode / 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 import javax.annotation.Nonnull;
23 import org.opendaylight.yangtools.yang.binding.DataContainer;
24 import org.opendaylight.yangtools.yang.binding.DataObject;
25 import org.opendaylight.yangtools.yang.binding.Notification;
26 import org.opendaylight.yangtools.yang.common.QName;
27 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
28 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
29 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
30 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
31
32 public interface DataObjectConverter {
33
34     <T extends DataObject> Optional<T> getDataObject(
35             @Nonnull NormalizedNode<? extends YangInstanceIdentifier.PathArgument, ?> normalizedNode,
36             @Nonnull QName rootNode);
37
38     <T extends DataObject> Optional<T> getDataObjectFromRpc(
39             @Nonnull NormalizedNode<? extends YangInstanceIdentifier.PathArgument, ?> normalizedNode,
40             @Nonnull SchemaPath rpcSchemaPath);
41
42     Optional<NormalizedNode<? extends YangInstanceIdentifier.PathArgument, ?>> transformIntoNormalizedNode(
43             @Nonnull InputStream inputStream);
44
45     Optional<NormalizedNode<? extends YangInstanceIdentifier.PathArgument, ?>> transformIntoNormalizedNode(
46             @Nonnull Reader inputReader, SchemaNode parentSchema);
47
48     Optional<NormalizedNode<? extends YangInstanceIdentifier.PathArgument, ?>> transformIntoNormalizedNode(
49             @Nonnull Reader inputReader);
50
51     <T extends DataObject> Writer writerFromDataObject(@Nonnull DataObject object, Class<T> dataObjectClass,
52             ConvertType<T> convertType);
53
54     <T extends DataObject> Writer writerFromRpcDataObject(@Nonnull DataObject object, Class<T> dataObjectClass,
55             ConvertType<T> convertType, QName rpcOutputQName, String rpcName);
56
57     <T extends DataObject> Optional<NormalizedNode<?, ?>> toNormalizedNodes(@Nonnull T object,
58             Class<T> dataObjectClass);
59
60     public interface ConvertType<T> {
61         Optional<NormalizedNode<?, ?>> toNormalizedNodes(T object, Class<T> clazz);
62     }
63
64     /**
65      * Returns a converter for {@link DataObject} container type.
66      *
67      * @return {@link ConvertType} converter for {@link DataContainer}
68      */
69     <T extends DataObject> ConvertType<T> dataContainer();
70
71     /**
72      * Returns converter for {@link DataContainer} rpc type.
73      *
74      * @return {@link ConvertType} converter for {@link DataContainer}
75      * representing rpc data
76      */
77     <T extends DataContainer> ConvertType<T> rpcData();
78
79     /**
80      * Return converter for {@link Notification}.
81      *
82      * @return {@link ConvertType} converter for {@link Notification}
83      */
84     <T extends Notification> ConvertType<T> notification();
85
86 }