Merge "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  * Modifications Copyright © 2018 IBM
8  * ================================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * ============LICENSE_END=========================================================
21  */
22
23 package org.onap.ccsdk.sli.plugins.yangserializers.pnserializer;
24
25 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
26
27 /**
28  * Representation of leaf node in properties data tree.
29  */
30 public class LeafNode extends PropertiesNode implements LeafListHolderChild, DataNodeChild {
31
32     private String value;
33     private Namespace valueNs;
34     private static final String svcLogicException = "Leaf cannot hold child nodes";
35
36     /**
37      * Creates an instance of leaf node.
38      *
39      * @param name name of the leaf node
40      * @param namespace namespace of the leaf node
41      * @param uri uri of the leaf node
42      * @param parent parent of the leaf node
43      * @param appInfo application info
44      * @param nodeType node type
45      * @param value value of the leaf
46      */
47     public LeafNode(String name, Namespace namespace,
48                     String uri, PropertiesNode parent,
49                     Object appInfo, NodeType nodeType,
50                     String value) {
51         super(name, namespace, uri, parent, appInfo, nodeType);
52         this.value = value;
53     }
54
55     /**
56      * Returns value of the leaf.
57      *
58      * @return value of the leaf
59      */
60     public String value() {
61         return value;
62     }
63
64     /**
65      * Sets value of the leaf.
66      *
67      * @param value value of the leaf
68      */
69     public void value(String value) {
70         this.value = value;
71     }
72
73     /**
74      * Returns value namespace.
75      *
76      * @return value namespace
77      */
78     public Namespace valueNs() {
79         return valueNs;
80     }
81
82     /**
83      * Sets value namespace.
84      *
85      * @param valueNs value namespace
86      */
87     public void valueNs(Namespace valueNs) {
88         this.valueNs = valueNs;
89     }
90
91     @Override
92     public PropertiesNode addChild(String name, Namespace namespace,
93                                    NodeType type,
94                                    Object appInfo) throws SvcLogicException {
95         throw new SvcLogicException(svcLogicException);
96     }
97
98     @Override
99     public PropertiesNode addChild(String name, Namespace namespace,
100                                    NodeType type, String value,
101                                    Namespace valueNs,
102                                    Object appInfo) throws SvcLogicException {
103         throw new SvcLogicException(svcLogicException);
104     }
105
106     @Override
107     public PropertiesNode addChild(String index, String name,
108                                    Namespace namespace,
109                                    NodeType type,
110                                    Object appInfo) throws SvcLogicException {
111         throw new SvcLogicException(svcLogicException);
112     }
113
114     @Override
115     public PropertiesNode addChild(String index, String name,
116                                    Namespace namespace,
117                                    NodeType type, String value,
118                                    Namespace valueNs,
119                                    Object appInfo) throws SvcLogicException {
120         throw new SvcLogicException("Leaf cannot hold child nodes");
121     }
122 }