blob: bf442a1e5f8e8c833125e0d051cfa90b52e25df0 [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 */
288 public List<YangImport> getImportList() {
289 return importList;
290 }
291
292 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530293 * Adds the imported module information to the import list.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530294 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530295 * @param importedModule module being imported
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530296 */
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530297 public void addToImportList(YangImport importedModule) {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530298 getImportList().add(importedModule);
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530299 }
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530300
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530301 @Override
302 public void setImportList(List<YangImport> importList) {
303 this.importList = importList;
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530304 }
305
306 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530307 * Returns the list of included sub modules.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530308 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530309 * @return the included list of sub modules
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530310 */
311 public List<YangInclude> getIncludeList() {
312 return includeList;
313 }
314
315 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530316 * Returns the included sub module information to the include list.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530317 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530318 * @param includeModule submodule being included
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530319 */
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530320 public void addToIncludeList(YangInclude includeModule) {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530321 getIncludeList().add(includeModule);
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530322 }
323
324 @Override
325 public void setIncludeList(List<YangInclude> includeList) {
326 this.includeList = includeList;
327 }
328
329 @Override
330 public String getPrefix() {
331 return prefix;
332 }
333
334 @Override
335 public void setPrefix(String prefix) {
336 this.prefix = prefix;
337 }
338
339 @Override
Ray Milkey994c4982016-05-11 18:39:39 +0000340 public void resolveSelfFileLinking() throws DataModelException {
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530341 // Get the list to be resolved.
342 List<YangResolutionInfo> resolutionList = getUnresolvedResolutionList();
343 // Resolve linking for a resolution list.
344 resolveLinkingForResolutionList(resolutionList, this);
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530345 }
346
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530347 @Override
348 public void resolveInterFileLinking() throws DataModelException {
349 // Get the list to be resolved.
350 List<YangResolutionInfo> resolutionList = getUnresolvedResolutionList();
351 // Resolve linking for a resolution list.
352 linkInterFileReferences(resolutionList, this);
353 }
354
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530355 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530356 * Returns the list of leaves.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530357 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530358 * @return the list of leaves
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530359 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530360 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530361 public List<YangLeaf> getListOfLeaf() {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530362 return listOfLeaf;
363 }
364
365 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530366 * Adds a leaf.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530367 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530368 * @param leaf the leaf to be added
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530369 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530370 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530371 public void addLeaf(YangLeaf leaf) {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530372 getListOfLeaf().add(leaf);
373 }
374
375 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530376 * Returns the list of leaf-list.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530377 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530378 * @return the list of leaf-list
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530379 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530380 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530381 public List<YangLeafList> getListOfLeafList() {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530382 return listOfLeafList;
383 }
384
385 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530386 * Adds a leaf-list.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530387 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530388 * @param leafList the leaf-list to be added
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530389 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530390 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530391 public void addLeafList(YangLeafList leafList) {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530392 getListOfLeafList().add(leafList);
393 }
394
395 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530396 * Returns the sub-modules organization.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530397 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530398 * @return the organization
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530399 */
400 public String getOrganization() {
401 return organization;
402 }
403
404 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530405 * Sets the sub-modules organization.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530406 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530407 * @param org the organization to set
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530408 */
409 public void setOrganization(String org) {
410 organization = org;
411 }
412
413 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530414 * Returns the textual reference.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530415 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530416 * @return the reference
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530417 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530418 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530419 public String getReference() {
420 return reference;
421 }
422
423 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530424 * Sets the textual reference.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530425 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530426 * @param reference the reference to set
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530427 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530428 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530429 public void setReference(String reference) {
430 this.reference = reference;
431 }
432
433 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530434 * Returns the revision.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530435 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530436 * @return the revision
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530437 */
438 public YangRevision getRevision() {
439 return revision;
440 }
441
442 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530443 * Sets the revision.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530444 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530445 * @param revision the revision to set
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530446 */
447 public void setRevision(YangRevision revision) {
448 this.revision = revision;
449 }
450
451 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530452 * Returns the version.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530453 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530454 * @return the version
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530455 */
456 public byte getVersion() {
457 return version;
458 }
459
460 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530461 * Sets the version.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530462 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530463 * @param version the version to set
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530464 */
465 public void setVersion(byte version) {
466 this.version = version;
467 }
468
469 /**
470 * Returns the type of the parsed data.
471 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530472 * @return returns SUB_MODULE_DATA
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530473 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530474 @Override
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530475 public YangConstructType getYangConstructType() {
476 return YangConstructType.SUB_MODULE_DATA;
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530477 }
478
479 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530480 * Validates the data on entering the corresponding parse tree node.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530481 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530482 * @throws DataModelException a violation of data model rules
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530483 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530484 @Override
Ray Milkey994c4982016-05-11 18:39:39 +0000485 public void validateDataOnEntry() throws DataModelException {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530486 // TODO auto-generated method stub, to be implemented by parser
487 }
488
489 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530490 * Validates the data on exiting the corresponding parse tree node.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530491 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530492 * @throws DataModelException a violation of data model rules
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530493 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530494 @Override
Ray Milkey994c4982016-05-11 18:39:39 +0000495 public void validateDataOnExit() throws DataModelException {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530496 // TODO auto-generated method stub, to be implemented by parser
497 }
498
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530499 @Override
Ray Milkey994c4982016-05-11 18:39:39 +0000500 public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException {
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530501 // Asks helper to detect colliding child.
502 detectCollidingChildUtil(identifierName, dataType, this);
503 }
504
505 @Override
Ray Milkey994c4982016-05-11 18:39:39 +0000506 public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException {
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530507 // Not required as module doesn't have any parent.
508 }
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530509
510 @Override
511 public List<YangResolutionInfo> getUnresolvedResolutionList() {
512 return unresolvedResolutionList;
513 }
514
515 @Override
516 public void addToResolutionList(YangResolutionInfo resolutionInfo) {
517 this.unresolvedResolutionList.add(resolutionInfo);
518 }
519
520 @Override
521 public void setResolutionList(List<YangResolutionInfo> resolutionList) {
522 this.unresolvedResolutionList = resolutionList;
523 }
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530524
525 /**
526 * Links the sub-module with module.
527 *
528 * @param yangFileInfoSet YANG file information set
529 * @throws DataModelException a violation in data model rule
530 */
531 public void linkWithModule(Set<YangFileInfo> yangFileInfoSet)
532 throws DataModelException {
533 getBelongsTo().linkWithModule(yangFileInfoSet);
534 }
535
536 @Override
537 public void addReferencesToIncludeList(Set<YangFileInfo> yangFileInfoSet)
538 throws LinkerException {
539 Iterator<YangInclude> includeInfoIterator = getIncludeList().iterator();
540 // Run through the included list to add references.
541 while (includeInfoIterator.hasNext()) {
542 YangInclude yangInclude = includeInfoIterator.next();
543 YangSubModule subModule = null;
544 try {
545 subModule = yangInclude.addReferenceToInclude(yangFileInfoSet);
546 } catch (DataModelException e) {
547 throw new LinkerException(e.getMessage());
548 }
549 // Check if the referred sub-modules parent is self
550 if (!(subModule.getBelongsTo().getModuleNode() == getBelongsTo().getModuleNode())) {
551 try {
552 yangInclude.reportIncludeError();
553 } catch (DataModelException e) {
554 throw new LinkerException(e.getMessage());
555 }
556 }
557 }
558 }
559
560 @Override
561 public void addReferencesToImportList(Set<YangFileInfo> yangFileInfoSet)
562 throws LinkerException {
563 Iterator<YangImport> importInfoIterator = getImportList().iterator();
564 // Run through the imported list to add references.
565 while (importInfoIterator.hasNext()) {
566 YangImport yangImport = importInfoIterator.next();
567 try {
568 yangImport.addReferenceToImport(yangFileInfoSet);
569 } catch (DataModelException e) {
570 throw new LinkerException(e.getMessage());
571 }
572 }
573 }
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530574}