blob: 3f349226b53b5f601b4b3434de191a0d18856ea7 [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;
23import org.onosproject.yangutils.parser.ParsableDataType;
Bharat saraswal5e3c45c2016-02-22 22:15:21 +053024import org.onosproject.yangutils.translator.CachedFileHandle;
Vinod Kumar S5a39e012016-02-16 01:37:16 +053025
26/*-
27 * Reference RFC 6020.
28 *
29 * The "augment" statement allows a module or submodule to add to the
30 * schema tree defined in an external module, or the current module and
31 * its submodules, and to add to the nodes from a grouping in a "uses"
32 * statement. The argument is a string that identifies a node in the
33 * schema tree. This node is called the augment's target node. The
34 * target node MUST be either a container, list, choice, case, input,
35 * output, or notification node. It is augmented with the nodes defined
36 * in the sub-statements that follow the "augment" statement.
37 *
38 * The argument string is a schema node identifier.
39 * If the "augment" statement is on the top level in a module or
40 * submodule, the absolute form of a schema node identifier
41 * MUST be used. If the "augment" statement is a sub-statement to the
42 * "uses" statement, the descendant form MUST be used.
43 *
44 * If the target node is a container, list, case, input, output, or
45 * notification node, the "container", "leaf", "list", "leaf-list",
46 * "uses", and "choice" statements can be used within the "augment"
47 * statement.
48 *
49 * If the target node is a choice node, the "case" statement, or a case
50 * shorthand statement can be used within the "augment" statement.
51 *
52 * If the target node is in another module, then nodes added by the
53 * augmentation MUST NOT be mandatory nodes.
54 *
55 * The "augment" statement MUST NOT add multiple nodes with the same
56 * name from the same module to the target node.
57 * The augment's sub-statements
58 *
59 * +--------------+---------+-------------+------------------+
60 * | substatement | section | cardinality |data model mapping|
61 * +--------------+---------+-------------+------------------+
62 * | anyxml | 7.10 | 0..n |-not supported |
63 * | case | 7.9.2 | 0..n |-child nodes |
64 * | choice | 7.9 | 0..n |-child nodes |
65 * | container | 7.5 | 0..n |-child nodes |
66 * | description | 7.19.3 | 0..1 |-string |
67 * | if-feature | 7.18.2 | 0..n |-TODO |
68 * | leaf | 7.6 | 0..n |-YangLeaf |
69 * | leaf-list | 7.7 | 0..n |-YangLeafList |
70 * | list | 7.8 | 0..n |-child nodes |
71 * | reference | 7.19.4 | 0..1 |-String |
72 * | status | 7.19.2 | 0..1 |-YangStatus |
73 * | uses | 7.12 | 0..n |-child nodes |
74 * | when | 7.19.5 | 0..1 |-TODO |
75 * +--------------+---------+-------------+------------------+
76 */
77/**
78 * Data model node to maintain information defined in YANG augment.
79 */
Bharat saraswal97459962016-02-20 21:57:16 +053080public class YangAugment extends YangNode 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 /**
88 * description of augment.
89 */
90 private String description;
91
92 /**
93 * List of leaves.
94 */
Bharat saraswal97459962016-02-20 21:57:16 +053095 private List<YangLeaf<?>> listOfLeaf;
Vinod Kumar S5a39e012016-02-16 01:37:16 +053096
97 /**
98 * List of leaf-lists.
99 */
Bharat saraswal97459962016-02-20 21:57:16 +0530100 private List<YangLeafList<?>> listOfLeafList;
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530101
102 /**
103 * reference.
104 */
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 *
122 * @return the augmented node.
123 */
124 public String getTargetNode() {
125 return targetNode;
126 }
127
128 /**
129 * Set the augmented node.
130 *
131 * @param targetNode the augmented node.
132 */
133 public void setTargetNode(String targetNode) {
134 this.targetNode = targetNode;
135 }
136
137 /**
138 * Get the description.
139 *
140 * @return the description.
141 */
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 *
150 * @param description set the description.
151 */
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 *
160 * @return the list of leaves.
161 */
Bharat saraswal97459962016-02-20 21:57:16 +0530162 @Override
163 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 *
170 * @param leafsList the list of leaf to set.
171 */
Bharat saraswal97459962016-02-20 21:57:16 +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 *
179 * @param leaf the leaf to be added.
180 */
Bharat saraswal97459962016-02-20 21:57:16 +0530181 @Override
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530182 public void addLeaf(YangLeaf<?> leaf) {
183 if (getListOfLeaf() == null) {
Bharat saraswal97459962016-02-20 21:57:16 +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 *
193 * @return the list of leaf-list.
194 */
Bharat saraswal97459962016-02-20 21:57:16 +0530195 @Override
196 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 *
203 * @param listOfLeafList the list of leaf-list to set.
204 */
Bharat saraswal97459962016-02-20 21:57:16 +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 *
212 * @param leafList the leaf-list to be added.
213 */
Bharat saraswal97459962016-02-20 21:57:16 +0530214 @Override
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530215 public void addLeafList(YangLeafList<?> leafList) {
216 if (getListOfLeafList() == null) {
Bharat saraswal97459962016-02-20 21:57:16 +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 *
226 * @return the reference.
227 */
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 *
236 * @param reference the reference to set.
237 */
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 *
246 * @return the status.
247 */
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 *
256 * @param status the status to set.
257 */
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 *
266 * @return returns AUGMENT_DATA.
267 */
Bharat saraswal97459962016-02-20 21:57:16 +0530268 @Override
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530269 public ParsableDataType getParsableDataType() {
270 return ParsableDataType.AUGMENT_DATA;
271 }
272
273 /**
274 * Validate the data on entering the corresponding parse tree node.
275 *
276 * @throws DataModelException a violation of data model rules.
277 */
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 *
286 * @throws DataModelException a violation of data model rules.
287 */
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
293 /* (non-Javadoc)
294 * @see org.onosproject.yangutils.datamodel.YangNode#getName()
295 */
296 @Override
297 public String getName() {
298 // TODO Auto-generated method stub
299 return null;
300 }
301
302 /* (non-Javadoc)
303 * @see org.onosproject.yangutils.datamodel.YangNode#setName(java.lang.String)
304 */
305 @Override
306 public void setName(String name) {
307 // TODO Auto-generated method stub
308
309 }
310
311 /* (non-Javadoc)
312 * @see org.onosproject.yangutils.datamodel.YangNode#getPackage()
313 */
314 @Override
315 public String getPackage() {
316 // TODO Auto-generated method stub
317 return null;
318 }
319
320 /* (non-Javadoc)
321 * @see org.onosproject.yangutils.datamodel.YangNode#setPackage(java.lang.String)
322 */
323 @Override
324 public void setPackage(String pkg) {
325 // TODO Auto-generated method stub
326
327 }
328
329 /* (non-Javadoc)
330 * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry()
331 */
Bharat saraswal97459962016-02-20 21:57:16 +0530332 @Override
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530333 public void generateJavaCodeEntry() {
334 // TODO Auto-generated method stub
335
336 }
337
338 /* (non-Javadoc)
339 * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit()
340 */
Bharat saraswal97459962016-02-20 21:57:16 +0530341 @Override
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530342 public void generateJavaCodeExit() {
343 // TODO Auto-generated method stub
344
345 }
Bharat saraswal5e3c45c2016-02-22 22:15:21 +0530346
347 @Override
348 public CachedFileHandle getFileHandle() {
349 // TODO Auto-generated method stub
350 return null;
351 }
352
353 @Override
354 public void setFileHandle(CachedFileHandle fileHandle) {
355 // TODO Auto-generated method stub
356
357 }
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530358}