Cleaned up Java Binding code from YANG Tools
[mdsal.git] / binding / mdsal-binding-dom-codec / src / main / java / org / opendaylight / yangtools / binding / data / codec / api / BindingNormalizedNodeSerializer.java
1 /*
2  * Copyright (c) 2014 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.yangtools.binding.data.codec.api;
9
10 import java.util.Map.Entry;
11 import javax.annotation.Nonnull;
12 import javax.annotation.Nullable;
13 import org.opendaylight.yangtools.yang.binding.DataContainer;
14 import org.opendaylight.yangtools.yang.binding.DataObject;
15 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
16 import org.opendaylight.yangtools.yang.binding.Notification;
17 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
18 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
19 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
20 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
21
22 /**
23  * Serialization service, which provides two-way serialization between Java
24  * Binding Data representation and NormalizedNode representation.
25  */
26 public interface BindingNormalizedNodeSerializer {
27
28     /**
29      * Translates supplied Binding Instance Identifier into NormalizedNode
30      * instance identifier.
31      *
32      * @param binding
33      *            Binding Instance Identifier
34      * @return DOM Instance Identifier
35      * @throws IllegalArgumentException
36      *             If supplied Instance Identifier is not valid.
37      */
38     YangInstanceIdentifier toYangInstanceIdentifier(@Nonnull InstanceIdentifier<?> binding);
39
40     /**
41      * Translates supplied YANG Instance Identifier into Binding instance
42      * identifier.
43      *
44      * @param dom
45      *            YANG Instance Identifier
46      * @return Binding Instance Identifier, or null if the instance identifier
47      *         is not representable.
48      */
49     @Nullable
50     InstanceIdentifier<?> fromYangInstanceIdentifier(@Nonnull YangInstanceIdentifier dom);
51
52     /**
53      * Translates supplied Binding Instance Identifier and data into
54      * NormalizedNode representation.
55      *
56      * @param path
57      *            Binding Instance Identifier pointing to data
58      * @param data
59      *            Data object representing data
60      * @return NormalizedNode representation
61      * @throws IllegalArgumentException
62      *             If supplied Instance Identifier is not valid.
63      */
64     <T extends DataObject> Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> toNormalizedNode(
65             InstanceIdentifier<T> path, T data);
66
67     /**
68      * Translates supplied YANG Instance Identifier and NormalizedNode into
69      * Binding data.
70      *
71      * @param path Binding Instance Identifier
72      * @param data NormalizedNode representing data
73      * @return DOM Instance Identifier
74      */
75     @Nullable
76     Entry<InstanceIdentifier<?>, DataObject> fromNormalizedNode(@Nonnull YangInstanceIdentifier path,
77             NormalizedNode<?, ?> data);
78
79     /**
80      * Translates supplied NormalizedNode Notification into Binding data.
81      *
82      * @param path Schema Path of Notification, schema path is absolute, and consists of Notification QName.
83      * @param data NormalizedNode representing data
84      * @return Binding representation of Notification
85      */
86     @Nullable Notification fromNormalizedNodeNotification(@Nonnull SchemaPath path,@Nonnull ContainerNode data);
87
88     /**
89      * Translates supplied NormalizedNode RPC input or output into Binding data.
90      *
91      * @param path Schema path of RPC data, Schema path consists of rpc QName and input / output QName.
92      * @param data NormalizedNode representing data
93      * @return Binding representation of RPC data
94      */
95     @Nullable DataObject fromNormalizedNodeRpcData(@Nonnull SchemaPath path,@Nonnull ContainerNode data);
96
97     /**
98      * Translates supplied Binding Notification or output into NormalizedNode notification.
99      *
100      * @param data NormalizedNode representing notification data
101      * @return NormalizedNode representation of notification
102      */
103     @Nonnull ContainerNode toNormalizedNodeNotification(@Nonnull Notification data);
104
105     /**
106      * Translates supplied Binding RPC input or output into NormalizedNode data.
107      *
108      * @param data NormalizedNode representing rpc data
109      * @return NormalizedNode representation of rpc data
110      */
111     @Nonnull ContainerNode toNormalizedNodeRpcData(@Nonnull DataContainer data);
112 }