blob: 8e1ba9d7a7323ac599fbcd7b4ff3eb3298e792d5 [file] [log] [blame]
Vinod Kumar S67e7be62016-02-11 20:13:28 +05301/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Vinod Kumar S67e7be62016-02-11 20:13:28 +05303 *
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
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +053018import java.util.Iterator;
Vinod Kumar S67e7be62016-02-11 20:13:28 +053019import java.util.LinkedList;
20import java.util.List;
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +053021import java.util.Set;
Bharat saraswal96dfef02016-06-16 00:29:12 +053022
Vinod Kumar S38046502016-03-23 15:30:27 +053023import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
Bharat saraswal96dfef02016-06-16 00:29:12 +053024import org.onosproject.yangutils.datamodel.utils.Parsable;
25import org.onosproject.yangutils.datamodel.utils.YangConstructType;
Vinod Kumar S38046502016-03-23 15:30:27 +053026
27import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil;
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +053028import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.linkInterFileReferences;
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +053029import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.resolveLinkingForResolutionList;
Vinod Kumar S38046502016-03-23 15:30:27 +053030
Vinod Kumar S67e7be62016-02-11 20:13:28 +053031/*
32 * Reference RFC 6020.
33 *
34 * While the primary unit in YANG is a module, a YANG module can itself
35 * be constructed out of several submodules. Submodules allow a module
36 * designer to split a complex model into several pieces where all the
37 * submodules contribute to a single namespace, which is defined by the
38 * module that includes the submodules.
39 *
40 * The "submodule" statement defines the submodule's name, and groups
41 * all statements that belong to the submodule together. The
42 * "submodule" statement's argument is the name of the submodule,
43 * followed by a block of sub-statements that hold detailed submodule
44 * information.
45 *
46 * The submodule's sub-statements
47 *
48 * +--------------+---------+-------------+------------------+
49 * | substatement | section | cardinality |data model mapping|
50 * +--------------+---------+-------------+------------------+
51 * | anyxml | 7.10 | 0..n | - not supported |
52 * | augment | 7.15 | 0..n | - child nodes |
53 * | belongs-to | 7.2.2 | 1 | - YangBelongsTo |
54 * | choice | 7.9 | 0..n | - child nodes |
55 * | contact | 7.1.8 | 0..1 | - string |
56 * | container | 7.5 | 0..n | - child nodes |
57 * | description | 7.19.3 | 0..1 | - string |
58 * | deviation | 7.18.3 | 0..n | - TODO |
59 * | extension | 7.17 | 0..n | - TODO |
60 * | feature | 7.18.1 | 0..n | - TODO |
61 * | grouping | 7.11 | 0..n | - child nodes |
62 * | identity | 7.16 | 0..n | - TODO |
63 * | import | 7.1.5 | 0..n | - YangImport |
64 * | include | 7.1.6 | 0..n | - YangInclude |
65 * | leaf | 7.6 | 0..n | - YangLeaf |
66 * | leaf-list | 7.7 | 0..n | - YangLeafList |
67 * | list | 7.8 | 0..n | - child nodes |
68 * | notification | 7.14 | 0..n | - TODO |
69 * | organization | 7.1.7 | 0..1 | - string |
70 * | reference | 7.19.4 | 0..1 | - string |
71 * | revision | 7.1.9 | 0..n | - string |
72 * | rpc | 7.13 | 0..n | - TODO |
73 * | typedef | 7.3 | 0..n | - child nodes |
74 * | uses | 7.12 | 0..n | - child nodes |
75 * | YANG-version | 7.1.2 | 0..1 | - int |
76 * +--------------+---------+-------------+------------------+
77 */
Gaurav Agrawal56527662016-04-20 15:49:17 +053078
Vinod Kumar S67e7be62016-02-11 20:13:28 +053079/**
Bharat saraswald9822e92016-04-05 15:13:44 +053080 * Represents data model node to maintain information defined in YANG sub-module.
Vinod Kumar S67e7be62016-02-11 20:13:28 +053081 */
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +053082public class YangSubModule
83 extends YangNode
Vinod Kumar Se4b9b0c2016-04-30 21:09:15 +053084 implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector, YangReferenceResolver,
85 RpcNotificationContainer {
Vinod Kumar S67e7be62016-02-11 20:13:28 +053086
Bharat saraswal96dfef02016-06-16 00:29:12 +053087 private static final long serialVersionUID = 806201614L;
88
Vinod Kumar S67e7be62016-02-11 20:13:28 +053089 /**
90 * Name of sub module.
91 */
92 private String name;
93
94 /**
95 * Module to which it belongs to.
96 */
97 private YangBelongsTo belongsTo;
98
99 /**
100 * Reference RFC 6020.
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530101 * <p>
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530102 * The "contact" statement provides contact information for the module. The
103 * argument is a string that is used to specify contact information for the
104 * person or persons to whom technical queries concerning this module should
105 * be sent, such as their name, postal address, telephone number, and
106 * electronic mail address.
107 */
108 private String contact;
109
110 /**
111 * Description.
112 */
113 private String description;
114
115 /**
116 * List of YANG modules imported.
117 */
118 private List<YangImport> importList;
119
120 /**
121 * List of YANG sub-modules included.
122 */
123 private List<YangInclude> includeList;
124
125 /**
126 * List of leaves at root level in the sub-module.
127 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530128 private List<YangLeaf> listOfLeaf;
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530129
130 /**
131 * List of leaf-lists at root level in the sub-module.
132 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530133 private List<YangLeafList> listOfLeafList;
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530134
135 /**
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530136 * Organization owner of the sub-module.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530137 */
138 private String organization;
139
140 /**
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530141 * Reference of the sub-module.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530142 */
143 private String reference;
144
145 /**
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530146 * Revision info of the sub-module.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530147 */
148 private YangRevision revision;
149
150 /**
151 * YANG version.
152 */
153 private byte version;
154
155 /**
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530156 * Prefix of parent module.
157 */
158 private String prefix;
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530159
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530160 /*-
161 * Reference RFC 6020.
162 *
163 * Nested typedefs and groupings.
164 * Typedefs and groupings may appear nested under many YANG statements,
165 * allowing these to be lexically scoped by the hierarchy under which
166 * they appear. This allows types and groupings to be defined near
167 * where they are used, rather than placing them at the top level of the
168 * hierarchy. The close proximity increases readability.
169 *
170 * Scoping also allows types to be defined without concern for naming
171 * conflicts between types in different submodules. Type names can be
172 * specified without adding leading strings designed to prevent name
173 * collisions within large modules.
174 *
175 * Finally, scoping allows the module author to keep types and groupings
176 * private to their module or submodule, preventing their reuse. Since
177 * only top-level types and groupings (i.e., those appearing as
178 * sub-statements to a module or submodule statement) can be used outside
179 * the module or submodule, the developer has more control over what
180 * pieces of their module are presented to the outside world, supporting
181 * the need to hide internal information and maintaining a boundary
182 * between what is shared with the outside world and what is kept
183 * private.
184 *
185 * Scoped definitions MUST NOT shadow definitions at a higher scope. A
186 * type or grouping cannot be defined if a higher level in the schema
187 * hierarchy has a definition with a matching identifier.
188 *
189 * A reference to an unprefixed type or grouping, or one which uses the
190 * prefix of the current module, is resolved by locating the closest
191 * matching "typedef" or "grouping" statement among the immediate
192 * sub-statements of each ancestor statement.
193 */
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530194 private List<YangResolutionInfo> derivedTypeResolutionList;
195
196 /**
197 * uses resolution list.
198 */
199 private List<YangResolutionInfo> usesResolutionList;
Gaurav Agrawal56527662016-04-20 15:49:17 +0530200
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530201 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530202 * Creates a sub module node.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530203 */
204 public YangSubModule() {
205 super(YangNodeType.SUB_MODULE_NODE);
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530206 derivedTypeResolutionList = new LinkedList<>();
207 usesResolutionList = new LinkedList<>();
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530208 importList = new LinkedList<YangImport>();
209 includeList = new LinkedList<YangInclude>();
210 listOfLeaf = new LinkedList<YangLeaf>();
211 listOfLeafList = new LinkedList<YangLeafList>();
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530212 }
213
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530214 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530215 * Returns the YANG name of the sub module.
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530216 *
217 * @return YANG name of the sub module
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530218 */
219 @Override
220 public String getName() {
221 return name;
222 }
223
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530224 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530225 * Sets YANG name of the sub module.
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530226 *
227 * @param subModuleName YANG name of the sub module
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530228 */
229 @Override
230 public void setName(String subModuleName) {
231 name = subModuleName;
232 }
233
234 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530235 * Returns the module info.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530236 *
237 * @return the belongs to info
238 */
239 public YangBelongsTo getBelongsTo() {
240 return belongsTo;
241 }
242
243 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530244 * Sets the module info.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530245 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530246 * @param belongsTo module info to set
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530247 */
248 public void setBelongsTo(YangBelongsTo belongsTo) {
249 this.belongsTo = belongsTo;
250 }
251
252 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530253 * Returns the contact.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530254 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530255 * @return the contact
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530256 */
257 public String getContact() {
258 return contact;
259 }
260
261 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530262 * Sets the contact.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530263 *
264 * @param contact the contact to set
265 */
266 public void setContact(String contact) {
267 this.contact = contact;
268 }
269
270 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530271 * Returns the description.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530272 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530273 * @return the description
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530274 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530275 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530276 public String getDescription() {
277 return description;
278 }
279
280 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530281 * Sets the description.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530282 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530283 * @param description set the description
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530284 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530285 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530286 public void setDescription(String description) {
287 this.description = description;
288 }
289
290 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530291 * Returns the list of imported modules.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530292 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530293 * @return the list of imported modules
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530294 */
Bharat saraswalcad0e652016-05-26 23:48:38 +0530295 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530296 public List<YangImport> getImportList() {
297 return importList;
298 }
299
300 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530301 * Adds the imported module information to the import list.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530302 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530303 * @param importedModule module being imported
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530304 */
Bharat saraswalcad0e652016-05-26 23:48:38 +0530305 @Override
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530306 public void addToImportList(YangImport importedModule) {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530307 getImportList().add(importedModule);
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530308 }
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530309
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530310 @Override
311 public void setImportList(List<YangImport> importList) {
312 this.importList = importList;
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530313 }
314
315 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530316 * Returns the list of included sub modules.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530317 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530318 * @return the included list of sub modules
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530319 */
Bharat saraswalcad0e652016-05-26 23:48:38 +0530320 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530321 public List<YangInclude> getIncludeList() {
322 return includeList;
323 }
324
325 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530326 * Returns the included sub module information to the include list.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530327 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530328 * @param includeModule submodule being included
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530329 */
Bharat saraswalcad0e652016-05-26 23:48:38 +0530330 @Override
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530331 public void addToIncludeList(YangInclude includeModule) {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530332 getIncludeList().add(includeModule);
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530333 }
334
335 @Override
336 public void setIncludeList(List<YangInclude> includeList) {
337 this.includeList = includeList;
338 }
339
340 @Override
341 public String getPrefix() {
342 return prefix;
343 }
344
345 @Override
346 public void setPrefix(String prefix) {
347 this.prefix = prefix;
348 }
349
350 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530351 public void resolveSelfFileLinking(ResolvableType type)
352 throws DataModelException {
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530353 // Get the list to be resolved.
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530354 List<YangResolutionInfo> resolutionList = getUnresolvedResolutionList(type);
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530355 // Resolve linking for a resolution list.
356 resolveLinkingForResolutionList(resolutionList, this);
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530357 }
358
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530359 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530360 public void resolveInterFileLinking(ResolvableType type)
361 throws DataModelException {
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530362 // Get the list to be resolved.
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530363 List<YangResolutionInfo> resolutionList = getUnresolvedResolutionList(type);
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530364 // Resolve linking for a resolution list.
365 linkInterFileReferences(resolutionList, this);
366 }
367
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530368 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530369 * Returns the list of leaves.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530370 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530371 * @return the list of leaves
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530372 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530373 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530374 public List<YangLeaf> getListOfLeaf() {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530375 return listOfLeaf;
376 }
377
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530378 @Override
379 public void setListOfLeaf(List<YangLeaf> leafsList) {
380 listOfLeaf = leafsList;
381 }
382
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530383 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530384 * Adds a leaf.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530385 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530386 * @param leaf the leaf to be added
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530387 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530388 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530389 public void addLeaf(YangLeaf leaf) {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530390 getListOfLeaf().add(leaf);
391 }
392
393 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530394 * Returns the list of leaf-list.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530395 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530396 * @return the list of leaf-list
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530397 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530398 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530399 public List<YangLeafList> getListOfLeafList() {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530400 return listOfLeafList;
401 }
402
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530403 @Override
404 public void setListOfLeafList(List<YangLeafList> listOfLeafList) {
405 this.listOfLeafList = listOfLeafList;
406 }
407
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530408 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530409 * Adds a leaf-list.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530410 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530411 * @param leafList the leaf-list to be added
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530412 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530413 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530414 public void addLeafList(YangLeafList leafList) {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530415 getListOfLeafList().add(leafList);
416 }
417
418 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530419 * Returns the sub-modules organization.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530420 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530421 * @return the organization
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530422 */
423 public String getOrganization() {
424 return organization;
425 }
426
427 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530428 * Sets the sub-modules organization.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530429 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530430 * @param org the organization to set
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530431 */
432 public void setOrganization(String org) {
433 organization = org;
434 }
435
436 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530437 * Returns the textual reference.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530438 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530439 * @return the reference
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530440 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530441 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530442 public String getReference() {
443 return reference;
444 }
445
446 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530447 * Sets the textual reference.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530448 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530449 * @param reference the reference to set
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530450 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530451 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530452 public void setReference(String reference) {
453 this.reference = reference;
454 }
455
456 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530457 * Returns the revision.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530458 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530459 * @return the revision
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530460 */
461 public YangRevision getRevision() {
462 return revision;
463 }
464
465 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530466 * Sets the revision.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530467 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530468 * @param revision the revision to set
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530469 */
470 public void setRevision(YangRevision revision) {
471 this.revision = revision;
472 }
473
474 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530475 * Returns the version.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530476 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530477 * @return the version
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530478 */
479 public byte getVersion() {
480 return version;
481 }
482
483 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530484 * Sets the version.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530485 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530486 * @param version the version to set
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530487 */
488 public void setVersion(byte version) {
489 this.version = version;
490 }
491
492 /**
493 * Returns the type of the parsed data.
494 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530495 * @return returns SUB_MODULE_DATA
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530496 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530497 @Override
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530498 public YangConstructType getYangConstructType() {
499 return YangConstructType.SUB_MODULE_DATA;
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530500 }
501
502 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530503 * Validates the data on entering the corresponding parse tree node.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530504 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530505 * @throws DataModelException a violation of data model rules
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530506 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530507 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530508 public void validateDataOnEntry()
509 throws DataModelException {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530510 // TODO auto-generated method stub, to be implemented by parser
511 }
512
513 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530514 * Validates the data on exiting the corresponding parse tree node.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530515 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530516 * @throws DataModelException a violation of data model rules
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530517 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530518 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530519 public void validateDataOnExit()
520 throws DataModelException {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530521 // TODO auto-generated method stub, to be implemented by parser
522 }
523
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530524 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530525 public void detectCollidingChild(String identifierName, YangConstructType dataType)
526 throws DataModelException {
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530527 // Asks helper to detect colliding child.
528 detectCollidingChildUtil(identifierName, dataType, this);
529 }
530
531 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530532 public void detectSelfCollision(String identifierName, YangConstructType dataType)
533 throws DataModelException {
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530534 // Not required as module doesn't have any parent.
535 }
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530536
537 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530538 public List<YangResolutionInfo> getUnresolvedResolutionList(ResolvableType type) {
539 if (type == ResolvableType.YANG_DERIVED_DATA_TYPE) {
540 return derivedTypeResolutionList;
541 } else {
542 return usesResolutionList;
543 }
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530544 }
545
546 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530547 public void addToResolutionList(YangResolutionInfo resolutionInfo,
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530548 ResolvableType type) {
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530549 if (type == ResolvableType.YANG_DERIVED_DATA_TYPE) {
550 derivedTypeResolutionList.add(resolutionInfo);
551 } else if (type == ResolvableType.YANG_USES) {
552 usesResolutionList.add(resolutionInfo);
553 }
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530554 }
555
556 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530557 public void setResolutionList(List<YangResolutionInfo> resolutionList,
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530558 ResolvableType type) {
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530559 if (type == ResolvableType.YANG_DERIVED_DATA_TYPE) {
560 derivedTypeResolutionList = resolutionList;
561 } else if (type == ResolvableType.YANG_USES) {
562 usesResolutionList = resolutionList;
563 }
564
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530565 }
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530566
567 /**
568 * Links the sub-module with module.
569 *
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530570 * @param yangNodeSet YANG file information set
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530571 * @throws DataModelException a violation in data model rule
572 */
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530573 public void linkWithModule(Set<YangNode> yangNodeSet)
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530574 throws DataModelException {
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530575 getBelongsTo().linkWithModule(yangNodeSet);
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530576 }
577
578 @Override
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530579 public void addReferencesToIncludeList(Set<YangNode> yangNodeSet)
580 throws DataModelException {
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530581 Iterator<YangInclude> includeInfoIterator = getIncludeList().iterator();
582 // Run through the included list to add references.
583 while (includeInfoIterator.hasNext()) {
584 YangInclude yangInclude = includeInfoIterator.next();
585 YangSubModule subModule = null;
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530586 subModule = yangInclude.addReferenceToInclude(yangNodeSet);
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530587 // Check if the referred sub-modules parent is self
588 if (!(subModule.getBelongsTo().getModuleNode() == getBelongsTo().getModuleNode())) {
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530589 yangInclude.reportIncludeError();
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530590 }
591 }
592 }
593
594 @Override
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530595 public void addReferencesToImportList(Set<YangNode> yangNodeSet)
596 throws DataModelException {
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530597 Iterator<YangImport> importInfoIterator = getImportList().iterator();
598 // Run through the imported list to add references.
599 while (importInfoIterator.hasNext()) {
600 YangImport yangImport = importInfoIterator.next();
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530601 yangImport.addReferenceToImport(yangNodeSet);
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530602 }
603 }
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530604}