blob: c2df52f3c7478006103d1180e9715088d2eeb876 [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,
Bharat saraswal2d90b0c2016-08-04 02:00:03 +053077 RpcNotificationContainer, YangFeatureHolder, YangIsFilterContentNodes {
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.
Bharat saraswal2d90b0c2016-08-04 02:00:03 +053088 * <p>
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.
Bharat saraswal2d90b0c2016-08-04 02:00:03 +053099 * <p>
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.
Bharat saraswal2d90b0c2016-08-04 02:00:03 +0530139 * <p>
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 saraswal2d90b0c2016-08-04 02:00:03 +0530214 * LeafRef resolution list.
janani be18b5342016-07-13 21:06:41 +0530215 */
Bharat saraswal2d90b0c2016-08-04 02:00:03 +0530216 private List<YangResolutionInfo> leafRefResolutionList;
janani be18b5342016-07-13 21:06:41 +0530217
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 saraswal2d90b0c2016-08-04 02:00:03 +0530224 * IdentityRef resolution list.
Shankara-Huaweidf7b9ca2016-07-14 11:35:34 +0530225 */
Bharat saraswal2d90b0c2016-08-04 02:00:03 +0530226 private List<YangResolutionInfo> identityRefResolutionList;
Shankara-Huaweidf7b9ca2016-07-14 11:35:34 +0530227
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 Rama07c26bb2016-07-28 17:33:15 +0530234 * Compiler annotation list.
235 */
236 private List<YangCompilerAnnotation> compilerAnnotationList;
237
238 /**
239 * Extension list.
Vidyashree Rama36f2fab2016-07-15 14:06:56 +0530240 */
241 private List<YangExtension> extensionList;
242
243 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530244 * Creates a YANG node of module type.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530245 */
246 public YangModule() {
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530247
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530248 super(YangNodeType.MODULE_NODE);
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530249 derivedTypeResolutionList = new LinkedList<>();
Bharat saraswalb1170bd2016-07-14 13:26:18 +0530250 augmentResolutionList = new LinkedList<>();
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530251 usesResolutionList = new LinkedList<>();
Vidyashree Ramadeac28b2016-06-20 15:12:43 +0530252 ifFeatureResolutionList = new LinkedList<>();
Bharat saraswal2d90b0c2016-08-04 02:00:03 +0530253 leafRefResolutionList = new LinkedList<>();
Shankara-Huaweidf7b9ca2016-07-14 11:35:34 +0530254 baseResolutionList = new LinkedList<>();
Bharat saraswal2d90b0c2016-08-04 02:00:03 +0530255 identityRefResolutionList = new LinkedList<>();
Vidyashree Rama07c26bb2016-07-28 17:33:15 +0530256 compilerAnnotationList = new LinkedList<>();
Bharat saraswal2d90b0c2016-08-04 02:00:03 +0530257 importList = new LinkedList<>();
258 includeList = new LinkedList<>();
259 listOfLeaf = new LinkedList<>();
260 listOfLeafList = new LinkedList<>();
261 extensionList = new LinkedList<>();
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530262 }
263
Vinod Kumar S71cba682016-02-25 15:52:16 +0530264 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530265 * Returns name of the module.
Vinod Kumar S71cba682016-02-25 15:52:16 +0530266 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530267 * @return module name
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530268 */
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530269 @Override
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530270 public String getName() {
271 return name;
272 }
273
Vinod Kumar S71cba682016-02-25 15:52:16 +0530274 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530275 * Sets module name.
Vinod Kumar S71cba682016-02-25 15:52:16 +0530276 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530277 * @param moduleName module name
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530278 */
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530279 @Override
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530280 public void setName(String moduleName) {
281 name = moduleName;
282 }
283
284 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530285 * Returns the contact details of the module owner.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530286 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530287 * @return the contact details of YANG owner
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530288 */
289 public String getContact() {
290 return contact;
291 }
292
293 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530294 * Sets the contact details of the module owner.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530295 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530296 * @param contact the contact details of YANG owner
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530297 */
298 public void setContact(String contact) {
299 this.contact = contact;
300 }
301
302 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530303 * Returns the description of module.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530304 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530305 * @return the description of YANG module
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530306 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530307 @Override
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530308 public String getDescription() {
309 return description;
310 }
311
312 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530313 * Sets the description of module.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530314 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530315 * @param description set the description of YANG module
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530316 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530317 @Override
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530318 public void setDescription(String description) {
319 this.description = description;
320 }
321
322 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530323 * Returns the list of imported modules.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530324 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530325 * @return the list of imported modules
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530326 */
Bharat saraswalcad0e652016-05-26 23:48:38 +0530327 @Override
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530328 public List<YangImport> getImportList() {
329 return importList;
330 }
331
332 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530333 * Adds the imported module information to the import list.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530334 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530335 * @param importedModule module being imported
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530336 */
Bharat saraswalcad0e652016-05-26 23:48:38 +0530337 @Override
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530338 public void addToImportList(YangImport importedModule) {
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530339 getImportList().add(importedModule);
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530340 }
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530341
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530342 @Override
343 public void setImportList(List<YangImport> importList) {
344 this.importList = importList;
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530345 }
346
347 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530348 * Returns the list of included sub modules.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530349 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530350 * @return the included list of sub modules
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530351 */
Bharat saraswalcad0e652016-05-26 23:48:38 +0530352 @Override
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530353 public List<YangInclude> getIncludeList() {
354 return includeList;
355 }
356
357 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530358 * Adds the included sub module information to the include list.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530359 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530360 * @param includeModule submodule being included
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530361 */
Bharat saraswalcad0e652016-05-26 23:48:38 +0530362 @Override
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530363 public void addToIncludeList(YangInclude includeModule) {
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530364 getIncludeList().add(includeModule);
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530365 }
366
367 @Override
368 public void setIncludeList(List<YangInclude> includeList) {
369 this.includeList = includeList;
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530370 }
371
372 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530373 * Returns the list of leaves in module.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530374 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530375 * @return the list of leaves
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530376 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530377 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530378 public List<YangLeaf> getListOfLeaf() {
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530379 return listOfLeaf;
380 }
381
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530382 @Override
383 public void setListOfLeaf(List<YangLeaf> leafsList) {
384 listOfLeaf = leafsList;
385 }
386
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530387 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530388 * Adds a leaf in module.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530389 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530390 * @param leaf the leaf to be added
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530391 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530392 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530393 public void addLeaf(YangLeaf leaf) {
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530394 getListOfLeaf().add(leaf);
395 }
396
397 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530398 * Returns the list of leaf-list from module.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530399 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530400 * @return the list of leaf-list
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530401 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530402 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530403 public List<YangLeafList> getListOfLeafList() {
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530404 return listOfLeafList;
405 }
406
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530407 @Override
408 public void setListOfLeafList(List<YangLeafList> listOfLeafList) {
409 this.listOfLeafList = listOfLeafList;
410 }
411
412
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530413 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530414 * Adds a leaf-list in module.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530415 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530416 * @param leafList the leaf-list to be added
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530417 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530418 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530419 public void addLeafList(YangLeafList leafList) {
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530420 getListOfLeafList().add(leafList);
421 }
422
Vidyashree Ramadeac28b2016-06-20 15:12:43 +0530423 @Override
424 public List<YangFeature> getFeatureList() {
425 return listOfFeature;
426 }
427
428 @Override
429 public void addFeatureList(YangFeature feature) {
430 if (getFeatureList() == null) {
431 setListOfFeature(new LinkedList<>());
432 }
433 getFeatureList().add(feature);
434 }
435
436 @Override
437 public void setListOfFeature(List<YangFeature> listOfFeature) {
438 this.listOfFeature = listOfFeature;
439 }
440
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530441 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530442 * Returns the name space of module elements.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530443 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530444 * @return the nameSpace
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530445 */
446 public YangNameSpace getNameSpace() {
447 return nameSpace;
448 }
449
450 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530451 * Sets the name space of module elements.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530452 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530453 * @param nameSpace the nameSpace to set
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530454 */
455 public void setNameSpace(YangNameSpace nameSpace) {
456 this.nameSpace = nameSpace;
457 }
458
459 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530460 * Returns the modules organization.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530461 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530462 * @return the organization
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530463 */
464 public String getOrganization() {
465 return organization;
466 }
467
468 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530469 * Sets the modules organization.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530470 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530471 * @param org the organization to set
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530472 */
473 public void setOrganization(String org) {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530474 organization = org;
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530475 }
476
477 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530478 * Returns the prefix.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530479 *
480 * @return the prefix
481 */
Bharat saraswalcad0e652016-05-26 23:48:38 +0530482 @Override
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530483 public String getPrefix() {
484 return prefix;
485 }
486
487 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530488 * Sets the prefix.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530489 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530490 * @param prefix the prefix to set
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530491 */
Bharat saraswalcad0e652016-05-26 23:48:38 +0530492 @Override
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530493 public void setPrefix(String prefix) {
494 this.prefix = prefix;
495 }
496
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530497 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530498 public void resolveSelfFileLinking(ResolvableType type)
499 throws DataModelException {
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530500 // Get the list to be resolved.
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530501 List<YangResolutionInfo> resolutionList = getUnresolvedResolutionList(type);
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530502 // Resolve linking for a resolution list.
503 resolveLinkingForResolutionList(resolutionList, this);
504 }
505
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530506 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530507 public void resolveInterFileLinking(ResolvableType type)
508 throws DataModelException {
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530509 // Get the list to be resolved.
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530510 List<YangResolutionInfo> resolutionList = getUnresolvedResolutionList(type);
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530511 // Resolve linking for a resolution list.
512 linkInterFileReferences(resolutionList, this);
513 }
514
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530515 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530516 * Returns the textual reference.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530517 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530518 * @return the reference
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530519 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530520 @Override
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530521 public String getReference() {
522 return reference;
523 }
524
525 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530526 * Sets the textual reference.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530527 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530528 * @param reference the reference to set
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530529 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530530 @Override
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530531 public void setReference(String reference) {
532 this.reference = reference;
533 }
534
535 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530536 * Returns the revision.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530537 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530538 * @return the revision
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530539 */
540 public YangRevision getRevision() {
541 return revision;
542 }
543
544 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530545 * Sets the revision.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530546 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530547 * @param revision the revision to set
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530548 */
549 public void setRevision(YangRevision revision) {
550 this.revision = revision;
551 }
552
553 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530554 * Returns the version.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530555 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530556 * @return the version
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530557 */
558 public byte getVersion() {
559 return version;
560 }
561
562 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530563 * Sets the version.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530564 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530565 * @param version the version to set
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530566 */
567 public void setVersion(byte version) {
568 this.version = version;
569 }
570
571 /**
Vidyashree Rama07c26bb2016-07-28 17:33:15 +0530572 * Adds compiler annotation in compiler-annotation list.
573 *
574 * @param compilerAnnotation the compiler-annotation to be added
575 */
576 public void addCompilerAnnotation(YangCompilerAnnotation compilerAnnotation) {
577 getCompilerAnnotationList().add(compilerAnnotation);
578 }
579
580 /**
581 * Returns the compiler annotation list.
582 *
583 * @return the compiler annotation list
584 */
585 public List<YangCompilerAnnotation> getCompilerAnnotationList() {
586 return compilerAnnotationList;
587 }
588
589 /**
590 * Sets the compiler-annotation list.
591 *
592 * @param compilerAnnotationList the list of compiler-annotation
593 */
594 public void setCompilerAnnotationList(List<YangCompilerAnnotation> compilerAnnotationList) {
595 this.compilerAnnotationList = compilerAnnotationList;
596 }
597
598 /**
Vidyashree Rama36f2fab2016-07-15 14:06:56 +0530599 * Adds extension in extension list.
600 *
601 * @param extension the extension to be added
602 */
603 public void addExtension(YangExtension extension) {
604 getExtensionList().add(extension);
605 }
606
607 /**
608 * Returns the extension list.
609 *
610 * @return the extension list
611 */
612 public List<YangExtension> getExtensionList() {
613 return extensionList;
614 }
615
616 /**
617 * Sets the extension list.
618 *
619 * @param extensionList the list of extension
620 */
621 public void setExtensionList(List<YangExtension> extensionList) {
622 this.extensionList = extensionList;
623 }
624
625 /**
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530626 * Returns the type of the parsed data.
627 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530628 * @return returns MODULE_DATA
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530629 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530630 @Override
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530631 public YangConstructType getYangConstructType() {
632 return YangConstructType.MODULE_DATA;
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530633 }
634
635 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530636 * Validates the data on entering the corresponding parse tree node.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530637 *
638 * @throws DataModelException a violation of data model rules
639 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530640 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530641 public void validateDataOnEntry()
642 throws DataModelException {
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530643 /*
644 * Module is root in the data model tree, hence there is no entry
645 * validation
646 */
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530647 }
648
649 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530650 * Validates the data on exiting the corresponding parse tree node.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530651 *
652 * @throws DataModelException a violation of data model rules
653 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530654 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530655 public void validateDataOnExit()
656 throws DataModelException {
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530657 /*
658 * TODO: perform symbol linking for the imported or included YANG info.
659 * TODO: perform symbol resolution for referred YANG entities.
660 */
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530661 }
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530662
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530663 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530664 public void detectCollidingChild(String identifierName, YangConstructType dataType)
665 throws DataModelException {
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530666 // Asks helper to detect colliding child.
667 detectCollidingChildUtil(identifierName, dataType, this);
668 }
669
670 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530671 public void detectSelfCollision(String identifierName, YangConstructType dataType)
672 throws DataModelException {
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530673 // Not required as module doesn't have any parent.
674 }
Vinod Kumar S38046502016-03-23 15:30:27 +0530675
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530676 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530677 public List<YangResolutionInfo> getUnresolvedResolutionList(ResolvableType type) {
678 if (type == ResolvableType.YANG_DERIVED_DATA_TYPE) {
679 return derivedTypeResolutionList;
Vidyashree Ramadeac28b2016-06-20 15:12:43 +0530680 } else if (type == ResolvableType.YANG_USES) {
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530681 return usesResolutionList;
Bharat saraswalb1170bd2016-07-14 13:26:18 +0530682 } else if (type == ResolvableType.YANG_AUGMENT) {
683 return augmentResolutionList;
janani be18b5342016-07-13 21:06:41 +0530684 } else if (type == ResolvableType.YANG_IF_FEATURE) {
Vidyashree Ramadeac28b2016-06-20 15:12:43 +0530685 return ifFeatureResolutionList;
Shankara-Huaweidf7b9ca2016-07-14 11:35:34 +0530686 } else if (type == ResolvableType.YANG_LEAFREF) {
Bharat saraswal2d90b0c2016-08-04 02:00:03 +0530687 return leafRefResolutionList;
Shankara-Huaweidf7b9ca2016-07-14 11:35:34 +0530688 } else if (type == ResolvableType.YANG_BASE) {
689 return baseResolutionList;
690 } else {
Bharat saraswal2d90b0c2016-08-04 02:00:03 +0530691 return identityRefResolutionList;
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530692 }
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530693 }
694
695 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530696 public void addToResolutionList(YangResolutionInfo resolutionInfo,
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530697 ResolvableType type) {
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530698 if (type == ResolvableType.YANG_DERIVED_DATA_TYPE) {
699 derivedTypeResolutionList.add(resolutionInfo);
700 } else if (type == ResolvableType.YANG_USES) {
701 usesResolutionList.add(resolutionInfo);
Vidyashree Ramadeac28b2016-06-20 15:12:43 +0530702 } else if (type == ResolvableType.YANG_IF_FEATURE) {
703 ifFeatureResolutionList.add(resolutionInfo);
Shankara-Huaweidf7b9ca2016-07-14 11:35:34 +0530704 } else if (type == ResolvableType.YANG_LEAFREF) {
Bharat saraswal2d90b0c2016-08-04 02:00:03 +0530705 leafRefResolutionList.add(resolutionInfo);
Shankara-Huaweidf7b9ca2016-07-14 11:35:34 +0530706 } else if (type == ResolvableType.YANG_BASE) {
707 baseResolutionList.add(resolutionInfo);
Vidyashree Rama36f2fab2016-07-15 14:06:56 +0530708 } else if (type == ResolvableType.YANG_AUGMENT) {
Bharat saraswalb1170bd2016-07-14 13:26:18 +0530709 augmentResolutionList.add(resolutionInfo);
Shankara-Huaweidf7b9ca2016-07-14 11:35:34 +0530710 } else if (type == ResolvableType.YANG_IDENTITYREF) {
Bharat saraswal2d90b0c2016-08-04 02:00:03 +0530711 identityRefResolutionList.add(resolutionInfo);
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530712 }
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530713 }
714
715 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530716 public void setResolutionList(List<YangResolutionInfo> resolutionList,
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530717 ResolvableType type) {
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530718 if (type == ResolvableType.YANG_DERIVED_DATA_TYPE) {
719 derivedTypeResolutionList = resolutionList;
720 } else if (type == ResolvableType.YANG_USES) {
721 usesResolutionList = resolutionList;
Vidyashree Ramadeac28b2016-06-20 15:12:43 +0530722 } else if (type == ResolvableType.YANG_IF_FEATURE) {
723 ifFeatureResolutionList.add((YangResolutionInfo) resolutionList);
janani be18b5342016-07-13 21:06:41 +0530724 } else if (type == ResolvableType.YANG_LEAFREF) {
Bharat saraswal2d90b0c2016-08-04 02:00:03 +0530725 leafRefResolutionList = resolutionList;
Shankara-Huaweidf7b9ca2016-07-14 11:35:34 +0530726 } else if (type == ResolvableType.YANG_BASE) {
727 baseResolutionList = resolutionList;
Vidyashree Rama36f2fab2016-07-15 14:06:56 +0530728 } else if (type == ResolvableType.YANG_AUGMENT) {
Bharat saraswalb1170bd2016-07-14 13:26:18 +0530729 augmentResolutionList = resolutionList;
Shankara-Huaweidf7b9ca2016-07-14 11:35:34 +0530730 } else if (type == ResolvableType.YANG_IDENTITYREF) {
Bharat saraswal2d90b0c2016-08-04 02:00:03 +0530731 identityRefResolutionList = resolutionList;
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530732 }
733
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530734 }
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530735
736 @Override
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530737 public void addReferencesToImportList(Set<YangNode> yangNodeSet)
738 throws DataModelException {
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530739 Iterator<YangImport> importInfoIterator = getImportList().iterator();
740 // Run through the imported list to add references.
741 while (importInfoIterator.hasNext()) {
742 YangImport yangImport = importInfoIterator.next();
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530743 yangImport.addReferenceToImport(yangNodeSet);
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530744 }
745 }
746
747 @Override
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530748 public void addReferencesToIncludeList(Set<YangNode> yangNodeSet)
749 throws DataModelException {
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530750 Iterator<YangInclude> includeInfoIterator = getIncludeList().iterator();
751 // Run through the included list to add references.
752 while (includeInfoIterator.hasNext()) {
753 YangInclude yangInclude = includeInfoIterator.next();
754 YangSubModule subModule = null;
Shankara-Huaweidf7b9ca2016-07-14 11:35:34 +0530755 subModule = yangInclude.addReferenceToInclude(yangNodeSet);
756
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530757 // Check if the referred sub-modules parent is self
758 if (!(subModule.getBelongsTo().getModuleNode() == this)) {
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530759 yangInclude.reportIncludeError();
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530760 }
761 }
762 }
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530763}