fccfa6a9d20339d86fe4d3035e6c568de69abcb2
[ccsdk/sli/plugins.git] / restconf-client / provider / src / main / java / org / onap / ccsdk / sli / plugins / yangserializers / pnserializer / PropertiesNode.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - CCSDK
4  * ================================================================================
5  * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.ccsdk.sli.plugins.yangserializers.pnserializer;
22
23 /**
24  * Abstraction of properties node data tree. This intermediate representation
25  * will enable data format serializers to be agnostic of DG context memory
26  * nuances and thereby will enable faster development of new data faormat
27  * serializers.
28  */
29 public abstract class PropertiesNode {
30
31     private String name;
32     private String namespace;
33     private String uri;
34     private PropertiesNode parent;
35
36     /**
37      * Creates an instance of properties node.
38      */
39     protected PropertiesNode() {
40     }
41
42     /**
43      * Creates an instance of properties node.
44      *
45      * @param name name of node
46      * @param namespace namespace of node, null indicates parent namespace
47      * @param uri URI of this node, if null its calculated based on parent and
48      * current value of name and namespace
49      * @param parent parent's node
50      */
51     protected PropertiesNode(String name, String namespace, String uri, PropertiesNode parent) {
52         this.name = name;
53         this.namespace = namespace;
54         this.uri = uri;
55         this.parent = parent;
56     }
57
58     /**
59      * Adds a child to a current node.
60      *
61      * @param name name of child
62      * @param namespace namespace of child, null represents parent namespace
63      * @param type type of node
64      * @return added properties node
65      */
66     public abstract PropertiesNode addChild(String name, String namespace, NodeType type);
67
68     /**
69      * Adds a child with value to a current node.
70      *
71      * @param name name of child
72      * @param namespace namespace of child, null represents parent namespace
73      * @param type type of node
74      * @param value value of node
75      * @return added properties node
76      */
77     public abstract PropertiesNode addChild(String name, String namespace, NodeType type, String value);
78
79     /**
80      * Adds a child at a given index to a current node. To be used in case of
81      * leaf holder child's which is multi instance node.
82      *
83      * @param index index at which node is to be added
84      * @param name name of child
85      * @param namespace namespace of child, null represents parent namespace
86      * @param type type of node
87      * @return added properties node
88      */
89     public abstract PropertiesNode addChild(String index, String name, String namespace, NodeType type);
90
91     public void name(String name) {
92         this.name = name;
93     }
94
95     public void namespace(String namespace) {
96         this.namespace = namespace;
97     }
98
99     public void uri(String uri) {
100         this.uri = uri;
101     }
102
103     public void parent(PropertiesNode parent) {
104         this.parent = parent;
105     }
106
107     public PropertiesNode parent() {
108         return parent;
109     }
110
111     public String name() {
112         return name;
113     }
114
115     public String namespace() {
116         return namespace;
117     }
118
119     public String uri() {
120         return uri;
121     }
122
123 }
124