blob: 16735c27385fb97b8558d0f2fce9cd653eb9b829 [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 */
79public class YangAugment extends YangNode
80 implements YangLeavesHolder, YangCommonInfo, Parsable {
81
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 */
95 @SuppressWarnings("rawtypes")
96 private List<YangLeaf> listOfLeaf;
97
98 /**
99 * List of leaf-lists.
100 */
101 @SuppressWarnings("rawtypes")
102 private List<YangLeafList> listOfLeafList;
103
104 /**
105 * reference.
106 */
107 private String reference;
108
109 /**
110 * Status of the node.
111 */
112 private YangStatusType status;
113
114 /**
115 * Create a YANG augment node.
116 */
117 public YangAugment() {
118 super(YangNodeType.AUGMENT_NODE);
119 }
120
121 /**
122 * Get the augmented node.
123 *
124 * @return the augmented node.
125 */
126 public String getTargetNode() {
127 return targetNode;
128 }
129
130 /**
131 * Set the augmented node.
132 *
133 * @param targetNode the augmented node.
134 */
135 public void setTargetNode(String targetNode) {
136 this.targetNode = targetNode;
137 }
138
139 /**
140 * Get the description.
141 *
142 * @return the description.
143 */
144 public String getDescription() {
145 return description;
146 }
147
148 /**
149 * Set the description.
150 *
151 * @param description set the description.
152 */
153 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 */
162 @SuppressWarnings("rawtypes")
163 public List<YangLeaf> getListOfLeaf() {
164 return listOfLeaf;
165 }
166
167 /**
168 * Set the list of leaves.
169 *
170 * @param leafsList the list of leaf to set.
171 */
172 @SuppressWarnings("rawtypes")
173 private void setListOfLeaf(List<YangLeaf> leafsList) {
174 listOfLeaf = leafsList;
175 }
176
177 /**
178 * Add a leaf.
179 *
180 * @param leaf the leaf to be added.
181 */
182 @SuppressWarnings("rawtypes")
183 public void addLeaf(YangLeaf<?> leaf) {
184 if (getListOfLeaf() == null) {
185 setListOfLeaf(new LinkedList<YangLeaf>());
186 }
187
188 getListOfLeaf().add(leaf);
189 }
190
191 /**
192 * Get the list of leaf-list.
193 *
194 * @return the list of leaf-list.
195 */
196 @SuppressWarnings("rawtypes")
197 public List<YangLeafList> getListOfLeafList() {
198 return listOfLeafList;
199 }
200
201 /**
202 * Set the list of leaf-list.
203 *
204 * @param listOfLeafList the list of leaf-list to set.
205 */
206 @SuppressWarnings("rawtypes")
207 private void setListOfLeafList(List<YangLeafList> listOfLeafList) {
208 this.listOfLeafList = listOfLeafList;
209 }
210
211 /**
212 * Add a leaf-list.
213 *
214 * @param leafList the leaf-list to be added.
215 */
216 @SuppressWarnings("rawtypes")
217 public void addLeafList(YangLeafList<?> leafList) {
218 if (getListOfLeafList() == null) {
219 setListOfLeafList(new LinkedList<YangLeafList>());
220 }
221
222 getListOfLeafList().add(leafList);
223 }
224
225 /**
226 * Get the textual reference.
227 *
228 * @return the reference.
229 */
230 public String getReference() {
231 return reference;
232 }
233
234 /**
235 * Set the textual reference.
236 *
237 * @param reference the reference to set.
238 */
239 public void setReference(String reference) {
240 this.reference = reference;
241 }
242
243 /**
244 * Get the status.
245 *
246 * @return the status.
247 */
248 public YangStatusType getStatus() {
249 return status;
250 }
251
252 /**
253 * Set the status.
254 *
255 * @param status the status to set.
256 */
257 public void setStatus(YangStatusType status) {
258 this.status = status;
259 }
260
261 /**
262 * Returns the type of the data as belongs-to.
263 *
264 * @return returns AUGMENT_DATA.
265 */
266 public ParsableDataType getParsableDataType() {
267 return ParsableDataType.AUGMENT_DATA;
268 }
269
270 /**
271 * Validate the data on entering the corresponding parse tree node.
272 *
273 * @throws DataModelException a violation of data model rules.
274 */
275 public void validateDataOnEntry() throws DataModelException {
276 // TODO auto-generated method stub, to be implemented by parser
277 }
278
279 /**
280 * Validate the data on exiting the corresponding parse tree node.
281 *
282 * @throws DataModelException a violation of data model rules.
283 */
284 public void validateDataOnExit() throws DataModelException {
285 // TODO auto-generated method stub, to be implemented by parser
286 }
287
288 /* (non-Javadoc)
289 * @see org.onosproject.yangutils.datamodel.YangNode#getName()
290 */
291 @Override
292 public String getName() {
293 // TODO Auto-generated method stub
294 return null;
295 }
296
297 /* (non-Javadoc)
298 * @see org.onosproject.yangutils.datamodel.YangNode#setName(java.lang.String)
299 */
300 @Override
301 public void setName(String name) {
302 // TODO Auto-generated method stub
303
304 }
305
306 /* (non-Javadoc)
307 * @see org.onosproject.yangutils.datamodel.YangNode#getPackage()
308 */
309 @Override
310 public String getPackage() {
311 // TODO Auto-generated method stub
312 return null;
313 }
314
315 /* (non-Javadoc)
316 * @see org.onosproject.yangutils.datamodel.YangNode#setPackage(java.lang.String)
317 */
318 @Override
319 public void setPackage(String pkg) {
320 // TODO Auto-generated method stub
321
322 }
323
324 /* (non-Javadoc)
325 * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry()
326 */
327 public void generateJavaCodeEntry() {
328 // TODO Auto-generated method stub
329
330 }
331
332 /* (non-Javadoc)
333 * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit()
334 */
335 public void generateJavaCodeExit() {
336 // TODO Auto-generated method stub
337
338 }
339}