blob: 073db3b8e39179a3256db102bf7b683fb7b5b36a [file] [log] [blame]
Vinod Kumar S2ff139c2016-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;
24
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 */
Bharat saraswal870c56f2016-02-20 21:57:16 +053079public class YangAugment extends YangNode implements YangLeavesHolder, YangCommonInfo, Parsable {
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053080
81 /**
82 * Augment target node.
83 */
84 private String targetNode;
85
86 /**
87 * description of augment.
88 */
89 private String description;
90
91 /**
92 * List of leaves.
93 */
Bharat saraswal870c56f2016-02-20 21:57:16 +053094 private List<YangLeaf<?>> listOfLeaf;
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053095
96 /**
97 * List of leaf-lists.
98 */
Bharat saraswal870c56f2016-02-20 21:57:16 +053099 private List<YangLeafList<?>> listOfLeafList;
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530100
101 /**
102 * reference.
103 */
104 private String reference;
105
106 /**
107 * Status of the node.
108 */
109 private YangStatusType status;
110
111 /**
112 * Create a YANG augment node.
113 */
114 public YangAugment() {
115 super(YangNodeType.AUGMENT_NODE);
116 }
117
118 /**
119 * Get the augmented node.
120 *
121 * @return the augmented node.
122 */
123 public String getTargetNode() {
124 return targetNode;
125 }
126
127 /**
128 * Set the augmented node.
129 *
130 * @param targetNode the augmented node.
131 */
132 public void setTargetNode(String targetNode) {
133 this.targetNode = targetNode;
134 }
135
136 /**
137 * Get the description.
138 *
139 * @return the description.
140 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530141 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530142 public String getDescription() {
143 return description;
144 }
145
146 /**
147 * Set the description.
148 *
149 * @param description set the description.
150 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530151 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530152 public void setDescription(String description) {
153 this.description = description;
154 }
155
156 /**
157 * Get the list of leaves.
158 *
159 * @return the list of leaves.
160 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530161 @Override
162 public List<YangLeaf<?>> getListOfLeaf() {
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530163 return listOfLeaf;
164 }
165
166 /**
167 * Set the list of leaves.
168 *
169 * @param leafsList the list of leaf to set.
170 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530171 private void setListOfLeaf(List<YangLeaf<?>> leafsList) {
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530172 listOfLeaf = leafsList;
173 }
174
175 /**
176 * Add a leaf.
177 *
178 * @param leaf the leaf to be added.
179 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530180 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530181 public void addLeaf(YangLeaf<?> leaf) {
182 if (getListOfLeaf() == null) {
Bharat saraswal870c56f2016-02-20 21:57:16 +0530183 setListOfLeaf(new LinkedList<YangLeaf<?>>());
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530184 }
185
186 getListOfLeaf().add(leaf);
187 }
188
189 /**
190 * Get the list of leaf-list.
191 *
192 * @return the list of leaf-list.
193 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530194 @Override
195 public List<YangLeafList<?>> getListOfLeafList() {
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530196 return listOfLeafList;
197 }
198
199 /**
200 * Set the list of leaf-list.
201 *
202 * @param listOfLeafList the list of leaf-list to set.
203 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530204 private void setListOfLeafList(List<YangLeafList<?>> listOfLeafList) {
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530205 this.listOfLeafList = listOfLeafList;
206 }
207
208 /**
209 * Add a leaf-list.
210 *
211 * @param leafList the leaf-list to be added.
212 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530213 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530214 public void addLeafList(YangLeafList<?> leafList) {
215 if (getListOfLeafList() == null) {
Bharat saraswal870c56f2016-02-20 21:57:16 +0530216 setListOfLeafList(new LinkedList<YangLeafList<?>>());
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530217 }
218
219 getListOfLeafList().add(leafList);
220 }
221
222 /**
223 * Get the textual reference.
224 *
225 * @return the reference.
226 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530227 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530228 public String getReference() {
229 return reference;
230 }
231
232 /**
233 * Set the textual reference.
234 *
235 * @param reference the reference to set.
236 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530237 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530238 public void setReference(String reference) {
239 this.reference = reference;
240 }
241
242 /**
243 * Get the status.
244 *
245 * @return the status.
246 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530247 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530248 public YangStatusType getStatus() {
249 return status;
250 }
251
252 /**
253 * Set the status.
254 *
255 * @param status the status to set.
256 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530257 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530258 public void setStatus(YangStatusType status) {
259 this.status = status;
260 }
261
262 /**
263 * Returns the type of the data as belongs-to.
264 *
265 * @return returns AUGMENT_DATA.
266 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530267 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530268 public ParsableDataType getParsableDataType() {
269 return ParsableDataType.AUGMENT_DATA;
270 }
271
272 /**
273 * Validate the data on entering the corresponding parse tree node.
274 *
275 * @throws DataModelException a violation of data model rules.
276 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530277 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530278 public void validateDataOnEntry() throws DataModelException {
279 // TODO auto-generated method stub, to be implemented by parser
280 }
281
282 /**
283 * Validate the data on exiting the corresponding parse tree node.
284 *
285 * @throws DataModelException a violation of data model rules.
286 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530287 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530288 public void validateDataOnExit() throws DataModelException {
289 // TODO auto-generated method stub, to be implemented by parser
290 }
291
292 /* (non-Javadoc)
293 * @see org.onosproject.yangutils.datamodel.YangNode#getName()
294 */
295 @Override
296 public String getName() {
297 // TODO Auto-generated method stub
298 return null;
299 }
300
301 /* (non-Javadoc)
302 * @see org.onosproject.yangutils.datamodel.YangNode#setName(java.lang.String)
303 */
304 @Override
305 public void setName(String name) {
306 // TODO Auto-generated method stub
307
308 }
309
310 /* (non-Javadoc)
311 * @see org.onosproject.yangutils.datamodel.YangNode#getPackage()
312 */
313 @Override
314 public String getPackage() {
315 // TODO Auto-generated method stub
316 return null;
317 }
318
319 /* (non-Javadoc)
320 * @see org.onosproject.yangutils.datamodel.YangNode#setPackage(java.lang.String)
321 */
322 @Override
323 public void setPackage(String pkg) {
324 // TODO Auto-generated method stub
325
326 }
327
328 /* (non-Javadoc)
329 * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry()
330 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530331 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530332 public void generateJavaCodeEntry() {
333 // TODO Auto-generated method stub
334
335 }
336
337 /* (non-Javadoc)
338 * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit()
339 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530340 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530341 public void generateJavaCodeExit() {
342 // TODO Auto-generated method stub
343
344 }
345}