Merge "Added tests for yang.model.util"
[yangtools.git] / code-generator / binding-data-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;
11 import java.util.Map.Entry;
12
13 import javax.annotation.Nonnull;
14 import javax.annotation.Nullable;
15
16 import org.opendaylight.yangtools.yang.binding.DataObject;
17 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
18 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
19 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
20
21 /**
22  * Serialization service, which provides two-way serialization between
23  * Java Binding Data representation and NormalizedNode representation.
24  */
25 public interface BindingNormalizedNodeSerializer {
26
27      /**
28       * Translates supplied Binding Instance Identifier into NormalizedNode instance identifier.
29       *
30       * @param binding Binding Instance Identifier
31       * @return DOM Instance Identifier
32       */
33      YangInstanceIdentifier toYangInstanceIdentifier(@Nonnull InstanceIdentifier<?> binding);
34
35      /**
36       * Translates supplied YANG Instance Identifier into Binding instance identifier.
37       *
38       * @param dom YANG Instance Identifier
39       * @return Binding Instance Identifier, or null if the instance identifier is not
40       *         representable.
41       */
42      @Nullable InstanceIdentifier<?> fromYangInstanceIdentifier(@Nonnull YangInstanceIdentifier dom);
43
44      /**
45       * Translates supplied Binding Instance Identifier and data into NormalizedNode representation.
46       *
47       * @param path Binding Instance Identifier pointing to data
48       * @param data Data object representing data
49       * @return NormalizedNode representation
50       */
51      <T extends DataObject> Entry<YangInstanceIdentifier, NormalizedNode<?,?>> toNormalizedNode(InstanceIdentifier<T> path, T data);
52
53      /**
54       * Translates supplied YANG Instance Identifier and NormalizedNode into Binding data.
55       *
56       * @param path Binding Instance Identifier
57       * @param data NormalizedNode representing data
58       * @return DOM Instance Identifier
59       */
60      @Nullable Entry<InstanceIdentifier<?>,DataObject> fromNormalizedNode(@Nonnull YangInstanceIdentifier path, NormalizedNode<?, ?> data);
61
62      /**
63       * Returns map view which contains translated set of entries to normalized nodes.
64       * Returned set will not contain representation of leaf nodes.
65       *
66       * @param dom Map of YANG Instance Identifier to Data
67       * @return Map of Binding Instance Identifier to data.
68       */
69      Map<InstanceIdentifier<?>,DataObject> fromNormalizedNodes(Map<YangInstanceIdentifier,NormalizedNode<?,?>> dom);
70
71 }