blob: b2bd1efb109f8647803b23bfa818a688fad57345 [file] [log] [blame]
Vinod Kumar S5a39e012016-02-16 01:37:16 +05301/*
2 * Copyright 2016 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.yangutils.datamodel;
17
18import java.util.LinkedList;
19import java.util.List;
20
21import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
22import org.onosproject.yangutils.parser.Parsable;
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +053023import org.onosproject.yangutils.utils.YangConstructType;
Vinod Kumar S5a39e012016-02-16 01:37:16 +053024
25/*-
26 * Reference RFC 6020.
27 *
28 * The "augment" statement allows a module or submodule to add to the
29 * schema tree defined in an external module, or the current module and
30 * its submodules, and to add to the nodes from a grouping in a "uses"
31 * statement. The argument is a string that identifies a node in the
32 * schema tree. This node is called the augment's target node. The
33 * target node MUST be either a container, list, choice, case, input,
34 * output, or notification node. It is augmented with the nodes defined
35 * in the sub-statements that follow the "augment" statement.
36 *
37 * The argument string is a schema node identifier.
38 * If the "augment" statement is on the top level in a module or
39 * submodule, the absolute form of a schema node identifier
40 * MUST be used. If the "augment" statement is a sub-statement to the
41 * "uses" statement, the descendant form MUST be used.
42 *
43 * If the target node is a container, list, case, input, output, or
44 * notification node, the "container", "leaf", "list", "leaf-list",
45 * "uses", and "choice" statements can be used within the "augment"
46 * statement.
47 *
48 * If the target node is a choice node, the "case" statement, or a case
49 * shorthand statement can be used within the "augment" statement.
50 *
51 * If the target node is in another module, then nodes added by the
52 * augmentation MUST NOT be mandatory nodes.
53 *
54 * The "augment" statement MUST NOT add multiple nodes with the same
55 * name from the same module to the target node.
56 * The augment's sub-statements
57 *
58 * +--------------+---------+-------------+------------------+
59 * | substatement | section | cardinality |data model mapping|
60 * +--------------+---------+-------------+------------------+
61 * | anyxml | 7.10 | 0..n |-not supported |
62 * | case | 7.9.2 | 0..n |-child nodes |
63 * | choice | 7.9 | 0..n |-child nodes |
64 * | container | 7.5 | 0..n |-child nodes |
65 * | description | 7.19.3 | 0..1 |-string |
66 * | if-feature | 7.18.2 | 0..n |-TODO |
67 * | leaf | 7.6 | 0..n |-YangLeaf |
68 * | leaf-list | 7.7 | 0..n |-YangLeafList |
69 * | list | 7.8 | 0..n |-child nodes |
70 * | reference | 7.19.4 | 0..1 |-String |
71 * | status | 7.19.2 | 0..1 |-YangStatus |
72 * | uses | 7.12 | 0..n |-child nodes |
73 * | when | 7.19.5 | 0..1 |-TODO |
74 * +--------------+---------+-------------+------------------+
75 */
76/**
77 * Data model node to maintain information defined in YANG augment.
78 */
Vinod Kumar S9f26ae52016-03-23 15:30:27 +053079public class YangAugment extends YangNode
80 implements YangLeavesHolder, YangCommonInfo, Parsable {
Vinod Kumar S5a39e012016-02-16 01:37:16 +053081
82 /**
83 * Augment target node.
84 */
85 private String targetNode;
86
87 /**
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +053088 * Description of augment.
Vinod Kumar S5a39e012016-02-16 01:37:16 +053089 */
90 private String description;
91
92 /**
93 * List of leaves.
94 */
Vinod Kumar Sc26bf192016-02-23 22:36:57 +053095 private List<YangLeaf> listOfLeaf;
Vinod Kumar S5a39e012016-02-16 01:37:16 +053096
97 /**
98 * List of leaf-lists.
99 */
Vinod Kumar Sc26bf192016-02-23 22:36:57 +0530100 private List<YangLeafList> listOfLeafList;
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530101
102 /**
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530103 * Reference of the YANG augment.
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530104 */
105 private String reference;
106
107 /**
108 * Status of the node.
109 */
110 private YangStatusType status;
111
112 /**
113 * Create a YANG augment node.
114 */
115 public YangAugment() {
116 super(YangNodeType.AUGMENT_NODE);
117 }
118
119 /**
120 * Get the augmented node.
121 *
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530122 * @return the augmented node
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530123 */
124 public String getTargetNode() {
125 return targetNode;
126 }
127
128 /**
129 * Set the augmented node.
130 *
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530131 * @param targetNode the augmented node
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530132 */
133 public void setTargetNode(String targetNode) {
134 this.targetNode = targetNode;
135 }
136
137 /**
138 * Get the description.
139 *
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530140 * @return the description
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530141 */
Bharat saraswal97459962016-02-20 21:57:16 +0530142 @Override
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530143 public String getDescription() {
144 return description;
145 }
146
147 /**
148 * Set the description.
149 *
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530150 * @param description set the description
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530151 */
Bharat saraswal97459962016-02-20 21:57:16 +0530152 @Override
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530153 public void setDescription(String description) {
154 this.description = description;
155 }
156
157 /**
158 * Get the list of leaves.
159 *
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530160 * @return the list of leaves
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530161 */
Bharat saraswal97459962016-02-20 21:57:16 +0530162 @Override
Vinod Kumar Sc26bf192016-02-23 22:36:57 +0530163 public List<YangLeaf> getListOfLeaf() {
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530164 return listOfLeaf;
165 }
166
167 /**
168 * Set the list of leaves.
169 *
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530170 * @param leafsList the list of leaf to set
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530171 */
Vinod Kumar Sc26bf192016-02-23 22:36:57 +0530172 private void setListOfLeaf(List<YangLeaf> leafsList) {
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530173 listOfLeaf = leafsList;
174 }
175
176 /**
177 * Add a leaf.
178 *
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530179 * @param leaf the leaf to be added
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530180 */
Bharat saraswal97459962016-02-20 21:57:16 +0530181 @Override
Vinod Kumar Sc26bf192016-02-23 22:36:57 +0530182 public void addLeaf(YangLeaf leaf) {
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530183 if (getListOfLeaf() == null) {
Vinod Kumar Sc26bf192016-02-23 22:36:57 +0530184 setListOfLeaf(new LinkedList<YangLeaf>());
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530185 }
186
187 getListOfLeaf().add(leaf);
188 }
189
190 /**
191 * Get the list of leaf-list.
192 *
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530193 * @return the list of leaf-list
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530194 */
Bharat saraswal97459962016-02-20 21:57:16 +0530195 @Override
Vinod Kumar Sc26bf192016-02-23 22:36:57 +0530196 public List<YangLeafList> getListOfLeafList() {
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530197 return listOfLeafList;
198 }
199
200 /**
201 * Set the list of leaf-list.
202 *
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530203 * @param listOfLeafList the list of leaf-list to set
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530204 */
Vinod Kumar Sc26bf192016-02-23 22:36:57 +0530205 private void setListOfLeafList(List<YangLeafList> listOfLeafList) {
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530206 this.listOfLeafList = listOfLeafList;
207 }
208
209 /**
210 * Add a leaf-list.
211 *
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530212 * @param leafList the leaf-list to be added
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530213 */
Bharat saraswal97459962016-02-20 21:57:16 +0530214 @Override
Vinod Kumar Sc26bf192016-02-23 22:36:57 +0530215 public void addLeafList(YangLeafList leafList) {
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530216 if (getListOfLeafList() == null) {
Vinod Kumar Sc26bf192016-02-23 22:36:57 +0530217 setListOfLeafList(new LinkedList<YangLeafList>());
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530218 }
219
220 getListOfLeafList().add(leafList);
221 }
222
223 /**
224 * Get the textual reference.
225 *
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530226 * @return the reference
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530227 */
Bharat saraswal97459962016-02-20 21:57:16 +0530228 @Override
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530229 public String getReference() {
230 return reference;
231 }
232
233 /**
234 * Set the textual reference.
235 *
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530236 * @param reference the reference to set
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530237 */
Bharat saraswal97459962016-02-20 21:57:16 +0530238 @Override
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530239 public void setReference(String reference) {
240 this.reference = reference;
241 }
242
243 /**
244 * Get the status.
245 *
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530246 * @return the status
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530247 */
Bharat saraswal97459962016-02-20 21:57:16 +0530248 @Override
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530249 public YangStatusType getStatus() {
250 return status;
251 }
252
253 /**
254 * Set the status.
255 *
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530256 * @param status the status to set
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530257 */
Bharat saraswal97459962016-02-20 21:57:16 +0530258 @Override
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530259 public void setStatus(YangStatusType status) {
260 this.status = status;
261 }
262
263 /**
264 * Returns the type of the data as belongs-to.
265 *
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530266 * @return returns AUGMENT_DATA
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530267 */
Bharat saraswal97459962016-02-20 21:57:16 +0530268 @Override
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530269 public YangConstructType getYangConstructType() {
270 return YangConstructType.AUGMENT_DATA;
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530271 }
272
273 /**
274 * Validate the data on entering the corresponding parse tree node.
275 *
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530276 * @throws DataModelException a violation of data model rules
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530277 */
Bharat saraswal97459962016-02-20 21:57:16 +0530278 @Override
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530279 public void validateDataOnEntry() throws DataModelException {
280 // TODO auto-generated method stub, to be implemented by parser
281 }
282
283 /**
284 * Validate the data on exiting the corresponding parse tree node.
285 *
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530286 * @throws DataModelException a violation of data model rules
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530287 */
Bharat saraswal97459962016-02-20 21:57:16 +0530288 @Override
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530289 public void validateDataOnExit() throws DataModelException {
290 // TODO auto-generated method stub, to be implemented by parser
291 }
292
Vinod Kumar Sc26bf192016-02-23 22:36:57 +0530293 /**
294 * Get the target nodes name where the augmentation is being done.
295 *
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530296 * @return target nodes name where the augmentation is being done
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530297 */
298 @Override
299 public String getName() {
Vinod Kumar Sc26bf192016-02-23 22:36:57 +0530300 return targetNode;
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530301 }
302
Vinod Kumar Sc26bf192016-02-23 22:36:57 +0530303 /**
304 * Set the target nodes name where the augmentation is being done.
305 *
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530306 * @param name target nodes name where the augmentation is being done
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530307 */
308 @Override
309 public void setName(String name) {
Vinod Kumar Sc26bf192016-02-23 22:36:57 +0530310 targetNode = name;
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530311
312 }
313
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530314}