Binding v2 DOM Codec - generator - SPI - part 1
[mdsal.git] / binding2 / mdsal-binding2-dom-codec / src / main / java / org / opendaylight / mdsal / binding / javav2 / dom / codec / api / serializer / BindingNormalizedNodeSerializer.java
1 /*
2  * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.mdsal.binding.javav2.dom.codec.api.serializer;
9
10 import java.util.Map.Entry;
11 import javax.annotation.Nonnull;
12 import javax.annotation.Nullable;
13 import org.opendaylight.mdsal.binding.javav2.spec.base.InstanceIdentifier;
14 import org.opendaylight.mdsal.binding.javav2.spec.base.Instantiable;
15 import org.opendaylight.mdsal.binding.javav2.spec.base.Notification;
16 import org.opendaylight.mdsal.binding.javav2.spec.base.TreeNode;
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 YANG Instance Identifier into Binding instance
30      * identifier.
31      *
32      * @param dom
33      *            - YANG Instance Identifier
34      * @return Binding Instance Identifier, or null if the instance identifier
35      *         is not representable
36      */
37     @Nullable
38     InstanceIdentifier<? extends TreeNode> fromYangInstanceIdentifier(@Nonnull YangInstanceIdentifier dom);
39
40     /**
41      * Translates supplied YANG Instance Identifier and NormalizedNode into
42      * Binding data.
43      *
44      * @param path
45      *            - Binding Instance Identifier
46      * @param data
47      *            - NormalizedNode representing data
48      * @return DOM Instance Identifier
49      */
50     @Nullable
51     Entry<InstanceIdentifier<? extends TreeNode>, TreeNode> fromNormalizedNode(@Nonnull YangInstanceIdentifier path,
52             NormalizedNode<?, ?> data);
53
54     /**
55      * Translates supplied Binding Instance Identifier into NormalizedNode
56      * instance identifier.
57      *
58      * @param binding
59      *            - Binding Instance Identifier
60      * @return DOM Instance Identifier
61      * @throws IllegalArgumentException
62      *             - if supplied Instance Identifier is not valid
63      */
64     @Nullable
65     YangInstanceIdentifier toYangInstanceIdentifier(@Nonnull InstanceIdentifier<? extends TreeNode> binding);
66
67     /**
68      * Translates supplied Binding Instance Identifier and data into
69      * NormalizedNode representation.
70      *
71      * @param path
72      *            - Binding Instance Identifier pointing to data
73      * @param data
74      *            - representing Data Tree
75      * @param <T> data type
76      * @return NormalizedNode representation
77      * @throws IllegalArgumentException
78      *             - if supplied Instance Identifier is not valid.
79      */
80     @Nullable
81     <T extends TreeNode> Entry<YangInstanceIdentifier, NormalizedNode<?, ?>>
82             toNormalizedNode(InstanceIdentifier<T> path, T data);
83
84     /**
85      * Translates supplied NormalizedNode Notification into Binding data.
86      *
87      * @param path
88      *            - Schema Path of Notification, schema path is absolute, and
89      *            consists of Notification QName
90      * @param data
91      *            - NormalizedNode representing data
92      * @return Binding representation of Notification
93      */
94     @Nullable
95     Notification<?> fromNormalizedNodeNotification(@Nonnull SchemaPath path, @Nonnull ContainerNode data);
96
97     /**
98      * Translates supplied Binding Notification or output into NormalizedNode
99      * notification.
100      *
101      * @param data
102      *            NormalizedNode representing notification data
103      * @return NormalizedNode representation of notification
104      */
105     @Nonnull
106     ContainerNode toNormalizedNodeNotification(@Nonnull Notification<?> data);
107
108     /**
109      * Translates supplied NormalizedNode operation (RPC, Action) input or
110      * output into Binding data.
111      *
112      * @param path
113      *            - schema path of operation data, schema path consists of
114      *            rpc/action QName and input/output QName.
115      * @param data
116      *            - NormalizedNode representing data
117      * @return Binding representation of operation data
118      */
119     @Nullable
120     TreeNode fromNormalizedNodeOperationData(@Nonnull SchemaPath path, @Nonnull ContainerNode data);
121
122     /**
123      * Translates supplied Binding operation (RPC, Action) input or output into
124      * NormalizedNode data.
125      *
126      * @param data
127      *            - NormalizedNode representing rpc/action data
128      * @return NormalizedNode representation of operation data
129      */
130     @Nonnull
131     ContainerNode toNormalizedNodeRpcData(@Nonnull Instantiable<?> data);
132 }