blob: be7a0c08a062c16efac311fd4ecf007e40af5bb7 [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,
Vidyashree Ramadeac28b2016-06-20 15:12:43 +053085 RpcNotificationContainer, YangFeatureHolder {
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 /**
202 * uses resolution list.
203 */
204 private List<YangResolutionInfo> usesResolutionList;
Gaurav Agrawal56527662016-04-20 15:49:17 +0530205
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530206 /**
Vidyashree Ramadeac28b2016-06-20 15:12:43 +0530207 * if-feature resolution list.
208 */
209 private List<YangResolutionInfo> ifFeatureResolutionList;
210
211 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530212 * Creates a sub module node.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530213 */
214 public YangSubModule() {
215 super(YangNodeType.SUB_MODULE_NODE);
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530216 derivedTypeResolutionList = new LinkedList<>();
217 usesResolutionList = new LinkedList<>();
Vidyashree Ramadeac28b2016-06-20 15:12:43 +0530218 ifFeatureResolutionList = new LinkedList<>();
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530219 importList = new LinkedList<YangImport>();
220 includeList = new LinkedList<YangInclude>();
221 listOfLeaf = new LinkedList<YangLeaf>();
222 listOfLeafList = new LinkedList<YangLeafList>();
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530223 }
224
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530225 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530226 * Returns the YANG name of the sub module.
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530227 *
228 * @return YANG name of the sub module
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530229 */
230 @Override
231 public String getName() {
232 return name;
233 }
234
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530235 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530236 * Sets YANG name of the sub module.
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530237 *
238 * @param subModuleName YANG name of the sub module
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530239 */
240 @Override
241 public void setName(String subModuleName) {
242 name = subModuleName;
243 }
244
245 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530246 * Returns the module info.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530247 *
248 * @return the belongs to info
249 */
250 public YangBelongsTo getBelongsTo() {
251 return belongsTo;
252 }
253
254 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530255 * Sets the module info.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530256 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530257 * @param belongsTo module info to set
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530258 */
259 public void setBelongsTo(YangBelongsTo belongsTo) {
260 this.belongsTo = belongsTo;
261 }
262
263 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530264 * Returns the contact.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530265 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530266 * @return the contact
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530267 */
268 public String getContact() {
269 return contact;
270 }
271
272 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530273 * Sets the contact.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530274 *
275 * @param contact the contact to set
276 */
277 public void setContact(String contact) {
278 this.contact = contact;
279 }
280
281 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530282 * Returns the description.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530283 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530284 * @return the description
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530285 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530286 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530287 public String getDescription() {
288 return description;
289 }
290
291 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530292 * Sets the description.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530293 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530294 * @param description set the description
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530295 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530296 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530297 public void setDescription(String description) {
298 this.description = description;
299 }
300
301 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530302 * Returns the list of imported modules.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530303 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530304 * @return the list of imported modules
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530305 */
Bharat saraswalcad0e652016-05-26 23:48:38 +0530306 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530307 public List<YangImport> getImportList() {
308 return importList;
309 }
310
311 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530312 * Adds the imported module information to the import list.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530313 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530314 * @param importedModule module being imported
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530315 */
Bharat saraswalcad0e652016-05-26 23:48:38 +0530316 @Override
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530317 public void addToImportList(YangImport importedModule) {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530318 getImportList().add(importedModule);
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530319 }
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530320
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530321 @Override
322 public void setImportList(List<YangImport> importList) {
323 this.importList = importList;
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530324 }
325
326 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530327 * Returns the list of included sub modules.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530328 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530329 * @return the included list of sub modules
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530330 */
Bharat saraswalcad0e652016-05-26 23:48:38 +0530331 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530332 public List<YangInclude> getIncludeList() {
333 return includeList;
334 }
335
336 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530337 * Returns the included sub module information to the include list.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530338 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530339 * @param includeModule submodule being included
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530340 */
Bharat saraswalcad0e652016-05-26 23:48:38 +0530341 @Override
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530342 public void addToIncludeList(YangInclude includeModule) {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530343 getIncludeList().add(includeModule);
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530344 }
345
346 @Override
347 public void setIncludeList(List<YangInclude> includeList) {
348 this.includeList = includeList;
349 }
350
351 @Override
352 public String getPrefix() {
353 return prefix;
354 }
355
356 @Override
357 public void setPrefix(String prefix) {
358 this.prefix = prefix;
359 }
360
361 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530362 public void resolveSelfFileLinking(ResolvableType type)
363 throws DataModelException {
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530364 // Get the list to be resolved.
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530365 List<YangResolutionInfo> resolutionList = getUnresolvedResolutionList(type);
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530366 // Resolve linking for a resolution list.
367 resolveLinkingForResolutionList(resolutionList, this);
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530368 }
369
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530370 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530371 public void resolveInterFileLinking(ResolvableType type)
372 throws DataModelException {
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530373 // Get the list to be resolved.
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530374 List<YangResolutionInfo> resolutionList = getUnresolvedResolutionList(type);
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530375 // Resolve linking for a resolution list.
376 linkInterFileReferences(resolutionList, this);
377 }
378
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530379 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530380 * Returns the list of leaves.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530381 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530382 * @return the list of leaves
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530383 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530384 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530385 public List<YangLeaf> getListOfLeaf() {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530386 return listOfLeaf;
387 }
388
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530389 @Override
390 public void setListOfLeaf(List<YangLeaf> leafsList) {
391 listOfLeaf = leafsList;
392 }
393
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530394 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530395 * Adds a leaf.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530396 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530397 * @param leaf the leaf to be added
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530398 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530399 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530400 public void addLeaf(YangLeaf leaf) {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530401 getListOfLeaf().add(leaf);
402 }
403
404 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530405 * Returns the list of leaf-list.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530406 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530407 * @return the list of leaf-list
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530408 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530409 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530410 public List<YangLeafList> getListOfLeafList() {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530411 return listOfLeafList;
412 }
413
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530414 @Override
415 public void setListOfLeafList(List<YangLeafList> listOfLeafList) {
416 this.listOfLeafList = listOfLeafList;
417 }
418
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530419 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530420 * Adds a leaf-list.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530421 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530422 * @param leafList the leaf-list to be added
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530423 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530424 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530425 public void addLeafList(YangLeafList leafList) {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530426 getListOfLeafList().add(leafList);
427 }
428
429 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530430 * Returns the sub-modules organization.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530431 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530432 * @return the organization
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530433 */
434 public String getOrganization() {
435 return organization;
436 }
437
438 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530439 * Sets the sub-modules organization.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530440 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530441 * @param org the organization to set
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530442 */
443 public void setOrganization(String org) {
444 organization = org;
445 }
446
447 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530448 * Returns the textual reference.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530449 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530450 * @return the reference
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530451 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530452 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530453 public String getReference() {
454 return reference;
455 }
456
457 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530458 * Sets the textual reference.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530459 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530460 * @param reference the reference to set
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530461 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530462 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530463 public void setReference(String reference) {
464 this.reference = reference;
465 }
466
467 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530468 * Returns the revision.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530469 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530470 * @return the revision
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530471 */
472 public YangRevision getRevision() {
473 return revision;
474 }
475
476 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530477 * Sets the revision.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530478 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530479 * @param revision the revision to set
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530480 */
481 public void setRevision(YangRevision revision) {
482 this.revision = revision;
483 }
484
485 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530486 * Returns the version.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530487 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530488 * @return the version
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530489 */
490 public byte getVersion() {
491 return version;
492 }
493
494 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530495 * Sets the version.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530496 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530497 * @param version the version to set
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530498 */
499 public void setVersion(byte version) {
500 this.version = version;
501 }
502
503 /**
504 * Returns the type of the parsed data.
505 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530506 * @return returns SUB_MODULE_DATA
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530507 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530508 @Override
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530509 public YangConstructType getYangConstructType() {
510 return YangConstructType.SUB_MODULE_DATA;
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530511 }
512
513 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530514 * Validates the data on entering the corresponding parse tree node.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530515 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530516 * @throws DataModelException a violation of data model rules
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530517 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530518 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530519 public void validateDataOnEntry()
520 throws DataModelException {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530521 // TODO auto-generated method stub, to be implemented by parser
522 }
523
524 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530525 * Validates the data on exiting the corresponding parse tree node.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530526 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530527 * @throws DataModelException a violation of data model rules
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530528 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530529 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530530 public void validateDataOnExit()
531 throws DataModelException {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530532 // TODO auto-generated method stub, to be implemented by parser
533 }
534
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530535 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530536 public void detectCollidingChild(String identifierName, YangConstructType dataType)
537 throws DataModelException {
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530538 // Asks helper to detect colliding child.
539 detectCollidingChildUtil(identifierName, dataType, this);
540 }
541
542 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530543 public void detectSelfCollision(String identifierName, YangConstructType dataType)
544 throws DataModelException {
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530545 // Not required as module doesn't have any parent.
546 }
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530547
548 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530549 public List<YangResolutionInfo> getUnresolvedResolutionList(ResolvableType type) {
550 if (type == ResolvableType.YANG_DERIVED_DATA_TYPE) {
551 return derivedTypeResolutionList;
Vidyashree Ramadeac28b2016-06-20 15:12:43 +0530552 } else if (type == ResolvableType.YANG_USES) {
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530553 return usesResolutionList;
Vidyashree Ramadeac28b2016-06-20 15:12:43 +0530554 } else {
555 return ifFeatureResolutionList;
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530556 }
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530557 }
558
559 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530560 public void addToResolutionList(YangResolutionInfo resolutionInfo,
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530561 ResolvableType type) {
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530562 if (type == ResolvableType.YANG_DERIVED_DATA_TYPE) {
563 derivedTypeResolutionList.add(resolutionInfo);
564 } else if (type == ResolvableType.YANG_USES) {
565 usesResolutionList.add(resolutionInfo);
Vidyashree Ramadeac28b2016-06-20 15:12:43 +0530566 } else if (type == ResolvableType.YANG_IF_FEATURE) {
567 ifFeatureResolutionList.add(resolutionInfo);
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530568 }
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530569 }
570
571 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530572 public void setResolutionList(List<YangResolutionInfo> resolutionList,
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530573 ResolvableType type) {
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530574 if (type == ResolvableType.YANG_DERIVED_DATA_TYPE) {
575 derivedTypeResolutionList = resolutionList;
576 } else if (type == ResolvableType.YANG_USES) {
577 usesResolutionList = resolutionList;
Vidyashree Ramadeac28b2016-06-20 15:12:43 +0530578 } else if (type == ResolvableType.YANG_IF_FEATURE) {
579 ifFeatureResolutionList = resolutionList;
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530580 }
581
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530582 }
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530583
584 /**
585 * Links the sub-module with module.
586 *
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530587 * @param yangNodeSet YANG file information set
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530588 * @throws DataModelException a violation in data model rule
589 */
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530590 public void linkWithModule(Set<YangNode> yangNodeSet)
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530591 throws DataModelException {
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530592 getBelongsTo().linkWithModule(yangNodeSet);
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530593 }
594
595 @Override
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530596 public void addReferencesToIncludeList(Set<YangNode> yangNodeSet)
597 throws DataModelException {
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530598 Iterator<YangInclude> includeInfoIterator = getIncludeList().iterator();
599 // Run through the included list to add references.
600 while (includeInfoIterator.hasNext()) {
601 YangInclude yangInclude = includeInfoIterator.next();
602 YangSubModule subModule = null;
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530603 subModule = yangInclude.addReferenceToInclude(yangNodeSet);
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530604 // Check if the referred sub-modules parent is self
605 if (!(subModule.getBelongsTo().getModuleNode() == getBelongsTo().getModuleNode())) {
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530606 yangInclude.reportIncludeError();
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530607 }
608 }
609 }
610
611 @Override
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530612 public void addReferencesToImportList(Set<YangNode> yangNodeSet)
613 throws DataModelException {
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530614 Iterator<YangImport> importInfoIterator = getImportList().iterator();
615 // Run through the imported list to add references.
616 while (importInfoIterator.hasNext()) {
617 YangImport yangImport = importInfoIterator.next();
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530618 yangImport.addReferenceToImport(yangNodeSet);
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530619 }
620 }
Vidyashree Ramadeac28b2016-06-20 15:12:43 +0530621
622 @Override
623 public List<YangFeature> getFeatureList() {
624 return listOfFeature;
625 }
626
627 @Override
628 public void addFeatureList(YangFeature feature) {
629 if (getFeatureList() == null) {
630 setListOfFeature(new LinkedList<>());
631 }
632 getFeatureList().add(feature);
633 }
634
635 @Override
636 public void setListOfFeature(List<YangFeature> listOfFeature) {
637 this.listOfFeature = listOfFeature;
638 }
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530639}