Merge "Added safe copy of array."
[yangtools.git] / yang / yang-data-impl / src / main / java / org / opendaylight / yangtools / yang / data / impl / codec / BindingIndependentMappingService.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.yang.data.impl.codec;
9
10 import java.util.Map.Entry;
11 import java.util.Set;
12
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.RpcService;
17 import org.opendaylight.yangtools.yang.common.QName;
18 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
19
20 import com.google.common.base.Optional;
21
22 public interface BindingIndependentMappingService {
23
24     /**
25      * Get codec registry.
26      *
27      * @return codec registry
28      */
29     CodecRegistry getCodecRegistry();
30
31     /**
32      * Convert given DataObject data to DOM-like node.
33      *
34      * @param data
35      *            DataObject instance
36      * @return CompositeNode created from DataObject instance
37      */
38     CompositeNode toDataDom(DataObject data);
39
40     /**
41      * Create map entry representing node data (key = data schema node
42      * identifier, value = value is node data representation as Composite node)
43      * from entry representing node class (key = class object identifier, value
44      * = class object).
45      *
46      * @param entry
47      *            map entry, where key is class object identifier and value
48      *            class object
49      * @return data schema node identifier
50      */
51     Entry<org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier, CompositeNode> toDataDom(
52             Entry<InstanceIdentifier<? extends DataObject>, DataObject> entry);
53
54     /**
55      * Create data schema node identifier from class object identifier.
56      *
57      * @param path
58      *            class object identifier
59      * @return data schema node identifier
60      */
61     org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier toDataDom(InstanceIdentifier<? extends DataObject> path);
62
63     /**
64      * Create DataObject instance from CompositeNode data based on given path.
65      *
66      * @param path
67      *            node identifier
68      * @param result
69      *            node data
70      * @return inputClass instance created from composite node input
71      */
72     DataObject dataObjectFromDataDom(InstanceIdentifier<? extends DataObject> path, CompositeNode result)
73             throws DeserializationException;
74
75     /**
76      * Create class object identifier from data schema node identifier.
77      *
78      * @param entry
79      *            data schema node identifier
80      * @return class object identifier
81      */
82     InstanceIdentifier<?> fromDataDom(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier entry)
83             throws DeserializationException;
84
85     /**
86      * Returns the list of currently-known QNames for instances of a service.
87      *
88      * @param service
89      *            RPC service
90      * @return List of QNames. The user may not modify this list.
91      */
92     Set<QName> getRpcQNamesFor(Class<? extends RpcService> service);
93
94     /**
95      * Get RpcService by namespace and revision.
96      *
97      * @param namespace
98      *            rpc service namespace
99      * @param revision
100      *            rpc service revision
101      * @return Optional reference on RpcServices based on given namespace and
102      *         revision
103      */
104     Optional<Class<? extends RpcService>> getRpcServiceClassFor(String namespace, String revision);
105
106     /**
107      * Create inputClass instance from CompositeNode data.
108      *
109      * @param inputClass
110      *            expected type of resulting object
111      * @param domInput
112      *            node data
113      * @return inputClass instance created from composite node input
114      */
115     DataContainer dataObjectFromDataDom(Class<? extends DataContainer> inputClass, CompositeNode domInput);
116
117 }