blob: a58eb7d159631108830cc7ca1343013f2527cfb1 [file] [log] [blame]
Vinod Kumar S67e7be62016-02-11 20:13:28 +05301/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Vinod Kumar S67e7be62016-02-11 20:13:28 +05303 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.yangutils.datamodel;
17
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +053018import java.util.Iterator;
Vinod Kumar S67e7be62016-02-11 20:13:28 +053019import java.util.LinkedList;
20import java.util.List;
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +053021import java.util.Set;
Bharat saraswal96dfef02016-06-16 00:29:12 +053022
Vinod Kumar S38046502016-03-23 15:30:27 +053023import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
Bharat saraswal96dfef02016-06-16 00:29:12 +053024import org.onosproject.yangutils.datamodel.utils.Parsable;
25import org.onosproject.yangutils.datamodel.utils.YangConstructType;
Vinod Kumar S38046502016-03-23 15:30:27 +053026
27import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil;
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +053028import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.linkInterFileReferences;
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +053029import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.resolveLinkingForResolutionList;
Vinod Kumar S38046502016-03-23 15:30:27 +053030
Vinod Kumar S67e7be62016-02-11 20:13:28 +053031/*
32 * Reference RFC 6020.
33 *
34 * While the primary unit in YANG is a module, a YANG module can itself
35 * be constructed out of several submodules. Submodules allow a module
36 * designer to split a complex model into several pieces where all the
37 * submodules contribute to a single namespace, which is defined by the
38 * module that includes the submodules.
39 *
40 * The "submodule" statement defines the submodule's name, and groups
41 * all statements that belong to the submodule together. The
42 * "submodule" statement's argument is the name of the submodule,
43 * followed by a block of sub-statements that hold detailed submodule
44 * information.
45 *
46 * The submodule's sub-statements
47 *
48 * +--------------+---------+-------------+------------------+
49 * | substatement | section | cardinality |data model mapping|
50 * +--------------+---------+-------------+------------------+
51 * | anyxml | 7.10 | 0..n | - not supported |
52 * | augment | 7.15 | 0..n | - child nodes |
53 * | belongs-to | 7.2.2 | 1 | - YangBelongsTo |
54 * | choice | 7.9 | 0..n | - child nodes |
55 * | contact | 7.1.8 | 0..1 | - string |
56 * | container | 7.5 | 0..n | - child nodes |
57 * | description | 7.19.3 | 0..1 | - string |
58 * | deviation | 7.18.3 | 0..n | - TODO |
59 * | extension | 7.17 | 0..n | - TODO |
Vidyashree Ramadeac28b2016-06-20 15:12:43 +053060 * | feature | 7.18.1 | 0..n | - YangFeature |
Vinod Kumar S67e7be62016-02-11 20:13:28 +053061 * | grouping | 7.11 | 0..n | - child nodes |
62 * | identity | 7.16 | 0..n | - TODO |
63 * | import | 7.1.5 | 0..n | - YangImport |
64 * | include | 7.1.6 | 0..n | - YangInclude |
65 * | leaf | 7.6 | 0..n | - YangLeaf |
66 * | leaf-list | 7.7 | 0..n | - YangLeafList |
67 * | list | 7.8 | 0..n | - child nodes |
68 * | notification | 7.14 | 0..n | - TODO |
69 * | organization | 7.1.7 | 0..1 | - string |
70 * | reference | 7.19.4 | 0..1 | - string |
71 * | revision | 7.1.9 | 0..n | - string |
72 * | rpc | 7.13 | 0..n | - TODO |
73 * | typedef | 7.3 | 0..n | - child nodes |
74 * | uses | 7.12 | 0..n | - child nodes |
75 * | YANG-version | 7.1.2 | 0..1 | - int |
76 * +--------------+---------+-------------+------------------+
77 */
Gaurav Agrawal56527662016-04-20 15:49:17 +053078
Vinod Kumar S67e7be62016-02-11 20:13:28 +053079/**
Bharat saraswald9822e92016-04-05 15:13:44 +053080 * Represents data model node to maintain information defined in YANG sub-module.
Vinod Kumar S67e7be62016-02-11 20:13:28 +053081 */
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +053082public class YangSubModule
83 extends YangNode
Vinod Kumar Se4b9b0c2016-04-30 21:09:15 +053084 implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector, YangReferenceResolver,
Bharat saraswal2d90b0c2016-08-04 02:00:03 +053085 RpcNotificationContainer, YangFeatureHolder, YangIsFilterContentNodes {
Vinod Kumar S67e7be62016-02-11 20:13:28 +053086
Bharat saraswal96dfef02016-06-16 00:29:12 +053087 private static final long serialVersionUID = 806201614L;
88
Vinod Kumar S67e7be62016-02-11 20:13:28 +053089 /**
90 * Name of sub module.
91 */
92 private String name;
93
94 /**
95 * Module to which it belongs to.
96 */
97 private YangBelongsTo belongsTo;
98
99 /**
100 * Reference RFC 6020.
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530101 * <p>
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530102 * The "contact" statement provides contact information for the module. The
103 * argument is a string that is used to specify contact information for the
104 * person or persons to whom technical queries concerning this module should
105 * be sent, such as their name, postal address, telephone number, and
106 * electronic mail address.
107 */
108 private String contact;
109
110 /**
111 * Description.
112 */
113 private String description;
114
115 /**
116 * List of YANG modules imported.
117 */
118 private List<YangImport> importList;
119
120 /**
121 * List of YANG sub-modules included.
122 */
123 private List<YangInclude> includeList;
124
125 /**
126 * List of leaves at root level in the sub-module.
127 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530128 private List<YangLeaf> listOfLeaf;
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530129
130 /**
131 * List of leaf-lists at root level in the sub-module.
132 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530133 private List<YangLeafList> listOfLeafList;
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530134
135 /**
Vidyashree Ramadeac28b2016-06-20 15:12:43 +0530136 * List of feature at root level in the module.
137 */
138 private List<YangFeature> listOfFeature;
139
140 /**
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530141 * Organization owner of the sub-module.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530142 */
143 private String organization;
144
145 /**
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530146 * Reference of the sub-module.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530147 */
148 private String reference;
149
150 /**
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530151 * Revision info of the sub-module.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530152 */
153 private YangRevision revision;
154
155 /**
156 * YANG version.
157 */
158 private byte version;
159
160 /**
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530161 * Prefix of parent module.
162 */
163 private String prefix;
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530164
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530165 /*-
166 * Reference RFC 6020.
167 *
168 * Nested typedefs and groupings.
169 * Typedefs and groupings may appear nested under many YANG statements,
170 * allowing these to be lexically scoped by the hierarchy under which
171 * they appear. This allows types and groupings to be defined near
172 * where they are used, rather than placing them at the top level of the
173 * hierarchy. The close proximity increases readability.
174 *
175 * Scoping also allows types to be defined without concern for naming
176 * conflicts between types in different submodules. Type names can be
177 * specified without adding leading strings designed to prevent name
178 * collisions within large modules.
179 *
180 * Finally, scoping allows the module author to keep types and groupings
181 * private to their module or submodule, preventing their reuse. Since
182 * only top-level types and groupings (i.e., those appearing as
183 * sub-statements to a module or submodule statement) can be used outside
184 * the module or submodule, the developer has more control over what
185 * pieces of their module are presented to the outside world, supporting
186 * the need to hide internal information and maintaining a boundary
187 * between what is shared with the outside world and what is kept
188 * private.
189 *
190 * Scoped definitions MUST NOT shadow definitions at a higher scope. A
191 * type or grouping cannot be defined if a higher level in the schema
192 * hierarchy has a definition with a matching identifier.
193 *
194 * A reference to an unprefixed type or grouping, or one which uses the
195 * prefix of the current module, is resolved by locating the closest
196 * matching "typedef" or "grouping" statement among the immediate
197 * sub-statements of each ancestor statement.
198 */
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530199 private List<YangResolutionInfo> derivedTypeResolutionList;
200
201 /**
Bharat saraswalb1170bd2016-07-14 13:26:18 +0530202 * Uses resolution list.
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530203 */
204 private List<YangResolutionInfo> usesResolutionList;
Gaurav Agrawal56527662016-04-20 15:49:17 +0530205
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530206 /**
Bharat saraswalb1170bd2016-07-14 13:26:18 +0530207 * If-feature resolution list.
Vidyashree Ramadeac28b2016-06-20 15:12:43 +0530208 */
209 private List<YangResolutionInfo> ifFeatureResolutionList;
210
211 /**
Bharat saraswal2d90b0c2016-08-04 02:00:03 +0530212 * LeafRef resolution list.
janani be18b5342016-07-13 21:06:41 +0530213 */
Bharat saraswal2d90b0c2016-08-04 02:00:03 +0530214 private List<YangResolutionInfo> leafRefResolutionList;
janani be18b5342016-07-13 21:06:41 +0530215
216 /**
Bharat saraswalb1170bd2016-07-14 13:26:18 +0530217 * Base resolution list.
Shankara-Huaweidf7b9ca2016-07-14 11:35:34 +0530218 */
219 private List<YangResolutionInfo> baseResolutionList;
220
221 /**
Bharat saraswal2d90b0c2016-08-04 02:00:03 +0530222 * IdentityRef resolution list.
Shankara-Huaweidf7b9ca2016-07-14 11:35:34 +0530223 */
Bharat saraswal2d90b0c2016-08-04 02:00:03 +0530224 private List<YangResolutionInfo> identityRefResolutionList;
Shankara-Huaweidf7b9ca2016-07-14 11:35:34 +0530225
226 /**
Vidyashree Rama07c26bb2016-07-28 17:33:15 +0530227 * Compiler annotation list.
228 */
229 private List<YangCompilerAnnotation> compilerAnnotationList;
230
231 /**
Vidyashree Rama36f2fab2016-07-15 14:06:56 +0530232 * extension list.
233 */
234 private List<YangExtension> extensionList;
235
236 /**
Bharat saraswalb1170bd2016-07-14 13:26:18 +0530237 * Augment resolution list.
238 */
239 private List<YangResolutionInfo> augmentResolutionList;
240
241 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530242 * Creates a sub module node.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530243 */
244 public YangSubModule() {
245 super(YangNodeType.SUB_MODULE_NODE);
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530246 derivedTypeResolutionList = new LinkedList<>();
Bharat saraswalb1170bd2016-07-14 13:26:18 +0530247 augmentResolutionList = new LinkedList<>();
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530248 usesResolutionList = new LinkedList<>();
Vidyashree Ramadeac28b2016-06-20 15:12:43 +0530249 ifFeatureResolutionList = new LinkedList<>();
Bharat saraswal2d90b0c2016-08-04 02:00:03 +0530250 leafRefResolutionList = new LinkedList<>();
Shankara-Huaweidf7b9ca2016-07-14 11:35:34 +0530251 baseResolutionList = new LinkedList<>();
Bharat saraswal2d90b0c2016-08-04 02:00:03 +0530252 identityRefResolutionList = new LinkedList<>();
Vidyashree Rama07c26bb2016-07-28 17:33:15 +0530253 compilerAnnotationList = new LinkedList<>();
Bharat saraswal2d90b0c2016-08-04 02:00:03 +0530254 importList = new LinkedList<>();
255 includeList = new LinkedList<>();
256 listOfLeaf = new LinkedList<>();
257 listOfLeafList = new LinkedList<>();
258 extensionList = new LinkedList<>();
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530259 }
260
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530261 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530262 * Returns the YANG name of the sub module.
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530263 *
264 * @return YANG name of the sub module
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530265 */
266 @Override
267 public String getName() {
268 return name;
269 }
270
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530271 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530272 * Sets YANG name of the sub module.
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530273 *
274 * @param subModuleName YANG name of the sub module
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530275 */
276 @Override
277 public void setName(String subModuleName) {
278 name = subModuleName;
279 }
280
281 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530282 * Returns the module info.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530283 *
284 * @return the belongs to info
285 */
286 public YangBelongsTo getBelongsTo() {
287 return belongsTo;
288 }
289
290 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530291 * Sets the module info.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530292 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530293 * @param belongsTo module info to set
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530294 */
295 public void setBelongsTo(YangBelongsTo belongsTo) {
296 this.belongsTo = belongsTo;
297 }
298
299 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530300 * Returns the contact.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530301 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530302 * @return the contact
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530303 */
304 public String getContact() {
305 return contact;
306 }
307
308 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530309 * Sets the contact.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530310 *
311 * @param contact the contact to set
312 */
313 public void setContact(String contact) {
314 this.contact = contact;
315 }
316
317 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530318 * Returns the description.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530319 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530320 * @return the description
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530321 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530322 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530323 public String getDescription() {
324 return description;
325 }
326
327 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530328 * Sets the description.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530329 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530330 * @param description set the description
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530331 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530332 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530333 public void setDescription(String description) {
334 this.description = description;
335 }
336
337 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530338 * Returns the list of imported modules.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530339 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530340 * @return the list of imported modules
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530341 */
Bharat saraswalcad0e652016-05-26 23:48:38 +0530342 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530343 public List<YangImport> getImportList() {
344 return importList;
345 }
346
347 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530348 * Adds the imported module information to the import list.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530349 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530350 * @param importedModule module being imported
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530351 */
Bharat saraswalcad0e652016-05-26 23:48:38 +0530352 @Override
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530353 public void addToImportList(YangImport importedModule) {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530354 getImportList().add(importedModule);
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530355 }
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530356
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530357 @Override
358 public void setImportList(List<YangImport> importList) {
359 this.importList = importList;
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530360 }
361
362 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530363 * Returns the list of included sub modules.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530364 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530365 * @return the included list of sub modules
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530366 */
Bharat saraswalcad0e652016-05-26 23:48:38 +0530367 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530368 public List<YangInclude> getIncludeList() {
369 return includeList;
370 }
371
372 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530373 * Returns the included sub module information to the include list.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530374 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530375 * @param includeModule submodule being included
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530376 */
Bharat saraswalcad0e652016-05-26 23:48:38 +0530377 @Override
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530378 public void addToIncludeList(YangInclude includeModule) {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530379 getIncludeList().add(includeModule);
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530380 }
381
382 @Override
383 public void setIncludeList(List<YangInclude> includeList) {
384 this.includeList = includeList;
385 }
386
387 @Override
388 public String getPrefix() {
389 return prefix;
390 }
391
392 @Override
393 public void setPrefix(String prefix) {
394 this.prefix = prefix;
395 }
396
397 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530398 public void resolveSelfFileLinking(ResolvableType type)
399 throws DataModelException {
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530400 // Get the list to be resolved.
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530401 List<YangResolutionInfo> resolutionList = getUnresolvedResolutionList(type);
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530402 // Resolve linking for a resolution list.
403 resolveLinkingForResolutionList(resolutionList, this);
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530404 }
405
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530406 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530407 public void resolveInterFileLinking(ResolvableType type)
408 throws DataModelException {
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530409 // Get the list to be resolved.
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530410 List<YangResolutionInfo> resolutionList = getUnresolvedResolutionList(type);
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530411 // Resolve linking for a resolution list.
412 linkInterFileReferences(resolutionList, this);
413 }
414
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530415 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530416 * Returns the list of leaves.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530417 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530418 * @return the list of leaves
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530419 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530420 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530421 public List<YangLeaf> getListOfLeaf() {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530422 return listOfLeaf;
423 }
424
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530425 @Override
426 public void setListOfLeaf(List<YangLeaf> leafsList) {
427 listOfLeaf = leafsList;
428 }
429
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530430 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530431 * Adds a leaf.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530432 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530433 * @param leaf the leaf to be added
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530434 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530435 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530436 public void addLeaf(YangLeaf leaf) {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530437 getListOfLeaf().add(leaf);
438 }
439
440 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530441 * Returns the list of leaf-list.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530442 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530443 * @return the list of leaf-list
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530444 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530445 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530446 public List<YangLeafList> getListOfLeafList() {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530447 return listOfLeafList;
448 }
449
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530450 @Override
451 public void setListOfLeafList(List<YangLeafList> listOfLeafList) {
452 this.listOfLeafList = listOfLeafList;
453 }
454
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530455 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530456 * Adds a leaf-list.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530457 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530458 * @param leafList the leaf-list to be added
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530459 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530460 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530461 public void addLeafList(YangLeafList leafList) {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530462 getListOfLeafList().add(leafList);
463 }
464
465 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530466 * Returns the sub-modules organization.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530467 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530468 * @return the organization
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530469 */
470 public String getOrganization() {
471 return organization;
472 }
473
474 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530475 * Sets the sub-modules organization.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530476 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530477 * @param org the organization to set
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530478 */
479 public void setOrganization(String org) {
480 organization = org;
481 }
482
483 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530484 * Returns the textual reference.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530485 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530486 * @return the reference
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530487 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530488 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530489 public String getReference() {
490 return reference;
491 }
492
493 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530494 * Sets the textual reference.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530495 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530496 * @param reference the reference to set
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530497 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530498 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530499 public void setReference(String reference) {
500 this.reference = reference;
501 }
502
503 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530504 * Returns the revision.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530505 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530506 * @return the revision
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530507 */
508 public YangRevision getRevision() {
509 return revision;
510 }
511
512 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530513 * Sets the revision.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530514 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530515 * @param revision the revision to set
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530516 */
517 public void setRevision(YangRevision revision) {
518 this.revision = revision;
519 }
520
521 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530522 * Returns the version.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530523 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530524 * @return the version
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530525 */
526 public byte getVersion() {
527 return version;
528 }
529
530 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530531 * Sets the version.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530532 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530533 * @param version the version to set
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530534 */
535 public void setVersion(byte version) {
536 this.version = version;
537 }
538
539 /**
540 * Returns the type of the parsed data.
541 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530542 * @return returns SUB_MODULE_DATA
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530543 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530544 @Override
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530545 public YangConstructType getYangConstructType() {
546 return YangConstructType.SUB_MODULE_DATA;
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530547 }
548
549 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530550 * Validates the data on entering the corresponding parse tree node.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530551 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530552 * @throws DataModelException a violation of data model rules
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530553 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530554 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530555 public void validateDataOnEntry()
556 throws DataModelException {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530557 // TODO auto-generated method stub, to be implemented by parser
558 }
559
560 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530561 * Validates the data on exiting the corresponding parse tree node.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530562 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530563 * @throws DataModelException a violation of data model rules
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530564 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530565 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530566 public void validateDataOnExit()
567 throws DataModelException {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530568 // TODO auto-generated method stub, to be implemented by parser
569 }
570
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530571 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530572 public void detectCollidingChild(String identifierName, YangConstructType dataType)
573 throws DataModelException {
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530574 // Asks helper to detect colliding child.
575 detectCollidingChildUtil(identifierName, dataType, this);
576 }
577
578 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530579 public void detectSelfCollision(String identifierName, YangConstructType dataType)
580 throws DataModelException {
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530581 // Not required as module doesn't have any parent.
582 }
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530583
584 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530585 public List<YangResolutionInfo> getUnresolvedResolutionList(ResolvableType type) {
586 if (type == ResolvableType.YANG_DERIVED_DATA_TYPE) {
587 return derivedTypeResolutionList;
Vidyashree Ramadeac28b2016-06-20 15:12:43 +0530588 } else if (type == ResolvableType.YANG_USES) {
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530589 return usesResolutionList;
Bharat saraswalb1170bd2016-07-14 13:26:18 +0530590 } else if (type == ResolvableType.YANG_AUGMENT) {
591 return augmentResolutionList;
janani be18b5342016-07-13 21:06:41 +0530592 } else if (type == ResolvableType.YANG_IF_FEATURE) {
Vidyashree Ramadeac28b2016-06-20 15:12:43 +0530593 return ifFeatureResolutionList;
Shankara-Huaweidf7b9ca2016-07-14 11:35:34 +0530594 } else if (type == ResolvableType.YANG_LEAFREF) {
Bharat saraswal2d90b0c2016-08-04 02:00:03 +0530595 return leafRefResolutionList;
Shankara-Huaweidf7b9ca2016-07-14 11:35:34 +0530596 } else if (type == ResolvableType.YANG_BASE) {
597 return baseResolutionList;
598 } else {
Bharat saraswal2d90b0c2016-08-04 02:00:03 +0530599 return identityRefResolutionList;
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530600 }
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530601 }
602
603 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530604 public void addToResolutionList(YangResolutionInfo resolutionInfo,
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530605 ResolvableType type) {
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530606 if (type == ResolvableType.YANG_DERIVED_DATA_TYPE) {
607 derivedTypeResolutionList.add(resolutionInfo);
608 } else if (type == ResolvableType.YANG_USES) {
609 usesResolutionList.add(resolutionInfo);
Vidyashree Ramadeac28b2016-06-20 15:12:43 +0530610 } else if (type == ResolvableType.YANG_IF_FEATURE) {
611 ifFeatureResolutionList.add(resolutionInfo);
Shankara-Huaweidf7b9ca2016-07-14 11:35:34 +0530612 } else if (type == ResolvableType.YANG_LEAFREF) {
Bharat saraswal2d90b0c2016-08-04 02:00:03 +0530613 leafRefResolutionList.add(resolutionInfo);
Shankara-Huaweidf7b9ca2016-07-14 11:35:34 +0530614 } else if (type == ResolvableType.YANG_BASE) {
615 baseResolutionList.add(resolutionInfo);
Vidyashree Rama36f2fab2016-07-15 14:06:56 +0530616 } else if (type == ResolvableType.YANG_AUGMENT) {
Bharat saraswalb1170bd2016-07-14 13:26:18 +0530617 augmentResolutionList.add(resolutionInfo);
Shankara-Huaweidf7b9ca2016-07-14 11:35:34 +0530618 } else if (type == ResolvableType.YANG_IDENTITYREF) {
Bharat saraswal2d90b0c2016-08-04 02:00:03 +0530619 identityRefResolutionList.add(resolutionInfo);
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530620 }
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530621 }
622
623 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530624 public void setResolutionList(List<YangResolutionInfo> resolutionList,
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530625 ResolvableType type) {
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530626 if (type == ResolvableType.YANG_DERIVED_DATA_TYPE) {
627 derivedTypeResolutionList = resolutionList;
628 } else if (type == ResolvableType.YANG_USES) {
629 usesResolutionList = resolutionList;
Vidyashree Ramadeac28b2016-06-20 15:12:43 +0530630 } else if (type == ResolvableType.YANG_IF_FEATURE) {
janani be18b5342016-07-13 21:06:41 +0530631 ifFeatureResolutionList.add((YangResolutionInfo) resolutionList);
632 } else if (type == ResolvableType.YANG_LEAFREF) {
Bharat saraswal2d90b0c2016-08-04 02:00:03 +0530633 leafRefResolutionList = resolutionList;
Shankara-Huaweidf7b9ca2016-07-14 11:35:34 +0530634 } else if (type == ResolvableType.YANG_BASE) {
635 baseResolutionList = resolutionList;
Vidyashree Rama36f2fab2016-07-15 14:06:56 +0530636 } else if (type == ResolvableType.YANG_AUGMENT) {
Bharat saraswalb1170bd2016-07-14 13:26:18 +0530637 augmentResolutionList = resolutionList;
Shankara-Huaweidf7b9ca2016-07-14 11:35:34 +0530638 } else if (type == ResolvableType.YANG_IDENTITYREF) {
Bharat saraswal2d90b0c2016-08-04 02:00:03 +0530639 identityRefResolutionList = resolutionList;
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530640 }
641
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530642 }
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530643
644 /**
645 * Links the sub-module with module.
646 *
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530647 * @param yangNodeSet YANG file information set
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530648 * @throws DataModelException a violation in data model rule
649 */
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530650 public void linkWithModule(Set<YangNode> yangNodeSet)
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530651 throws DataModelException {
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530652 getBelongsTo().linkWithModule(yangNodeSet);
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530653 }
654
655 @Override
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530656 public void addReferencesToIncludeList(Set<YangNode> yangNodeSet)
657 throws DataModelException {
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530658 Iterator<YangInclude> includeInfoIterator = getIncludeList().iterator();
659 // Run through the included list to add references.
660 while (includeInfoIterator.hasNext()) {
661 YangInclude yangInclude = includeInfoIterator.next();
662 YangSubModule subModule = null;
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530663 subModule = yangInclude.addReferenceToInclude(yangNodeSet);
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530664 // Check if the referred sub-modules parent is self
665 if (!(subModule.getBelongsTo().getModuleNode() == getBelongsTo().getModuleNode())) {
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530666 yangInclude.reportIncludeError();
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530667 }
668 }
669 }
670
671 @Override
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530672 public void addReferencesToImportList(Set<YangNode> yangNodeSet)
673 throws DataModelException {
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530674 Iterator<YangImport> importInfoIterator = getImportList().iterator();
675 // Run through the imported list to add references.
676 while (importInfoIterator.hasNext()) {
677 YangImport yangImport = importInfoIterator.next();
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530678 yangImport.addReferenceToImport(yangNodeSet);
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530679 }
680 }
Vidyashree Ramadeac28b2016-06-20 15:12:43 +0530681
682 @Override
683 public List<YangFeature> getFeatureList() {
684 return listOfFeature;
685 }
686
687 @Override
688 public void addFeatureList(YangFeature feature) {
689 if (getFeatureList() == null) {
690 setListOfFeature(new LinkedList<>());
691 }
692 getFeatureList().add(feature);
693 }
694
695 @Override
696 public void setListOfFeature(List<YangFeature> listOfFeature) {
697 this.listOfFeature = listOfFeature;
698 }
Vidyashree Rama36f2fab2016-07-15 14:06:56 +0530699
700 /**
Vidyashree Rama07c26bb2016-07-28 17:33:15 +0530701 * Adds compiler annotation in compiler annotation list.
702 *
703 * @param compilerAnnotation the compiler annotation to be added
704 */
705 public void addCompilerAnnotation(YangCompilerAnnotation compilerAnnotation) {
706 getCompilerAnnotationList().add(compilerAnnotation);
707 }
708
709 /**
710 * Returns the compiler annotation list.
711 *
712 * @return the compiler annotation list
713 */
714 public List<YangCompilerAnnotation> getCompilerAnnotationList() {
715 return compilerAnnotationList;
716 }
717
718 /**
719 * Sets the compiler annotation list.
720 *
721 * @param compilerAnnotationList the list of compiler annotation
722 */
723 public void setCompilerAnnotationList(List<YangCompilerAnnotation> compilerAnnotationList) {
724 this.compilerAnnotationList = compilerAnnotationList;
725 }
726
727
728 /**
Vidyashree Rama36f2fab2016-07-15 14:06:56 +0530729 * Adds extension in extension list.
730 *
731 * @param extension the extension to be added
732 */
733 public void addExtension(YangExtension extension) {
734 getExtensionList().add(extension);
735 }
736
737 /**
738 * Returns the extension list.
739 *
740 * @return the extension list
741 */
742 public List<YangExtension> getExtensionList() {
743 return extensionList;
744 }
745
746 /**
747 * Sets the extension list.
748 *
749 * @param extensionList the list of extension
750 */
751 public void setExtensionList(List<YangExtension> extensionList) {
752 this.extensionList = extensionList;
753 }
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530754}