2 * Copyright (c) 2018 AT&T and/or its affiliates.
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:
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package io.fd.honeycomb.transportpce.binding.converter.api;
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;
32 public interface DataObjectConverter {
34 <T extends DataObject> Optional<T> getDataObject(
35 @Nonnull NormalizedNode<? extends YangInstanceIdentifier.PathArgument, ?> normalizedNode,
36 @Nonnull QName rootNode);
38 <T extends DataObject> Optional<T> getDataObjectFromRpc(
39 @Nonnull NormalizedNode<? extends YangInstanceIdentifier.PathArgument, ?> normalizedNode,
40 @Nonnull SchemaPath rpcSchemaPath);
42 Optional<NormalizedNode<? extends YangInstanceIdentifier.PathArgument, ?>> transformIntoNormalizedNode(
43 @Nonnull InputStream inputStream);
45 Optional<NormalizedNode<? extends YangInstanceIdentifier.PathArgument, ?>> transformIntoNormalizedNode(
46 @Nonnull Reader inputReader, SchemaNode parentSchema);
48 Optional<NormalizedNode<? extends YangInstanceIdentifier.PathArgument, ?>> transformIntoNormalizedNode(
49 @Nonnull Reader inputReader);
51 <T extends DataObject> Writer writerFromDataObject(@Nonnull DataObject object, Class<T> dataObjectClass,
52 ConvertType<T> convertType);
54 <T extends DataObject> Writer writerFromRpcDataObject(@Nonnull DataObject object, Class<T> dataObjectClass,
55 ConvertType<T> convertType, QName rpcOutputQName, String rpcName);
57 <T extends DataObject> Optional<NormalizedNode<?, ?>> toNormalizedNodes(@Nonnull T object,
58 Class<T> dataObjectClass);
60 public interface ConvertType<T> {
61 Optional<NormalizedNode<?, ?>> toNormalizedNodes(T object, Class<T> clazz);
65 * Returns a converter for {@link DataObject} container type.
67 * @return {@link ConvertType} converter for {@link DataContainer}
69 <T extends DataObject> ConvertType<T> dataContainer();
72 * Returns converter for {@link DataContainer} rpc type.
74 * @return {@link ConvertType} converter for {@link DataContainer}
75 * representing rpc data
77 <T extends DataContainer> ConvertType<T> rpcData();
80 * Return converter for {@link Notification}.
82 * @return {@link ConvertType} converter for {@link Notification}
84 <T extends Notification> ConvertType<T> notification();