blob: f9b1e874a3cea220adafe82c7f36f5b7ca24f531 [file] [log] [blame]
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +05301/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +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;
Bharat saraswal2f00b4b2016-03-04 20:08:09 +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
Bharat saraswal2f00b4b2016-03-04 20:08:09 +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 S67e7be62016-02-11 20:13:28 +053030
31/*-
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +053032 * Reference:RFC 6020.
33 * The "module" statement defines the module's name,
34 * and groups all statements that belong to the module together. The "module"
35 * statement's argument is the name of the module, followed by a block of
36 * sub statements that hold detailed module information.
37 * The module's sub statements
38 *
39 * +--------------+---------+-------------+-----------------------+
40 * |sub statement | section | cardinality | data model mapping |
41 * +--------------+---------+-------------+-----------------------+
42 * | anyxml | 7.10 | 0..n | not supported |
43 * | augment | 7.15 | 0..n | child nodes |
44 * | choice | 7.9 | 0..n | child nodes |
45 * | contact | 7.1.8 | 0..1 | string |
46 * | container | 7.5 | 0..n | child nodes |
47 * | description | 7.19.3 | 0..1 | string |
48 * | deviation | 7.18.3 | 0..n | TODO |
49 * | extension | 7.17 | 0..n | TODO |
50 * | feature | 7.18.1 | 0..n | TODO |
51 * | grouping | 7.11 | 0..n | child nodes |
52 * | identity | 7.16 | 0..n | TODO |
53 * | import | 7.1.5 | 0..n | list of import info |
54 * | include | 7.1.6 | 0..n | list of include info |
55 * | leaf | 7.6 | 0..n | list of leaf info |
56 * | leaf-list | 7.7 | 0..n | list of leaf-list info|
57 * | list | 7.8 | 0..n | child nodes |
58 * | namespace | 7.1.3 | 1 | string/uri |
59 * | notification | 7.14 | 0..n | TODO |
60 * | organization | 7.1.7 | 0..1 | string |
61 * | prefix | 7.1.4 | 1 | string |
62 * | reference | 7.19.4 | 0..1 | string |
63 * | revision | 7.1.9 | 0..n | revision |
64 * | rpc | 7.13 | 0..n | TODO |
65 * | typedef | 7.3 | 0..n | child nodes |
66 * | uses | 7.12 | 0..n | child nodes |
67 * | YANG-version | 7.1.2 | 0..1 | int |
68 * +--------------+---------+-------------+-----------------------+
69 */
70
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +053071/**
Bharat saraswald9822e92016-04-05 15:13:44 +053072 * Represents data model node to maintain information defined in YANG module.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +053073 */
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +053074public class YangModule
75 extends YangNode
Vinod Kumar Se4b9b0c2016-04-30 21:09:15 +053076 implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector, YangReferenceResolver,
Vidyashree Ramadeac28b2016-06-20 15:12:43 +053077 RpcNotificationContainer, YangFeatureHolder {
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +053078
Bharat saraswal96dfef02016-06-16 00:29:12 +053079 private static final long serialVersionUID = 806201610L;
80
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +053081 /**
82 * Name of the module.
83 */
84 private String name;
85
86 /**
87 * Reference:RFC 6020.
Vidyashree Ramadeac28b2016-06-20 15:12:43 +053088 *
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +053089 * The "contact" statement provides contact information for the module. The
90 * argument is a string that is used to specify contact information for the
91 * person or persons to whom technical queries concerning this module should
92 * be sent, such as their name, postal address, telephone number, and
93 * electronic mail address.
94 */
95 private String contact;
96
97 /**
98 * Reference:RFC 6020.
Vidyashree Ramadeac28b2016-06-20 15:12:43 +053099 *
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530100 * The "description" statement takes as an argument a string that contains a
101 * human-readable textual description of this definition. The text is
102 * provided in a language (or languages) chosen by the module developer; for
103 * the sake of interoperability.
104 */
105 private String description;
106
107 /**
108 * List of YANG modules imported.
109 */
110 private List<YangImport> importList;
111
112 /**
113 * List of YANG sub-modules included.
114 */
115 private List<YangInclude> includeList;
116
117 /**
118 * List of leaves at root level in the module.
119 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530120 private List<YangLeaf> listOfLeaf;
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530121
122 /**
123 * List of leaf-lists at root level in the module.
124 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530125 private List<YangLeafList> listOfLeafList;
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530126
127 /**
Vidyashree Ramadeac28b2016-06-20 15:12:43 +0530128 * List of feature at root level in the module.
129 */
130 private List<YangFeature> listOfFeature;
131
132 /**
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530133 * Name space of the module.
134 */
135 private YangNameSpace nameSpace;
136
137 /**
138 * Reference:RFC 6020.
Vidyashree Ramadeac28b2016-06-20 15:12:43 +0530139 *
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530140 * The "organization" statement defines the party responsible for this
141 * module. The argument is a string that is used to specify a textual
142 * description of the organization(s) under whose auspices this module was
143 * developed.
144 */
145 private String organization;
146
147 /**
148 * Prefix to refer to the objects in module.
149 */
150 private String prefix;
151
152 /**
153 * Reference of the module.
154 */
155 private String reference;
156
157 /**
158 * Revision info of the module.
159 */
160 private YangRevision revision;
161
162 /**
163 * YANG version.
164 */
165 private byte version;
166
Vinod Kumar S71cba682016-02-25 15:52:16 +0530167 /*-
Vinod Kumar Sc4216002016-03-03 19:55:30 +0530168 * Reference RFC 6020.
169 *
Vinod Kumar S71cba682016-02-25 15:52:16 +0530170 * Nested typedefs and groupings.
171 * Typedefs and groupings may appear nested under many YANG statements,
172 * allowing these to be lexically scoped by the hierarchy under which
173 * they appear. This allows types and groupings to be defined near
174 * where they are used, rather than placing them at the top level of the
175 * hierarchy. The close proximity increases readability.
176 *
177 * Scoping also allows types to be defined without concern for naming
178 * conflicts between types in different submodules. Type names can be
179 * specified without adding leading strings designed to prevent name
180 * collisions within large modules.
181 *
182 * Finally, scoping allows the module author to keep types and groupings
183 * private to their module or submodule, preventing their reuse. Since
184 * only top-level types and groupings (i.e., those appearing as
185 * sub-statements to a module or submodule statement) can be used outside
186 * the module or submodule, the developer has more control over what
187 * pieces of their module are presented to the outside world, supporting
188 * the need to hide internal information and maintaining a boundary
189 * between what is shared with the outside world and what is kept
190 * private.
191 *
192 * Scoped definitions MUST NOT shadow definitions at a higher scope. A
193 * type or grouping cannot be defined if a higher level in the schema
194 * hierarchy has a definition with a matching identifier.
195 *
196 * A reference to an unprefixed type or grouping, or one which uses the
197 * prefix of the current module, is resolved by locating the closest
198 * matching "typedef" or "grouping" statement among the immediate
199 * sub-statements of each ancestor statement.
200 */
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530201 private List<YangResolutionInfo> derivedTypeResolutionList;
202
203 /**
Bharat saraswalb1170bd2016-07-14 13:26:18 +0530204 * Uses resolution list.
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530205 */
206 private List<YangResolutionInfo> usesResolutionList;
Vinod Kumar S71cba682016-02-25 15:52:16 +0530207
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530208 /**
Bharat saraswalb1170bd2016-07-14 13:26:18 +0530209 * If-feature resolution list.
Vidyashree Ramadeac28b2016-06-20 15:12:43 +0530210 */
211 private List<YangResolutionInfo> ifFeatureResolutionList;
212
213 /**
Bharat saraswalb1170bd2016-07-14 13:26:18 +0530214 * Leafref resolution list.
janani be18b5342016-07-13 21:06:41 +0530215 */
216 private List<YangResolutionInfo> leafrefResolutionList;
217
218 /**
Bharat saraswalb1170bd2016-07-14 13:26:18 +0530219 * Base resolution list.
Shankara-Huaweidf7b9ca2016-07-14 11:35:34 +0530220 */
221 private List<YangResolutionInfo> baseResolutionList;
222
223 /**
Bharat saraswalb1170bd2016-07-14 13:26:18 +0530224 * Identityref resolution list.
Shankara-Huaweidf7b9ca2016-07-14 11:35:34 +0530225 */
226 private List<YangResolutionInfo> identityrefResolutionList;
227
Bharat saraswalb1170bd2016-07-14 13:26:18 +0530228 /**
229 * Augment resolution list.
230 */
231 private List<YangResolutionInfo> augmentResolutionList;
Shankara-Huaweidf7b9ca2016-07-14 11:35:34 +0530232
233 /**
Vidyashree Rama36f2fab2016-07-15 14:06:56 +0530234 * extension list.
235 */
236 private List<YangExtension> extensionList;
237
238 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530239 * Creates a YANG node of module type.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530240 */
241 public YangModule() {
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530242
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530243 super(YangNodeType.MODULE_NODE);
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530244 derivedTypeResolutionList = new LinkedList<>();
Bharat saraswalb1170bd2016-07-14 13:26:18 +0530245 augmentResolutionList = new LinkedList<>();
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530246 usesResolutionList = new LinkedList<>();
Vidyashree Ramadeac28b2016-06-20 15:12:43 +0530247 ifFeatureResolutionList = new LinkedList<>();
janani be18b5342016-07-13 21:06:41 +0530248 leafrefResolutionList = new LinkedList<>();
Shankara-Huaweidf7b9ca2016-07-14 11:35:34 +0530249 baseResolutionList = new LinkedList<>();
250 identityrefResolutionList = new LinkedList<>();
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530251 importList = new LinkedList<YangImport>();
252 includeList = new LinkedList<YangInclude>();
253 listOfLeaf = new LinkedList<YangLeaf>();
254 listOfLeafList = new LinkedList<YangLeafList>();
Vidyashree Rama36f2fab2016-07-15 14:06:56 +0530255 extensionList = new LinkedList<YangExtension>();
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530256 }
257
Vinod Kumar S71cba682016-02-25 15:52:16 +0530258 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530259 * Returns name of the module.
Vinod Kumar S71cba682016-02-25 15:52:16 +0530260 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530261 * @return module name
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530262 */
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530263 @Override
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530264 public String getName() {
265 return name;
266 }
267
Vinod Kumar S71cba682016-02-25 15:52:16 +0530268 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530269 * Sets module name.
Vinod Kumar S71cba682016-02-25 15:52:16 +0530270 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530271 * @param moduleName module name
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530272 */
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530273 @Override
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530274 public void setName(String moduleName) {
275 name = moduleName;
276 }
277
278 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530279 * Returns the contact details of the module owner.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530280 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530281 * @return the contact details of YANG owner
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530282 */
283 public String getContact() {
284 return contact;
285 }
286
287 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530288 * Sets the contact details of the module owner.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530289 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530290 * @param contact the contact details of YANG owner
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530291 */
292 public void setContact(String contact) {
293 this.contact = contact;
294 }
295
296 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530297 * Returns the description of module.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530298 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530299 * @return the description of YANG module
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530300 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530301 @Override
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530302 public String getDescription() {
303 return description;
304 }
305
306 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530307 * Sets the description of module.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530308 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530309 * @param description set the description of YANG module
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530310 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530311 @Override
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530312 public void setDescription(String description) {
313 this.description = description;
314 }
315
316 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530317 * Returns the list of imported modules.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530318 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530319 * @return the list of imported modules
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530320 */
Bharat saraswalcad0e652016-05-26 23:48:38 +0530321 @Override
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530322 public List<YangImport> getImportList() {
323 return importList;
324 }
325
326 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530327 * Adds the imported module information to the import list.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530328 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530329 * @param importedModule module being imported
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530330 */
Bharat saraswalcad0e652016-05-26 23:48:38 +0530331 @Override
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530332 public void addToImportList(YangImport importedModule) {
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530333 getImportList().add(importedModule);
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530334 }
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530335
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530336 @Override
337 public void setImportList(List<YangImport> importList) {
338 this.importList = importList;
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530339 }
340
341 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530342 * Returns the list of included sub modules.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530343 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530344 * @return the included list of sub modules
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530345 */
Bharat saraswalcad0e652016-05-26 23:48:38 +0530346 @Override
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530347 public List<YangInclude> getIncludeList() {
348 return includeList;
349 }
350
351 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530352 * Adds the included sub module information to the include list.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530353 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530354 * @param includeModule submodule being included
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530355 */
Bharat saraswalcad0e652016-05-26 23:48:38 +0530356 @Override
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530357 public void addToIncludeList(YangInclude includeModule) {
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530358 getIncludeList().add(includeModule);
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530359 }
360
361 @Override
362 public void setIncludeList(List<YangInclude> includeList) {
363 this.includeList = includeList;
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530364 }
365
366 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530367 * Returns the list of leaves in module.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530368 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530369 * @return the list of leaves
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530370 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530371 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530372 public List<YangLeaf> getListOfLeaf() {
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530373 return listOfLeaf;
374 }
375
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530376 @Override
377 public void setListOfLeaf(List<YangLeaf> leafsList) {
378 listOfLeaf = leafsList;
379 }
380
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530381 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530382 * Adds a leaf in module.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530383 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530384 * @param leaf the leaf to be added
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530385 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530386 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530387 public void addLeaf(YangLeaf leaf) {
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530388 getListOfLeaf().add(leaf);
389 }
390
391 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530392 * Returns the list of leaf-list from module.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530393 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530394 * @return the list of leaf-list
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530395 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530396 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530397 public List<YangLeafList> getListOfLeafList() {
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530398 return listOfLeafList;
399 }
400
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530401 @Override
402 public void setListOfLeafList(List<YangLeafList> listOfLeafList) {
403 this.listOfLeafList = listOfLeafList;
404 }
405
406
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530407 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530408 * Adds a leaf-list in module.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530409 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530410 * @param leafList the leaf-list to be added
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530411 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530412 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530413 public void addLeafList(YangLeafList leafList) {
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530414 getListOfLeafList().add(leafList);
415 }
416
Vidyashree Ramadeac28b2016-06-20 15:12:43 +0530417 @Override
418 public List<YangFeature> getFeatureList() {
419 return listOfFeature;
420 }
421
422 @Override
423 public void addFeatureList(YangFeature feature) {
424 if (getFeatureList() == null) {
425 setListOfFeature(new LinkedList<>());
426 }
427 getFeatureList().add(feature);
428 }
429
430 @Override
431 public void setListOfFeature(List<YangFeature> listOfFeature) {
432 this.listOfFeature = listOfFeature;
433 }
434
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530435 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530436 * Returns the name space of module elements.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530437 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530438 * @return the nameSpace
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530439 */
440 public YangNameSpace getNameSpace() {
441 return nameSpace;
442 }
443
444 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530445 * Sets the name space of module elements.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530446 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530447 * @param nameSpace the nameSpace to set
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530448 */
449 public void setNameSpace(YangNameSpace nameSpace) {
450 this.nameSpace = nameSpace;
451 }
452
453 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530454 * Returns the modules organization.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530455 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530456 * @return the organization
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530457 */
458 public String getOrganization() {
459 return organization;
460 }
461
462 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530463 * Sets the modules organization.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530464 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530465 * @param org the organization to set
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530466 */
467 public void setOrganization(String org) {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530468 organization = org;
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530469 }
470
471 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530472 * Returns the prefix.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530473 *
474 * @return the prefix
475 */
Bharat saraswalcad0e652016-05-26 23:48:38 +0530476 @Override
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530477 public String getPrefix() {
478 return prefix;
479 }
480
481 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530482 * Sets the prefix.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530483 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530484 * @param prefix the prefix to set
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530485 */
Bharat saraswalcad0e652016-05-26 23:48:38 +0530486 @Override
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530487 public void setPrefix(String prefix) {
488 this.prefix = prefix;
489 }
490
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530491 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530492 public void resolveSelfFileLinking(ResolvableType type)
493 throws DataModelException {
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530494 // Get the list to be resolved.
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530495 List<YangResolutionInfo> resolutionList = getUnresolvedResolutionList(type);
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530496 // Resolve linking for a resolution list.
497 resolveLinkingForResolutionList(resolutionList, this);
498 }
499
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530500 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530501 public void resolveInterFileLinking(ResolvableType type)
502 throws DataModelException {
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530503 // Get the list to be resolved.
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530504 List<YangResolutionInfo> resolutionList = getUnresolvedResolutionList(type);
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530505 // Resolve linking for a resolution list.
506 linkInterFileReferences(resolutionList, this);
507 }
508
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530509 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530510 * Returns the textual reference.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530511 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530512 * @return the reference
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530513 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530514 @Override
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530515 public String getReference() {
516 return reference;
517 }
518
519 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530520 * Sets the textual reference.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530521 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530522 * @param reference the reference to set
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530523 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530524 @Override
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530525 public void setReference(String reference) {
526 this.reference = reference;
527 }
528
529 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530530 * Returns the revision.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530531 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530532 * @return the revision
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530533 */
534 public YangRevision getRevision() {
535 return revision;
536 }
537
538 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530539 * Sets the revision.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530540 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530541 * @param revision the revision to set
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530542 */
543 public void setRevision(YangRevision revision) {
544 this.revision = revision;
545 }
546
547 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530548 * Returns the version.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530549 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530550 * @return the version
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530551 */
552 public byte getVersion() {
553 return version;
554 }
555
556 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530557 * Sets the version.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530558 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530559 * @param version the version to set
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530560 */
561 public void setVersion(byte version) {
562 this.version = version;
563 }
564
565 /**
Vidyashree Rama36f2fab2016-07-15 14:06:56 +0530566 * Adds extension in extension list.
567 *
568 * @param extension the extension to be added
569 */
570 public void addExtension(YangExtension extension) {
571 getExtensionList().add(extension);
572 }
573
574 /**
575 * Returns the extension list.
576 *
577 * @return the extension list
578 */
579 public List<YangExtension> getExtensionList() {
580 return extensionList;
581 }
582
583 /**
584 * Sets the extension list.
585 *
586 * @param extensionList the list of extension
587 */
588 public void setExtensionList(List<YangExtension> extensionList) {
589 this.extensionList = extensionList;
590 }
591
592 /**
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530593 * Returns the type of the parsed data.
594 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530595 * @return returns MODULE_DATA
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530596 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530597 @Override
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530598 public YangConstructType getYangConstructType() {
599 return YangConstructType.MODULE_DATA;
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530600 }
601
602 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530603 * Validates the data on entering the corresponding parse tree node.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530604 *
605 * @throws DataModelException a violation of data model rules
606 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530607 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530608 public void validateDataOnEntry()
609 throws DataModelException {
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530610 /*
611 * Module is root in the data model tree, hence there is no entry
612 * validation
613 */
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530614 }
615
616 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530617 * Validates the data on exiting the corresponding parse tree node.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530618 *
619 * @throws DataModelException a violation of data model rules
620 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530621 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530622 public void validateDataOnExit()
623 throws DataModelException {
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530624 /*
625 * TODO: perform symbol linking for the imported or included YANG info.
626 * TODO: perform symbol resolution for referred YANG entities.
627 */
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530628 }
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530629
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530630 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530631 public void detectCollidingChild(String identifierName, YangConstructType dataType)
632 throws DataModelException {
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530633 // Asks helper to detect colliding child.
634 detectCollidingChildUtil(identifierName, dataType, this);
635 }
636
637 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530638 public void detectSelfCollision(String identifierName, YangConstructType dataType)
639 throws DataModelException {
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530640 // Not required as module doesn't have any parent.
641 }
Vinod Kumar S38046502016-03-23 15:30:27 +0530642
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530643 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530644 public List<YangResolutionInfo> getUnresolvedResolutionList(ResolvableType type) {
645 if (type == ResolvableType.YANG_DERIVED_DATA_TYPE) {
646 return derivedTypeResolutionList;
Vidyashree Ramadeac28b2016-06-20 15:12:43 +0530647 } else if (type == ResolvableType.YANG_USES) {
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530648 return usesResolutionList;
Bharat saraswalb1170bd2016-07-14 13:26:18 +0530649 } else if (type == ResolvableType.YANG_AUGMENT) {
650 return augmentResolutionList;
janani be18b5342016-07-13 21:06:41 +0530651 } else if (type == ResolvableType.YANG_IF_FEATURE) {
Vidyashree Ramadeac28b2016-06-20 15:12:43 +0530652 return ifFeatureResolutionList;
Shankara-Huaweidf7b9ca2016-07-14 11:35:34 +0530653 } else if (type == ResolvableType.YANG_LEAFREF) {
janani be18b5342016-07-13 21:06:41 +0530654 return leafrefResolutionList;
Shankara-Huaweidf7b9ca2016-07-14 11:35:34 +0530655 } else if (type == ResolvableType.YANG_BASE) {
656 return baseResolutionList;
657 } else {
658 return identityrefResolutionList;
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530659 }
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530660 }
661
662 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530663 public void addToResolutionList(YangResolutionInfo resolutionInfo,
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530664 ResolvableType type) {
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530665 if (type == ResolvableType.YANG_DERIVED_DATA_TYPE) {
666 derivedTypeResolutionList.add(resolutionInfo);
667 } else if (type == ResolvableType.YANG_USES) {
668 usesResolutionList.add(resolutionInfo);
Vidyashree Ramadeac28b2016-06-20 15:12:43 +0530669 } else if (type == ResolvableType.YANG_IF_FEATURE) {
670 ifFeatureResolutionList.add(resolutionInfo);
Shankara-Huaweidf7b9ca2016-07-14 11:35:34 +0530671 } else if (type == ResolvableType.YANG_LEAFREF) {
janani be18b5342016-07-13 21:06:41 +0530672 leafrefResolutionList.add(resolutionInfo);
Shankara-Huaweidf7b9ca2016-07-14 11:35:34 +0530673 } else if (type == ResolvableType.YANG_BASE) {
674 baseResolutionList.add(resolutionInfo);
Vidyashree Rama36f2fab2016-07-15 14:06:56 +0530675 } else if (type == ResolvableType.YANG_AUGMENT) {
Bharat saraswalb1170bd2016-07-14 13:26:18 +0530676 augmentResolutionList.add(resolutionInfo);
Shankara-Huaweidf7b9ca2016-07-14 11:35:34 +0530677 } else if (type == ResolvableType.YANG_IDENTITYREF) {
678 identityrefResolutionList.add(resolutionInfo);
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530679 }
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530680 }
681
682 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530683 public void setResolutionList(List<YangResolutionInfo> resolutionList,
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530684 ResolvableType type) {
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530685 if (type == ResolvableType.YANG_DERIVED_DATA_TYPE) {
686 derivedTypeResolutionList = resolutionList;
687 } else if (type == ResolvableType.YANG_USES) {
688 usesResolutionList = resolutionList;
Vidyashree Ramadeac28b2016-06-20 15:12:43 +0530689 } else if (type == ResolvableType.YANG_IF_FEATURE) {
690 ifFeatureResolutionList.add((YangResolutionInfo) resolutionList);
janani be18b5342016-07-13 21:06:41 +0530691 } else if (type == ResolvableType.YANG_LEAFREF) {
692 leafrefResolutionList = resolutionList;
Shankara-Huaweidf7b9ca2016-07-14 11:35:34 +0530693 } else if (type == ResolvableType.YANG_BASE) {
694 baseResolutionList = resolutionList;
Vidyashree Rama36f2fab2016-07-15 14:06:56 +0530695 } else if (type == ResolvableType.YANG_AUGMENT) {
Bharat saraswalb1170bd2016-07-14 13:26:18 +0530696 augmentResolutionList = resolutionList;
Shankara-Huaweidf7b9ca2016-07-14 11:35:34 +0530697 } else if (type == ResolvableType.YANG_IDENTITYREF) {
698 identityrefResolutionList = resolutionList;
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530699 }
700
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530701 }
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530702
703 @Override
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530704 public void addReferencesToImportList(Set<YangNode> yangNodeSet)
705 throws DataModelException {
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530706 Iterator<YangImport> importInfoIterator = getImportList().iterator();
707 // Run through the imported list to add references.
708 while (importInfoIterator.hasNext()) {
709 YangImport yangImport = importInfoIterator.next();
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530710 yangImport.addReferenceToImport(yangNodeSet);
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530711 }
712 }
713
714 @Override
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530715 public void addReferencesToIncludeList(Set<YangNode> yangNodeSet)
716 throws DataModelException {
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530717 Iterator<YangInclude> includeInfoIterator = getIncludeList().iterator();
718 // Run through the included list to add references.
719 while (includeInfoIterator.hasNext()) {
720 YangInclude yangInclude = includeInfoIterator.next();
721 YangSubModule subModule = null;
Shankara-Huaweidf7b9ca2016-07-14 11:35:34 +0530722 subModule = yangInclude.addReferenceToInclude(yangNodeSet);
723
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530724 // Check if the referred sub-modules parent is self
725 if (!(subModule.getBelongsTo().getModuleNode() == this)) {
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530726 yangInclude.reportIncludeError();
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530727 }
728 }
729 }
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530730}