blob: b7f92232d0fb90426a6f0013aa959039386a39d6 [file] [log] [blame]
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +05301/*
Brian O'Connor0f7908b2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Vinod Kumar S6a6ce4c2016-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 Agrawalab7c4bd2016-05-17 18:06:38 +053018import java.util.Iterator;
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +053019import java.util.LinkedList;
20import java.util.List;
Gaurav Agrawalab7c4bd2016-05-17 18:06:38 +053021import java.util.Set;
Vinod Kumar S9f26ae52016-03-23 15:30:27 +053022import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
23import org.onosproject.yangutils.parser.Parsable;
24import org.onosproject.yangutils.utils.YangConstructType;
25
26import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil;
Gaurav Agrawalab7c4bd2016-05-17 18:06:38 +053027import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.linkInterFileReferences;
Gaurav Agrawal1fbfae12016-03-29 02:17:23 +053028import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.resolveLinkingForResolutionList;
Vinod Kumar S9f26ae52016-03-23 15:30:27 +053029
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +053030/*
31 * Reference RFC 6020.
32 *
33 * While the primary unit in YANG is a module, a YANG module can itself
34 * be constructed out of several submodules. Submodules allow a module
35 * designer to split a complex model into several pieces where all the
36 * submodules contribute to a single namespace, which is defined by the
37 * module that includes the submodules.
38 *
39 * The "submodule" statement defines the submodule's name, and groups
40 * all statements that belong to the submodule together. The
41 * "submodule" statement's argument is the name of the submodule,
42 * followed by a block of sub-statements that hold detailed submodule
43 * information.
44 *
45 * The submodule's sub-statements
46 *
47 * +--------------+---------+-------------+------------------+
48 * | substatement | section | cardinality |data model mapping|
49 * +--------------+---------+-------------+------------------+
50 * | anyxml | 7.10 | 0..n | - not supported |
51 * | augment | 7.15 | 0..n | - child nodes |
52 * | belongs-to | 7.2.2 | 1 | - YangBelongsTo |
53 * | choice | 7.9 | 0..n | - child nodes |
54 * | contact | 7.1.8 | 0..1 | - string |
55 * | container | 7.5 | 0..n | - child nodes |
56 * | description | 7.19.3 | 0..1 | - string |
57 * | deviation | 7.18.3 | 0..n | - TODO |
58 * | extension | 7.17 | 0..n | - TODO |
59 * | feature | 7.18.1 | 0..n | - TODO |
60 * | grouping | 7.11 | 0..n | - child nodes |
61 * | identity | 7.16 | 0..n | - TODO |
62 * | import | 7.1.5 | 0..n | - YangImport |
63 * | include | 7.1.6 | 0..n | - YangInclude |
64 * | leaf | 7.6 | 0..n | - YangLeaf |
65 * | leaf-list | 7.7 | 0..n | - YangLeafList |
66 * | list | 7.8 | 0..n | - child nodes |
67 * | notification | 7.14 | 0..n | - TODO |
68 * | organization | 7.1.7 | 0..1 | - string |
69 * | reference | 7.19.4 | 0..1 | - string |
70 * | revision | 7.1.9 | 0..n | - string |
71 * | rpc | 7.13 | 0..n | - TODO |
72 * | typedef | 7.3 | 0..n | - child nodes |
73 * | uses | 7.12 | 0..n | - child nodes |
74 * | YANG-version | 7.1.2 | 0..1 | - int |
75 * +--------------+---------+-------------+------------------+
76 */
Gaurav Agrawal02a60de2016-04-20 15:49:17 +053077
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +053078/**
Bharat saraswal63f26fb2016-04-05 15:13:44 +053079 * Represents data model node to maintain information defined in YANG sub-module.
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +053080 */
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +053081public class YangSubModule
82 extends YangNode
Vinod Kumar S79a374b2016-04-30 21:09:15 +053083 implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector, YangReferenceResolver,
84 RpcNotificationContainer {
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +053085
86 /**
87 * Name of sub module.
88 */
89 private String name;
90
91 /**
92 * Module to which it belongs to.
93 */
94 private YangBelongsTo belongsTo;
95
96 /**
97 * Reference RFC 6020.
Gaurav Agrawalab7c4bd2016-05-17 18:06:38 +053098 * <p>
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +053099 * The "contact" statement provides contact information for the module. The
100 * argument is a string that is used to specify contact information for the
101 * person or persons to whom technical queries concerning this module should
102 * be sent, such as their name, postal address, telephone number, and
103 * electronic mail address.
104 */
105 private String contact;
106
107 /**
108 * Description.
109 */
110 private String description;
111
112 /**
113 * List of YANG modules imported.
114 */
115 private List<YangImport> importList;
116
117 /**
118 * List of YANG sub-modules included.
119 */
120 private List<YangInclude> includeList;
121
122 /**
123 * List of leaves at root level in the sub-module.
124 */
Vinod Kumar Sc26bf192016-02-23 22:36:57 +0530125 private List<YangLeaf> listOfLeaf;
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530126
127 /**
128 * List of leaf-lists at root level in the sub-module.
129 */
Vinod Kumar Sc26bf192016-02-23 22:36:57 +0530130 private List<YangLeafList> listOfLeafList;
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530131
132 /**
Gaurav Agrawal1fbfae12016-03-29 02:17:23 +0530133 * Organization owner of the sub-module.
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530134 */
135 private String organization;
136
137 /**
Gaurav Agrawal1fbfae12016-03-29 02:17:23 +0530138 * Reference of the sub-module.
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530139 */
140 private String reference;
141
142 /**
Gaurav Agrawal1fbfae12016-03-29 02:17:23 +0530143 * Revision info of the sub-module.
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530144 */
145 private YangRevision revision;
146
147 /**
148 * YANG version.
149 */
150 private byte version;
151
152 /**
Gaurav Agrawal1fbfae12016-03-29 02:17:23 +0530153 * Prefix of parent module.
154 */
155 private String prefix;
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +0530156
Gaurav Agrawal1fbfae12016-03-29 02:17:23 +0530157 /*-
158 * Reference RFC 6020.
159 *
160 * Nested typedefs and groupings.
161 * Typedefs and groupings may appear nested under many YANG statements,
162 * allowing these to be lexically scoped by the hierarchy under which
163 * they appear. This allows types and groupings to be defined near
164 * where they are used, rather than placing them at the top level of the
165 * hierarchy. The close proximity increases readability.
166 *
167 * Scoping also allows types to be defined without concern for naming
168 * conflicts between types in different submodules. Type names can be
169 * specified without adding leading strings designed to prevent name
170 * collisions within large modules.
171 *
172 * Finally, scoping allows the module author to keep types and groupings
173 * private to their module or submodule, preventing their reuse. Since
174 * only top-level types and groupings (i.e., those appearing as
175 * sub-statements to a module or submodule statement) can be used outside
176 * the module or submodule, the developer has more control over what
177 * pieces of their module are presented to the outside world, supporting
178 * the need to hide internal information and maintaining a boundary
179 * between what is shared with the outside world and what is kept
180 * private.
181 *
182 * Scoped definitions MUST NOT shadow definitions at a higher scope. A
183 * type or grouping cannot be defined if a higher level in the schema
184 * hierarchy has a definition with a matching identifier.
185 *
186 * A reference to an unprefixed type or grouping, or one which uses the
187 * prefix of the current module, is resolved by locating the closest
188 * matching "typedef" or "grouping" statement among the immediate
189 * sub-statements of each ancestor statement.
190 */
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +0530191 private List<YangResolutionInfo> derivedTypeResolutionList;
192
193 /**
194 * uses resolution list.
195 */
196 private List<YangResolutionInfo> usesResolutionList;
Gaurav Agrawal02a60de2016-04-20 15:49:17 +0530197
Gaurav Agrawal1fbfae12016-03-29 02:17:23 +0530198 /**
Bharat saraswal63f26fb2016-04-05 15:13:44 +0530199 * Creates a sub module node.
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530200 */
201 public YangSubModule() {
202 super(YangNodeType.SUB_MODULE_NODE);
Gaurav Agrawal58b348e2016-06-07 14:00:26 +0530203 derivedTypeResolutionList = new LinkedList<>();
204 usesResolutionList = new LinkedList<>();
Gaurav Agrawal1fbfae12016-03-29 02:17:23 +0530205 importList = new LinkedList<YangImport>();
206 includeList = new LinkedList<YangInclude>();
207 listOfLeaf = new LinkedList<YangLeaf>();
208 listOfLeafList = new LinkedList<YangLeafList>();
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530209 }
210
Vinod Kumar Sc26bf192016-02-23 22:36:57 +0530211 /**
Bharat saraswal63f26fb2016-04-05 15:13:44 +0530212 * Returns the YANG name of the sub module.
Vinod Kumar Sc26bf192016-02-23 22:36:57 +0530213 *
214 * @return YANG name of the sub module
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530215 */
216 @Override
217 public String getName() {
218 return name;
219 }
220
Vinod Kumar Sc26bf192016-02-23 22:36:57 +0530221 /**
Bharat saraswal63f26fb2016-04-05 15:13:44 +0530222 * Sets YANG name of the sub module.
Vinod Kumar Sc26bf192016-02-23 22:36:57 +0530223 *
224 * @param subModuleName YANG name of the sub module
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530225 */
226 @Override
227 public void setName(String subModuleName) {
228 name = subModuleName;
229 }
230
231 /**
Bharat saraswal63f26fb2016-04-05 15:13:44 +0530232 * Returns the module info.
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530233 *
234 * @return the belongs to info
235 */
236 public YangBelongsTo getBelongsTo() {
237 return belongsTo;
238 }
239
240 /**
Bharat saraswal63f26fb2016-04-05 15:13:44 +0530241 * Sets the module info.
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530242 *
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530243 * @param belongsTo module info to set
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530244 */
245 public void setBelongsTo(YangBelongsTo belongsTo) {
246 this.belongsTo = belongsTo;
247 }
248
249 /**
Bharat saraswal63f26fb2016-04-05 15:13:44 +0530250 * Returns the contact.
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530251 *
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530252 * @return the contact
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530253 */
254 public String getContact() {
255 return contact;
256 }
257
258 /**
Bharat saraswal63f26fb2016-04-05 15:13:44 +0530259 * Sets the contact.
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530260 *
261 * @param contact the contact to set
262 */
263 public void setContact(String contact) {
264 this.contact = contact;
265 }
266
267 /**
Bharat saraswal63f26fb2016-04-05 15:13:44 +0530268 * Returns the description.
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530269 *
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530270 * @return the description
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530271 */
Bharat saraswal97459962016-02-20 21:57:16 +0530272 @Override
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530273 public String getDescription() {
274 return description;
275 }
276
277 /**
Bharat saraswal63f26fb2016-04-05 15:13:44 +0530278 * Sets the description.
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530279 *
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530280 * @param description set the description
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530281 */
Bharat saraswal97459962016-02-20 21:57:16 +0530282 @Override
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530283 public void setDescription(String description) {
284 this.description = description;
285 }
286
287 /**
Bharat saraswal63f26fb2016-04-05 15:13:44 +0530288 * Returns the list of imported modules.
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530289 *
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530290 * @return the list of imported modules
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530291 */
Bharat saraswal5cd9e9c2016-05-26 23:48:38 +0530292 @Override
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530293 public List<YangImport> getImportList() {
294 return importList;
295 }
296
297 /**
Bharat saraswal63f26fb2016-04-05 15:13:44 +0530298 * Adds the imported module information to the import list.
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530299 *
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530300 * @param importedModule module being imported
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530301 */
Bharat saraswal5cd9e9c2016-05-26 23:48:38 +0530302 @Override
Gaurav Agrawal1fbfae12016-03-29 02:17:23 +0530303 public void addToImportList(YangImport importedModule) {
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530304 getImportList().add(importedModule);
Gaurav Agrawal1fbfae12016-03-29 02:17:23 +0530305 }
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530306
Gaurav Agrawal1fbfae12016-03-29 02:17:23 +0530307 @Override
308 public void setImportList(List<YangImport> importList) {
309 this.importList = importList;
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530310 }
311
312 /**
Bharat saraswal63f26fb2016-04-05 15:13:44 +0530313 * Returns the list of included sub modules.
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530314 *
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530315 * @return the included list of sub modules
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530316 */
Bharat saraswal5cd9e9c2016-05-26 23:48:38 +0530317 @Override
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530318 public List<YangInclude> getIncludeList() {
319 return includeList;
320 }
321
322 /**
Bharat saraswal63f26fb2016-04-05 15:13:44 +0530323 * Returns the included sub module information to the include list.
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530324 *
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530325 * @param includeModule submodule being included
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530326 */
Bharat saraswal5cd9e9c2016-05-26 23:48:38 +0530327 @Override
Gaurav Agrawal1fbfae12016-03-29 02:17:23 +0530328 public void addToIncludeList(YangInclude includeModule) {
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530329 getIncludeList().add(includeModule);
Gaurav Agrawal1fbfae12016-03-29 02:17:23 +0530330 }
331
332 @Override
333 public void setIncludeList(List<YangInclude> includeList) {
334 this.includeList = includeList;
335 }
336
337 @Override
338 public String getPrefix() {
339 return prefix;
340 }
341
342 @Override
343 public void setPrefix(String prefix) {
344 this.prefix = prefix;
345 }
346
347 @Override
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +0530348 public void resolveSelfFileLinking(ResolvableType type)
349 throws DataModelException {
Gaurav Agrawal1fbfae12016-03-29 02:17:23 +0530350 // Get the list to be resolved.
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +0530351 List<YangResolutionInfo> resolutionList = getUnresolvedResolutionList(type);
Gaurav Agrawal1fbfae12016-03-29 02:17:23 +0530352 // Resolve linking for a resolution list.
353 resolveLinkingForResolutionList(resolutionList, this);
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530354 }
355
Gaurav Agrawalab7c4bd2016-05-17 18:06:38 +0530356 @Override
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +0530357 public void resolveInterFileLinking(ResolvableType type)
358 throws DataModelException {
Gaurav Agrawalab7c4bd2016-05-17 18:06:38 +0530359 // Get the list to be resolved.
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +0530360 List<YangResolutionInfo> resolutionList = getUnresolvedResolutionList(type);
Gaurav Agrawalab7c4bd2016-05-17 18:06:38 +0530361 // Resolve linking for a resolution list.
362 linkInterFileReferences(resolutionList, this);
363 }
364
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530365 /**
Bharat saraswal63f26fb2016-04-05 15:13:44 +0530366 * Returns the list of leaves.
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530367 *
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530368 * @return the list of leaves
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530369 */
Bharat saraswal97459962016-02-20 21:57:16 +0530370 @Override
Vinod Kumar Sc26bf192016-02-23 22:36:57 +0530371 public List<YangLeaf> getListOfLeaf() {
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530372 return listOfLeaf;
373 }
374
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +0530375 @Override
376 public void setListOfLeaf(List<YangLeaf> leafsList) {
377 listOfLeaf = leafsList;
378 }
379
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530380 /**
Bharat saraswal63f26fb2016-04-05 15:13:44 +0530381 * Adds a leaf.
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530382 *
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530383 * @param leaf the leaf to be added
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530384 */
Bharat saraswal97459962016-02-20 21:57:16 +0530385 @Override
Vinod Kumar Sc26bf192016-02-23 22:36:57 +0530386 public void addLeaf(YangLeaf leaf) {
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530387 getListOfLeaf().add(leaf);
388 }
389
390 /**
Bharat saraswal63f26fb2016-04-05 15:13:44 +0530391 * Returns the list of leaf-list.
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530392 *
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530393 * @return the list of leaf-list
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530394 */
Bharat saraswal97459962016-02-20 21:57:16 +0530395 @Override
Vinod Kumar Sc26bf192016-02-23 22:36:57 +0530396 public List<YangLeafList> getListOfLeafList() {
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530397 return listOfLeafList;
398 }
399
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +0530400 @Override
401 public void setListOfLeafList(List<YangLeafList> listOfLeafList) {
402 this.listOfLeafList = listOfLeafList;
403 }
404
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530405 /**
Bharat saraswal63f26fb2016-04-05 15:13:44 +0530406 * Adds a leaf-list.
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530407 *
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530408 * @param leafList the leaf-list to be added
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530409 */
Bharat saraswal97459962016-02-20 21:57:16 +0530410 @Override
Vinod Kumar Sc26bf192016-02-23 22:36:57 +0530411 public void addLeafList(YangLeafList leafList) {
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530412 getListOfLeafList().add(leafList);
413 }
414
415 /**
Bharat saraswal63f26fb2016-04-05 15:13:44 +0530416 * Returns the sub-modules organization.
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530417 *
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530418 * @return the organization
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530419 */
420 public String getOrganization() {
421 return organization;
422 }
423
424 /**
Bharat saraswal63f26fb2016-04-05 15:13:44 +0530425 * Sets the sub-modules organization.
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530426 *
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530427 * @param org the organization to set
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530428 */
429 public void setOrganization(String org) {
430 organization = org;
431 }
432
433 /**
Bharat saraswal63f26fb2016-04-05 15:13:44 +0530434 * Returns the textual reference.
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530435 *
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530436 * @return the reference
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530437 */
Bharat saraswal97459962016-02-20 21:57:16 +0530438 @Override
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530439 public String getReference() {
440 return reference;
441 }
442
443 /**
Bharat saraswal63f26fb2016-04-05 15:13:44 +0530444 * Sets the textual reference.
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530445 *
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530446 * @param reference the reference to set
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530447 */
Bharat saraswal97459962016-02-20 21:57:16 +0530448 @Override
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530449 public void setReference(String reference) {
450 this.reference = reference;
451 }
452
453 /**
Bharat saraswal63f26fb2016-04-05 15:13:44 +0530454 * Returns the revision.
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530455 *
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530456 * @return the revision
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530457 */
458 public YangRevision getRevision() {
459 return revision;
460 }
461
462 /**
Bharat saraswal63f26fb2016-04-05 15:13:44 +0530463 * Sets the revision.
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530464 *
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530465 * @param revision the revision to set
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530466 */
467 public void setRevision(YangRevision revision) {
468 this.revision = revision;
469 }
470
471 /**
Bharat saraswal63f26fb2016-04-05 15:13:44 +0530472 * Returns the version.
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530473 *
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530474 * @return the version
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530475 */
476 public byte getVersion() {
477 return version;
478 }
479
480 /**
Bharat saraswal63f26fb2016-04-05 15:13:44 +0530481 * Sets the version.
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530482 *
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530483 * @param version the version to set
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530484 */
485 public void setVersion(byte version) {
486 this.version = version;
487 }
488
489 /**
490 * Returns the type of the parsed data.
491 *
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530492 * @return returns SUB_MODULE_DATA
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530493 */
Bharat saraswal97459962016-02-20 21:57:16 +0530494 @Override
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530495 public YangConstructType getYangConstructType() {
496 return YangConstructType.SUB_MODULE_DATA;
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530497 }
498
499 /**
Bharat saraswal63f26fb2016-04-05 15:13:44 +0530500 * Validates the data on entering the corresponding parse tree node.
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530501 *
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530502 * @throws DataModelException a violation of data model rules
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530503 */
Bharat saraswal97459962016-02-20 21:57:16 +0530504 @Override
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +0530505 public void validateDataOnEntry()
506 throws DataModelException {
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530507 // TODO auto-generated method stub, to be implemented by parser
508 }
509
510 /**
Bharat saraswal63f26fb2016-04-05 15:13:44 +0530511 * Validates the data on exiting the corresponding parse tree node.
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530512 *
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530513 * @throws DataModelException a violation of data model rules
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530514 */
Bharat saraswal97459962016-02-20 21:57:16 +0530515 @Override
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +0530516 public void validateDataOnExit()
517 throws DataModelException {
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530518 // TODO auto-generated method stub, to be implemented by parser
519 }
520
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530521 @Override
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +0530522 public void detectCollidingChild(String identifierName, YangConstructType dataType)
523 throws DataModelException {
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530524 // Asks helper to detect colliding child.
525 detectCollidingChildUtil(identifierName, dataType, this);
526 }
527
528 @Override
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +0530529 public void detectSelfCollision(String identifierName, YangConstructType dataType)
530 throws DataModelException {
Gaurav Agrawaldb828bd2016-02-27 03:57:50 +0530531 // Not required as module doesn't have any parent.
532 }
Gaurav Agrawal1fbfae12016-03-29 02:17:23 +0530533
534 @Override
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +0530535 public List<YangResolutionInfo> getUnresolvedResolutionList(ResolvableType type) {
536 if (type == ResolvableType.YANG_DERIVED_DATA_TYPE) {
537 return derivedTypeResolutionList;
538 } else {
539 return usesResolutionList;
540 }
Gaurav Agrawal1fbfae12016-03-29 02:17:23 +0530541 }
542
543 @Override
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +0530544 public void addToResolutionList(YangResolutionInfo resolutionInfo,
Gaurav Agrawal58b348e2016-06-07 14:00:26 +0530545 ResolvableType type) {
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +0530546 if (type == ResolvableType.YANG_DERIVED_DATA_TYPE) {
547 derivedTypeResolutionList.add(resolutionInfo);
548 } else if (type == ResolvableType.YANG_USES) {
549 usesResolutionList.add(resolutionInfo);
550 }
Gaurav Agrawal1fbfae12016-03-29 02:17:23 +0530551 }
552
553 @Override
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +0530554 public void setResolutionList(List<YangResolutionInfo> resolutionList,
Gaurav Agrawal58b348e2016-06-07 14:00:26 +0530555 ResolvableType type) {
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +0530556 if (type == ResolvableType.YANG_DERIVED_DATA_TYPE) {
557 derivedTypeResolutionList = resolutionList;
558 } else if (type == ResolvableType.YANG_USES) {
559 usesResolutionList = resolutionList;
560 }
561
Gaurav Agrawal1fbfae12016-03-29 02:17:23 +0530562 }
Gaurav Agrawalab7c4bd2016-05-17 18:06:38 +0530563
564 /**
565 * Links the sub-module with module.
566 *
Gaurav Agrawal58b348e2016-06-07 14:00:26 +0530567 * @param yangNodeSet YANG file information set
Gaurav Agrawalab7c4bd2016-05-17 18:06:38 +0530568 * @throws DataModelException a violation in data model rule
569 */
Gaurav Agrawal58b348e2016-06-07 14:00:26 +0530570 public void linkWithModule(Set<YangNode> yangNodeSet)
Gaurav Agrawalab7c4bd2016-05-17 18:06:38 +0530571 throws DataModelException {
Gaurav Agrawal58b348e2016-06-07 14:00:26 +0530572 getBelongsTo().linkWithModule(yangNodeSet);
Gaurav Agrawalab7c4bd2016-05-17 18:06:38 +0530573 }
574
575 @Override
Gaurav Agrawal58b348e2016-06-07 14:00:26 +0530576 public void addReferencesToIncludeList(Set<YangNode> yangNodeSet)
577 throws DataModelException {
Gaurav Agrawalab7c4bd2016-05-17 18:06:38 +0530578 Iterator<YangInclude> includeInfoIterator = getIncludeList().iterator();
579 // Run through the included list to add references.
580 while (includeInfoIterator.hasNext()) {
581 YangInclude yangInclude = includeInfoIterator.next();
582 YangSubModule subModule = null;
Gaurav Agrawal58b348e2016-06-07 14:00:26 +0530583 subModule = yangInclude.addReferenceToInclude(yangNodeSet);
Gaurav Agrawalab7c4bd2016-05-17 18:06:38 +0530584 // Check if the referred sub-modules parent is self
585 if (!(subModule.getBelongsTo().getModuleNode() == getBelongsTo().getModuleNode())) {
Gaurav Agrawal58b348e2016-06-07 14:00:26 +0530586 yangInclude.reportIncludeError();
Gaurav Agrawalab7c4bd2016-05-17 18:06:38 +0530587 }
588 }
589 }
590
591 @Override
Gaurav Agrawal58b348e2016-06-07 14:00:26 +0530592 public void addReferencesToImportList(Set<YangNode> yangNodeSet)
593 throws DataModelException {
Gaurav Agrawalab7c4bd2016-05-17 18:06:38 +0530594 Iterator<YangImport> importInfoIterator = getImportList().iterator();
595 // Run through the imported list to add references.
596 while (importInfoIterator.hasNext()) {
597 YangImport yangImport = importInfoIterator.next();
Gaurav Agrawal58b348e2016-06-07 14:00:26 +0530598 yangImport.addReferenceToImport(yangNodeSet);
Gaurav Agrawalab7c4bd2016-05-17 18:06:38 +0530599 }
600 }
Vinod Kumar S6a6ce4c2016-02-11 20:13:28 +0530601}