Sonar fix: TemplateNode.java
[ccsdk/sli/plugins.git] / restconf-client / provider / src / main / java / org / onap / ccsdk / sli / plugins / yangserializers / pnserializer / LeafNode.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 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
24
25 /**
26  * Representation of leaf node in properties data tree.
27  */
28 public class LeafNode extends PropertiesNode implements LeafListHolderChild, DataNodeChild {
29
30     private String value;
31     private Namespace valueNs;
32
33     /**
34      * Creates an instance of leaf node.
35      *
36      * @param name name of the leaf node
37      * @param namespace namespace of the leaf node
38      * @param uri uri of the leaf node
39      * @param parent parent of the leaf node
40      * @param appInfo application info
41      * @param nodeType node type
42      * @param value value of the leaf
43      */
44     public LeafNode(String name, Namespace namespace,
45                     String uri, PropertiesNode parent,
46                     Object appInfo, NodeType nodeType,
47                     String value) {
48         super(name, namespace, uri, parent, appInfo, nodeType);
49         this.value = value;
50     }
51
52     /**
53      * Returns value of the leaf.
54      *
55      * @return value of the leaf
56      */
57     public String value() {
58         return value;
59     }
60
61     /**
62      * Sets value of the leaf.
63      *
64      * @param value value of the leaf
65      */
66     public void value(String value) {
67         this.value = value;
68     }
69
70     /**
71      * Returns value namespace.
72      *
73      * @return value namespace
74      */
75     public Namespace valueNs() {
76         return valueNs;
77     }
78
79     /**
80      * Sets value namespace.
81      *
82      * @param valueNs value namespace
83      */
84     public void valueNs(Namespace valueNs) {
85         this.valueNs = valueNs;
86     }
87
88     @Override
89     public PropertiesNode addChild(String name, Namespace namespace,
90                                    NodeType type,
91                                    Object appInfo) throws SvcLogicException {
92         throw new SvcLogicException("Leaf cannot hold child nodes");
93     }
94
95     @Override
96     public PropertiesNode addChild(String name, Namespace namespace,
97                                    NodeType type, String value,
98                                    Namespace valueNs,
99                                    Object appInfo) throws SvcLogicException {
100         throw new SvcLogicException("Leaf cannot hold child nodes");
101     }
102
103     @Override
104     public PropertiesNode addChild(String index, String name,
105                                    Namespace namespace,
106                                    NodeType type,
107                                    Object appInfo) throws SvcLogicException {
108         throw new SvcLogicException("Leaf cannot hold child nodes");
109     }
110
111     @Override
112     public PropertiesNode addChild(String index, String name,
113                                    Namespace namespace,
114                                    NodeType type, String value,
115                                    Namespace valueNs,
116                                    Object appInfo) throws SvcLogicException {
117         throw new SvcLogicException("Leaf cannot hold child nodes");
118     }
119 }