blob: 36dbb236fa27d7a813b1d99fee244f641295b1e3 [file] [log] [blame]
Vinod Kumar S67e7be62016-02-11 20:13:28 +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 * While the primary unit in YANG is a module, a YANG module can itself
29 * be constructed out of several submodules. Submodules allow a module
30 * designer to split a complex model into several pieces where all the
31 * submodules contribute to a single namespace, which is defined by the
32 * module that includes the submodules.
33 *
34 * The "submodule" statement defines the submodule's name, and groups
35 * all statements that belong to the submodule together. The
36 * "submodule" statement's argument is the name of the submodule,
37 * followed by a block of sub-statements that hold detailed submodule
38 * information.
39 *
40 * The submodule's sub-statements
41 *
42 * +--------------+---------+-------------+------------------+
43 * | substatement | section | cardinality |data model mapping|
44 * +--------------+---------+-------------+------------------+
45 * | anyxml | 7.10 | 0..n | - not supported |
46 * | augment | 7.15 | 0..n | - child nodes |
47 * | belongs-to | 7.2.2 | 1 | - YangBelongsTo |
48 * | choice | 7.9 | 0..n | - child nodes |
49 * | contact | 7.1.8 | 0..1 | - string |
50 * | container | 7.5 | 0..n | - child nodes |
51 * | description | 7.19.3 | 0..1 | - string |
52 * | deviation | 7.18.3 | 0..n | - TODO |
53 * | extension | 7.17 | 0..n | - TODO |
54 * | feature | 7.18.1 | 0..n | - TODO |
55 * | grouping | 7.11 | 0..n | - child nodes |
56 * | identity | 7.16 | 0..n | - TODO |
57 * | import | 7.1.5 | 0..n | - YangImport |
58 * | include | 7.1.6 | 0..n | - YangInclude |
59 * | leaf | 7.6 | 0..n | - YangLeaf |
60 * | leaf-list | 7.7 | 0..n | - YangLeafList |
61 * | list | 7.8 | 0..n | - child nodes |
62 * | notification | 7.14 | 0..n | - TODO |
63 * | organization | 7.1.7 | 0..1 | - string |
64 * | reference | 7.19.4 | 0..1 | - string |
65 * | revision | 7.1.9 | 0..n | - string |
66 * | rpc | 7.13 | 0..n | - TODO |
67 * | typedef | 7.3 | 0..n | - child nodes |
68 * | uses | 7.12 | 0..n | - child nodes |
69 * | YANG-version | 7.1.2 | 0..1 | - int |
70 * +--------------+---------+-------------+------------------+
71 */
72/**
73 * Data model node to maintain information defined in YANG sub-module.
74 */
Bharat saraswal870c56f2016-02-20 21:57:16 +053075public class YangSubModule extends YangNode implements YangLeavesHolder, YangDesc, YangReference, Parsable {
Vinod Kumar S67e7be62016-02-11 20:13:28 +053076
77 /**
78 * Name of sub module.
79 */
80 private String name;
81
82 /**
83 * Module to which it belongs to.
84 */
85 private YangBelongsTo belongsTo;
86
87 /**
88 * Reference RFC 6020.
89 *
90 * The "contact" statement provides contact information for the module. The
91 * argument is a string that is used to specify contact information for the
92 * person or persons to whom technical queries concerning this module should
93 * be sent, such as their name, postal address, telephone number, and
94 * electronic mail address.
95 */
96 private String contact;
97
98 /**
99 * Description.
100 */
101 private String description;
102
103 /**
104 * List of YANG modules imported.
105 */
106 private List<YangImport> importList;
107
108 /**
109 * List of YANG sub-modules included.
110 */
111 private List<YangInclude> includeList;
112
113 /**
114 * List of leaves at root level in the sub-module.
115 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530116 private List<YangLeaf<?>> listOfLeaf;
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530117
118 /**
119 * List of leaf-lists at root level in the sub-module.
120 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530121 private List<YangLeafList<?>> listOfLeafList;
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530122
123 /**
124 * organization owner of the sub-module.
125 */
126 private String organization;
127
128 /**
129 * reference of the sub-module.
130 */
131 private String reference;
132
133 /**
134 * revision info of the sub-module.
135 */
136 private YangRevision revision;
137
138 /**
139 * YANG version.
140 */
141 private byte version;
142
143 /**
144 * Create a sub module node.
145 */
146 public YangSubModule() {
147 super(YangNodeType.SUB_MODULE_NODE);
148 }
149
150 /* (non-Javadoc)
151 * @see org.onosproject.yangutils.datamodel.YangNode#getName()
152 */
153 @Override
154 public String getName() {
155 return name;
156 }
157
158 /* (non-Javadoc)
159 * @see org.onosproject.yangutils.datamodel.YangNode#setName(java.lang.String)
160 */
161 @Override
162 public void setName(String subModuleName) {
163 name = subModuleName;
164 }
165
166 /**
167 * Get the module info.
168 *
169 * @return the belongs to info
170 */
171 public YangBelongsTo getBelongsTo() {
172 return belongsTo;
173 }
174
175 /**
176 * Set the module info.
177 *
178 * @param belongsTo module info to set.
179 */
180 public void setBelongsTo(YangBelongsTo belongsTo) {
181 this.belongsTo = belongsTo;
182 }
183
184 /**
185 * Get the contact.
186 *
187 * @return the contact.
188 */
189 public String getContact() {
190 return contact;
191 }
192
193 /**
194 * Set the contact.
195 *
196 * @param contact the contact to set
197 */
198 public void setContact(String contact) {
199 this.contact = contact;
200 }
201
202 /**
203 * Get the description.
204 *
205 * @return the description.
206 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530207 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530208 public String getDescription() {
209 return description;
210 }
211
212 /**
213 * Set the description.
214 *
215 * @param description set the description.
216 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530217 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530218 public void setDescription(String description) {
219 this.description = description;
220 }
221
222 /**
223 * Get the list of imported modules.
224 *
225 * @return the list of imported modules.
226 */
227 public List<YangImport> getImportList() {
228 return importList;
229 }
230
231 /**
232 * prevent setting the import list from outside.
233 *
234 * @param importList the import list to set.
235 */
236 private void setImportList(List<YangImport> importList) {
237 this.importList = importList;
238 }
239
240 /**
241 * Add the imported module information to the import list.
242 *
243 * @param importedModule module being imported.
244 */
245 public void addImportedInfo(YangImport importedModule) {
246
247 if (getImportList() == null) {
248 setImportList(new LinkedList<YangImport>());
249 }
250
251 getImportList().add(importedModule);
252
253 return;
254 }
255
256 /**
257 * Get the list of included sub modules.
258 *
259 * @return the included list of sub modules.
260 */
261 public List<YangInclude> getIncludeList() {
262 return includeList;
263 }
264
265 /**
266 * Set the list of included sub modules.
267 *
268 * @param includeList the included list to set.
269 */
270 private void setIncludeList(List<YangInclude> includeList) {
271 this.includeList = includeList;
272 }
273
274 /**
275 * Add the included sub module information to the include list.
276 *
277 * @param includeModule submodule being included.
278 */
279 public void addIncludedInfo(YangInclude includeModule) {
280
281 if (getIncludeList() == null) {
282 setIncludeList(new LinkedList<YangInclude>());
283 }
284
285 getIncludeList().add(includeModule);
286 return;
287 }
288
289 /**
290 * Get the list of leaves.
291 *
292 * @return the list of leaves.
293 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530294 @Override
295 public List<YangLeaf<?>> getListOfLeaf() {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530296 return listOfLeaf;
297 }
298
299 /**
300 * Set the list of leaves.
301 *
302 * @param leafsList the list of leaf to set.
303 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530304 private void setListOfLeaf(List<YangLeaf<?>> leafsList) {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530305 listOfLeaf = leafsList;
306 }
307
308 /**
309 * Add a leaf.
310 *
311 * @param leaf the leaf to be added.
312 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530313 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530314 public void addLeaf(YangLeaf<?> leaf) {
315 if (getListOfLeaf() == null) {
Bharat saraswal870c56f2016-02-20 21:57:16 +0530316 setListOfLeaf(new LinkedList<YangLeaf<?>>());
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530317 }
318
319 getListOfLeaf().add(leaf);
320 }
321
322 /**
323 * Get the list of leaf-list.
324 *
325 * @return the list of leaf-list.
326 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530327 @Override
328 public List<YangLeafList<?>> getListOfLeafList() {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530329 return listOfLeafList;
330 }
331
332 /**
333 * Set the list of leaf-list.
334 *
335 * @param listOfLeafList the list of leaf-list to set.
336 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530337 private void setListOfLeafList(List<YangLeafList<?>> listOfLeafList) {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530338 this.listOfLeafList = listOfLeafList;
339 }
340
341 /**
342 * Add a leaf-list.
343 *
344 * @param leafList the leaf-list to be added.
345 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530346 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530347 public void addLeafList(YangLeafList<?> leafList) {
348 if (getListOfLeafList() == null) {
Bharat saraswal870c56f2016-02-20 21:57:16 +0530349 setListOfLeafList(new LinkedList<YangLeafList<?>>());
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530350 }
351
352 getListOfLeafList().add(leafList);
353 }
354
355 /**
356 * Get the sub-modules organization.
357 *
358 * @return the organization.
359 */
360 public String getOrganization() {
361 return organization;
362 }
363
364 /**
365 * Set the sub-modules organization.
366 *
367 * @param org the organization to set.
368 */
369 public void setOrganization(String org) {
370 organization = org;
371 }
372
373 /**
374 * Get the textual reference.
375 *
376 * @return the reference.
377 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530378 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530379 public String getReference() {
380 return reference;
381 }
382
383 /**
384 * Set the textual reference.
385 *
386 * @param reference the reference to set.
387 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530388 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530389 public void setReference(String reference) {
390 this.reference = reference;
391 }
392
393 /**
394 * Get the revision.
395 *
396 * @return the revision.
397 */
398 public YangRevision getRevision() {
399 return revision;
400 }
401
402 /**
403 * Set the revision.
404 *
405 * @param revision the revision to set.
406 */
407 public void setRevision(YangRevision revision) {
408 this.revision = revision;
409 }
410
411 /**
412 * Get the version.
413 *
414 * @return the version.
415 */
416 public byte getVersion() {
417 return version;
418 }
419
420 /**
421 * Set the version.
422 *
423 * @param version the version to set.
424 */
425 public void setVersion(byte version) {
426 this.version = version;
427 }
428
429 /**
430 * Returns the type of the parsed data.
431 *
432 * @return returns SUB_MODULE_DATA.
433 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530434 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530435 public ParsableDataType getParsableDataType() {
436 return ParsableDataType.SUB_MODULE_DATA;
437 }
438
439 /**
440 * Validate the data on entering the corresponding parse tree node.
441 *
442 * @throws DataModelException a violation of data model rules.
443 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530444 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530445 public void validateDataOnEntry() throws DataModelException {
446 // TODO auto-generated method stub, to be implemented by parser
447 }
448
449 /**
450 * Validate the data on exiting the corresponding parse tree node.
451 *
452 * @throws DataModelException a violation of data model rules.
453 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530454 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530455 public void validateDataOnExit() throws DataModelException {
456 // TODO auto-generated method stub, to be implemented by parser
457 }
458
459 /* (non-Javadoc)
460 * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry()
461 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530462 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530463 public void generateJavaCodeEntry() {
464 // TODO Auto-generated method stub
465
466 }
467
468 /* (non-Javadoc)
469 * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit()
470 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530471 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530472 public void generateJavaCodeExit() {
473 // TODO Auto-generated method stub
474
475 }
476
477 /* (non-Javadoc)
478 * @see org.onosproject.yangutils.datamodel.YangNode#getPackage()
479 */
480 @Override
481 public String getPackage() {
482 // TODO Auto-generated method stub
483 return null;
484 }
485
486 /* (non-Javadoc)
487 * @see org.onosproject.yangutils.datamodel.YangNode#setPackage(java.lang.String)
488 */
489 @Override
490 public void setPackage(String pkg) {
491 // TODO Auto-generated method stub
492
493 }
494}