/* * Copyright (c) 2018 AT&T and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.fd.honeycomb.transportpce.binding.converter.api; import java.io.InputStream; import java.io.Reader; import java.io.Writer; import java.util.Optional; import javax.annotation.Nonnull; import org.opendaylight.yangtools.yang.binding.DataContainer; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.Notification; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.model.api.SchemaNode; import org.opendaylight.yangtools.yang.model.api.SchemaPath; public interface DataObjectConverter { Optional getDataObject( @Nonnull NormalizedNode normalizedNode, @Nonnull QName rootNode); Optional getDataObjectFromRpc( @Nonnull NormalizedNode normalizedNode, @Nonnull SchemaPath rpcSchemaPath); Optional> transformIntoNormalizedNode( @Nonnull InputStream inputStream); Optional> transformIntoNormalizedNode( @Nonnull Reader inputReader, SchemaNode parentSchema); Optional> transformIntoNormalizedNode( @Nonnull Reader inputReader); Writer writerFromDataObject(@Nonnull DataObject object, Class dataObjectClass, ConvertType convertType); Writer writerFromRpcDataObject(@Nonnull DataObject object, Class dataObjectClass, ConvertType convertType, QName rpcOutputQName, String rpcName); Optional> toNormalizedNodes(@Nonnull T object, Class dataObjectClass); public interface ConvertType { Optional> toNormalizedNodes(T object, Class clazz); } /** * Returns a converter for {@link DataObject} container type. * @param T extends DataObject * * @return {@link ConvertType} converter for {@link DataContainer} */ ConvertType dataContainer(); /** * Returns converter for {@link DataContainer} rpc type. * @param T extends DataContainer * * @return {@link ConvertType} converter for {@link DataContainer} * representing rpc data */ ConvertType rpcData(); /** * Return converter for {@link Notification}. * @param T extends Notification * * @return {@link ConvertType} converter for {@link Notification} */ ConvertType notification(); }