blob: 7a54aaf192f50677af037348b1e041d937413ac6 [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;
Vinod Kumar S38046502016-03-23 15:30:27 +053022import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +053023import org.onosproject.yangutils.linker.exceptions.LinkerException;
24import org.onosproject.yangutils.linker.impl.YangReferenceResolver;
25import org.onosproject.yangutils.linker.impl.YangResolutionInfo;
Vinod Kumar S38046502016-03-23 15:30:27 +053026import org.onosproject.yangutils.parser.Parsable;
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +053027import org.onosproject.yangutils.plugin.manager.YangFileInfo;
Vinod Kumar S38046502016-03-23 15:30:27 +053028import org.onosproject.yangutils.utils.YangConstructType;
29
30import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil;
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +053031import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.linkInterFileReferences;
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +053032import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.resolveLinkingForResolutionList;
Vinod Kumar S38046502016-03-23 15:30:27 +053033
Vinod Kumar S67e7be62016-02-11 20:13:28 +053034/*
35 * Reference RFC 6020.
36 *
37 * While the primary unit in YANG is a module, a YANG module can itself
38 * be constructed out of several submodules. Submodules allow a module
39 * designer to split a complex model into several pieces where all the
40 * submodules contribute to a single namespace, which is defined by the
41 * module that includes the submodules.
42 *
43 * The "submodule" statement defines the submodule's name, and groups
44 * all statements that belong to the submodule together. The
45 * "submodule" statement's argument is the name of the submodule,
46 * followed by a block of sub-statements that hold detailed submodule
47 * information.
48 *
49 * The submodule's sub-statements
50 *
51 * +--------------+---------+-------------+------------------+
52 * | substatement | section | cardinality |data model mapping|
53 * +--------------+---------+-------------+------------------+
54 * | anyxml | 7.10 | 0..n | - not supported |
55 * | augment | 7.15 | 0..n | - child nodes |
56 * | belongs-to | 7.2.2 | 1 | - YangBelongsTo |
57 * | choice | 7.9 | 0..n | - child nodes |
58 * | contact | 7.1.8 | 0..1 | - string |
59 * | container | 7.5 | 0..n | - child nodes |
60 * | description | 7.19.3 | 0..1 | - string |
61 * | deviation | 7.18.3 | 0..n | - TODO |
62 * | extension | 7.17 | 0..n | - TODO |
63 * | feature | 7.18.1 | 0..n | - TODO |
64 * | grouping | 7.11 | 0..n | - child nodes |
65 * | identity | 7.16 | 0..n | - TODO |
66 * | import | 7.1.5 | 0..n | - YangImport |
67 * | include | 7.1.6 | 0..n | - YangInclude |
68 * | leaf | 7.6 | 0..n | - YangLeaf |
69 * | leaf-list | 7.7 | 0..n | - YangLeafList |
70 * | list | 7.8 | 0..n | - child nodes |
71 * | notification | 7.14 | 0..n | - TODO |
72 * | organization | 7.1.7 | 0..1 | - string |
73 * | reference | 7.19.4 | 0..1 | - string |
74 * | revision | 7.1.9 | 0..n | - string |
75 * | rpc | 7.13 | 0..n | - TODO |
76 * | typedef | 7.3 | 0..n | - child nodes |
77 * | uses | 7.12 | 0..n | - child nodes |
78 * | YANG-version | 7.1.2 | 0..1 | - int |
79 * +--------------+---------+-------------+------------------+
80 */
Gaurav Agrawal56527662016-04-20 15:49:17 +053081
Vinod Kumar S67e7be62016-02-11 20:13:28 +053082/**
Bharat saraswald9822e92016-04-05 15:13:44 +053083 * Represents data model node to maintain information defined in YANG sub-module.
Vinod Kumar S67e7be62016-02-11 20:13:28 +053084 */
Ray Milkey994c4982016-05-11 18:39:39 +000085public class YangSubModule extends YangNode
Vinod Kumar Se4b9b0c2016-04-30 21:09:15 +053086 implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector, YangReferenceResolver,
87 RpcNotificationContainer {
Vinod Kumar S67e7be62016-02-11 20:13:28 +053088
89 /**
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;
159 /*-
160 * Reference RFC 6020.
161 *
162 * Nested typedefs and groupings.
163 * Typedefs and groupings may appear nested under many YANG statements,
164 * allowing these to be lexically scoped by the hierarchy under which
165 * they appear. This allows types and groupings to be defined near
166 * where they are used, rather than placing them at the top level of the
167 * hierarchy. The close proximity increases readability.
168 *
169 * Scoping also allows types to be defined without concern for naming
170 * conflicts between types in different submodules. Type names can be
171 * specified without adding leading strings designed to prevent name
172 * collisions within large modules.
173 *
174 * Finally, scoping allows the module author to keep types and groupings
175 * private to their module or submodule, preventing their reuse. Since
176 * only top-level types and groupings (i.e., those appearing as
177 * sub-statements to a module or submodule statement) can be used outside
178 * the module or submodule, the developer has more control over what
179 * pieces of their module are presented to the outside world, supporting
180 * the need to hide internal information and maintaining a boundary
181 * between what is shared with the outside world and what is kept
182 * private.
183 *
184 * Scoped definitions MUST NOT shadow definitions at a higher scope. A
185 * type or grouping cannot be defined if a higher level in the schema
186 * hierarchy has a definition with a matching identifier.
187 *
188 * A reference to an unprefixed type or grouping, or one which uses the
189 * prefix of the current module, is resolved by locating the closest
190 * matching "typedef" or "grouping" statement among the immediate
191 * sub-statements of each ancestor statement.
192 */
193 private List<YangResolutionInfo> unresolvedResolutionList;
Gaurav Agrawal56527662016-04-20 15:49:17 +0530194
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530195 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530196 * Creates a sub module node.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530197 */
198 public YangSubModule() {
199 super(YangNodeType.SUB_MODULE_NODE);
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530200 unresolvedResolutionList = new LinkedList<YangResolutionInfo>();
201 importList = new LinkedList<YangImport>();
202 includeList = new LinkedList<YangInclude>();
203 listOfLeaf = new LinkedList<YangLeaf>();
204 listOfLeafList = new LinkedList<YangLeafList>();
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530205 }
206
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530207 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530208 * Returns the YANG name of the sub module.
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530209 *
210 * @return YANG name of the sub module
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530211 */
212 @Override
213 public String getName() {
214 return name;
215 }
216
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530217 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530218 * Sets YANG name of the sub module.
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530219 *
220 * @param subModuleName YANG name of the sub module
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530221 */
222 @Override
223 public void setName(String subModuleName) {
224 name = subModuleName;
225 }
226
227 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530228 * Returns the module info.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530229 *
230 * @return the belongs to info
231 */
232 public YangBelongsTo getBelongsTo() {
233 return belongsTo;
234 }
235
236 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530237 * Sets the module info.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530238 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530239 * @param belongsTo module info to set
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530240 */
241 public void setBelongsTo(YangBelongsTo belongsTo) {
242 this.belongsTo = belongsTo;
243 }
244
245 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530246 * Returns the contact.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530247 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530248 * @return the contact
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530249 */
250 public String getContact() {
251 return contact;
252 }
253
254 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530255 * Sets the contact.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530256 *
257 * @param contact the contact to set
258 */
259 public void setContact(String contact) {
260 this.contact = contact;
261 }
262
263 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530264 * Returns the description.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530265 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530266 * @return the description
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530267 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530268 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530269 public String getDescription() {
270 return description;
271 }
272
273 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530274 * Sets the description.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530275 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530276 * @param description set the description
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530277 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530278 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530279 public void setDescription(String description) {
280 this.description = description;
281 }
282
283 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530284 * Returns the list of imported modules.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530285 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530286 * @return the list of imported modules
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530287 */
Bharat saraswalcad0e652016-05-26 23:48:38 +0530288 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530289 public List<YangImport> getImportList() {
290 return importList;
291 }
292
293 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530294 * Adds the imported module information to the import list.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530295 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530296 * @param importedModule module being imported
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530297 */
Bharat saraswalcad0e652016-05-26 23:48:38 +0530298 @Override
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530299 public void addToImportList(YangImport importedModule) {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530300 getImportList().add(importedModule);
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530301 }
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530302
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530303 @Override
304 public void setImportList(List<YangImport> importList) {
305 this.importList = importList;
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530306 }
307
308 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530309 * Returns the list of included sub modules.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530310 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530311 * @return the included list of sub modules
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530312 */
Bharat saraswalcad0e652016-05-26 23:48:38 +0530313 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530314 public List<YangInclude> getIncludeList() {
315 return includeList;
316 }
317
318 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530319 * Returns the included sub module information to the include list.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530320 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530321 * @param includeModule submodule being included
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530322 */
Bharat saraswalcad0e652016-05-26 23:48:38 +0530323 @Override
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530324 public void addToIncludeList(YangInclude includeModule) {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530325 getIncludeList().add(includeModule);
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530326 }
327
328 @Override
329 public void setIncludeList(List<YangInclude> includeList) {
330 this.includeList = includeList;
331 }
332
333 @Override
334 public String getPrefix() {
335 return prefix;
336 }
337
338 @Override
339 public void setPrefix(String prefix) {
340 this.prefix = prefix;
341 }
342
343 @Override
Ray Milkey994c4982016-05-11 18:39:39 +0000344 public void resolveSelfFileLinking() throws DataModelException {
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530345 // Get the list to be resolved.
346 List<YangResolutionInfo> resolutionList = getUnresolvedResolutionList();
347 // Resolve linking for a resolution list.
348 resolveLinkingForResolutionList(resolutionList, this);
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530349 }
350
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530351 @Override
352 public void resolveInterFileLinking() throws DataModelException {
353 // Get the list to be resolved.
354 List<YangResolutionInfo> resolutionList = getUnresolvedResolutionList();
355 // Resolve linking for a resolution list.
356 linkInterFileReferences(resolutionList, this);
357 }
358
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530359 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530360 * Returns the list of leaves.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530361 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530362 * @return the list of leaves
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530363 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530364 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530365 public List<YangLeaf> getListOfLeaf() {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530366 return listOfLeaf;
367 }
368
369 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530370 * Adds a leaf.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530371 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530372 * @param leaf the leaf to be added
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530373 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530374 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530375 public void addLeaf(YangLeaf leaf) {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530376 getListOfLeaf().add(leaf);
377 }
378
379 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530380 * Returns the list of leaf-list.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530381 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530382 * @return the list of leaf-list
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530383 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530384 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530385 public List<YangLeafList> getListOfLeafList() {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530386 return listOfLeafList;
387 }
388
389 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530390 * Adds a leaf-list.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530391 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530392 * @param leafList the leaf-list to be added
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530393 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530394 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530395 public void addLeafList(YangLeafList leafList) {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530396 getListOfLeafList().add(leafList);
397 }
398
399 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530400 * Returns the sub-modules organization.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530401 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530402 * @return the organization
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530403 */
404 public String getOrganization() {
405 return organization;
406 }
407
408 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530409 * Sets the sub-modules organization.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530410 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530411 * @param org the organization to set
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530412 */
413 public void setOrganization(String org) {
414 organization = org;
415 }
416
417 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530418 * Returns the textual reference.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530419 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530420 * @return the reference
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530421 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530422 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530423 public String getReference() {
424 return reference;
425 }
426
427 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530428 * Sets the textual reference.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530429 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530430 * @param reference the reference to set
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530431 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530432 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530433 public void setReference(String reference) {
434 this.reference = reference;
435 }
436
437 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530438 * Returns the revision.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530439 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530440 * @return the revision
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530441 */
442 public YangRevision getRevision() {
443 return revision;
444 }
445
446 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530447 * Sets the revision.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530448 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530449 * @param revision the revision to set
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530450 */
451 public void setRevision(YangRevision revision) {
452 this.revision = revision;
453 }
454
455 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530456 * Returns the version.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530457 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530458 * @return the version
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530459 */
460 public byte getVersion() {
461 return version;
462 }
463
464 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530465 * Sets the version.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530466 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530467 * @param version the version to set
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530468 */
469 public void setVersion(byte version) {
470 this.version = version;
471 }
472
473 /**
474 * Returns the type of the parsed data.
475 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530476 * @return returns SUB_MODULE_DATA
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530477 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530478 @Override
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530479 public YangConstructType getYangConstructType() {
480 return YangConstructType.SUB_MODULE_DATA;
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530481 }
482
483 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530484 * Validates the data on entering the corresponding parse tree node.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530485 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530486 * @throws DataModelException a violation of data model rules
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530487 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530488 @Override
Ray Milkey994c4982016-05-11 18:39:39 +0000489 public void validateDataOnEntry() throws DataModelException {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530490 // TODO auto-generated method stub, to be implemented by parser
491 }
492
493 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530494 * Validates the data on exiting the corresponding parse tree node.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530495 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530496 * @throws DataModelException a violation of data model rules
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530497 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530498 @Override
Ray Milkey994c4982016-05-11 18:39:39 +0000499 public void validateDataOnExit() throws DataModelException {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530500 // TODO auto-generated method stub, to be implemented by parser
501 }
502
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530503 @Override
Ray Milkey994c4982016-05-11 18:39:39 +0000504 public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException {
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530505 // Asks helper to detect colliding child.
506 detectCollidingChildUtil(identifierName, dataType, this);
507 }
508
509 @Override
Ray Milkey994c4982016-05-11 18:39:39 +0000510 public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException {
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530511 // Not required as module doesn't have any parent.
512 }
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530513
514 @Override
515 public List<YangResolutionInfo> getUnresolvedResolutionList() {
516 return unresolvedResolutionList;
517 }
518
519 @Override
520 public void addToResolutionList(YangResolutionInfo resolutionInfo) {
521 this.unresolvedResolutionList.add(resolutionInfo);
522 }
523
524 @Override
525 public void setResolutionList(List<YangResolutionInfo> resolutionList) {
526 this.unresolvedResolutionList = resolutionList;
527 }
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530528
529 /**
530 * Links the sub-module with module.
531 *
532 * @param yangFileInfoSet YANG file information set
533 * @throws DataModelException a violation in data model rule
534 */
535 public void linkWithModule(Set<YangFileInfo> yangFileInfoSet)
536 throws DataModelException {
537 getBelongsTo().linkWithModule(yangFileInfoSet);
538 }
539
540 @Override
541 public void addReferencesToIncludeList(Set<YangFileInfo> yangFileInfoSet)
542 throws LinkerException {
543 Iterator<YangInclude> includeInfoIterator = getIncludeList().iterator();
544 // Run through the included list to add references.
545 while (includeInfoIterator.hasNext()) {
546 YangInclude yangInclude = includeInfoIterator.next();
547 YangSubModule subModule = null;
548 try {
549 subModule = yangInclude.addReferenceToInclude(yangFileInfoSet);
550 } catch (DataModelException e) {
551 throw new LinkerException(e.getMessage());
552 }
553 // Check if the referred sub-modules parent is self
554 if (!(subModule.getBelongsTo().getModuleNode() == getBelongsTo().getModuleNode())) {
555 try {
556 yangInclude.reportIncludeError();
557 } catch (DataModelException e) {
558 throw new LinkerException(e.getMessage());
559 }
560 }
561 }
562 }
563
564 @Override
565 public void addReferencesToImportList(Set<YangFileInfo> yangFileInfoSet)
566 throws LinkerException {
567 Iterator<YangImport> importInfoIterator = getImportList().iterator();
568 // Run through the imported list to add references.
569 while (importInfoIterator.hasNext()) {
570 YangImport yangImport = importInfoIterator.next();
571 try {
572 yangImport.addReferenceToImport(yangFileInfoSet);
573 } catch (DataModelException e) {
574 throw new LinkerException(e.getMessage());
575 }
576 }
577 }
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530578}