blob: 89c49dd4fbc6223dbf4869e8e4f98a1ee6fabcd3 [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;
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +053022
Vinod Kumar S38046502016-03-23 15:30:27 +053023import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +053024import org.onosproject.yangutils.linker.exceptions.LinkerException;
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +053025import org.onosproject.yangutils.linker.ResolvableType;
26import org.onosproject.yangutils.linker.YangReferenceResolver;
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +053027import org.onosproject.yangutils.linker.impl.YangResolutionInfo;
Vinod Kumar S38046502016-03-23 15:30:27 +053028import org.onosproject.yangutils.parser.Parsable;
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +053029import org.onosproject.yangutils.plugin.manager.YangFileInfo;
Vinod Kumar S38046502016-03-23 15:30:27 +053030import org.onosproject.yangutils.utils.YangConstructType;
31
32import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil;
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +053033import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.linkInterFileReferences;
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +053034import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.resolveLinkingForResolutionList;
Vinod Kumar S38046502016-03-23 15:30:27 +053035
Vinod Kumar S67e7be62016-02-11 20:13:28 +053036/*
37 * Reference RFC 6020.
38 *
39 * While the primary unit in YANG is a module, a YANG module can itself
40 * be constructed out of several submodules. Submodules allow a module
41 * designer to split a complex model into several pieces where all the
42 * submodules contribute to a single namespace, which is defined by the
43 * module that includes the submodules.
44 *
45 * The "submodule" statement defines the submodule's name, and groups
46 * all statements that belong to the submodule together. The
47 * "submodule" statement's argument is the name of the submodule,
48 * followed by a block of sub-statements that hold detailed submodule
49 * information.
50 *
51 * The submodule's sub-statements
52 *
53 * +--------------+---------+-------------+------------------+
54 * | substatement | section | cardinality |data model mapping|
55 * +--------------+---------+-------------+------------------+
56 * | anyxml | 7.10 | 0..n | - not supported |
57 * | augment | 7.15 | 0..n | - child nodes |
58 * | belongs-to | 7.2.2 | 1 | - YangBelongsTo |
59 * | choice | 7.9 | 0..n | - child nodes |
60 * | contact | 7.1.8 | 0..1 | - string |
61 * | container | 7.5 | 0..n | - child nodes |
62 * | description | 7.19.3 | 0..1 | - string |
63 * | deviation | 7.18.3 | 0..n | - TODO |
64 * | extension | 7.17 | 0..n | - TODO |
65 * | feature | 7.18.1 | 0..n | - TODO |
66 * | grouping | 7.11 | 0..n | - child nodes |
67 * | identity | 7.16 | 0..n | - TODO |
68 * | import | 7.1.5 | 0..n | - YangImport |
69 * | include | 7.1.6 | 0..n | - YangInclude |
70 * | leaf | 7.6 | 0..n | - YangLeaf |
71 * | leaf-list | 7.7 | 0..n | - YangLeafList |
72 * | list | 7.8 | 0..n | - child nodes |
73 * | notification | 7.14 | 0..n | - TODO |
74 * | organization | 7.1.7 | 0..1 | - string |
75 * | reference | 7.19.4 | 0..1 | - string |
76 * | revision | 7.1.9 | 0..n | - string |
77 * | rpc | 7.13 | 0..n | - TODO |
78 * | typedef | 7.3 | 0..n | - child nodes |
79 * | uses | 7.12 | 0..n | - child nodes |
80 * | YANG-version | 7.1.2 | 0..1 | - int |
81 * +--------------+---------+-------------+------------------+
82 */
Gaurav Agrawal56527662016-04-20 15:49:17 +053083
Vinod Kumar S67e7be62016-02-11 20:13:28 +053084/**
Bharat saraswald9822e92016-04-05 15:13:44 +053085 * Represents data model node to maintain information defined in YANG sub-module.
Vinod Kumar S67e7be62016-02-11 20:13:28 +053086 */
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +053087public class YangSubModule
88 extends YangNode
Vinod Kumar Se4b9b0c2016-04-30 21:09:15 +053089 implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector, YangReferenceResolver,
90 RpcNotificationContainer {
Vinod Kumar S67e7be62016-02-11 20:13:28 +053091
92 /**
93 * Name of sub module.
94 */
95 private String name;
96
97 /**
98 * Module to which it belongs to.
99 */
100 private YangBelongsTo belongsTo;
101
102 /**
103 * Reference RFC 6020.
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530104 * <p>
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530105 * The "contact" statement provides contact information for the module. The
106 * argument is a string that is used to specify contact information for the
107 * person or persons to whom technical queries concerning this module should
108 * be sent, such as their name, postal address, telephone number, and
109 * electronic mail address.
110 */
111 private String contact;
112
113 /**
114 * Description.
115 */
116 private String description;
117
118 /**
119 * List of YANG modules imported.
120 */
121 private List<YangImport> importList;
122
123 /**
124 * List of YANG sub-modules included.
125 */
126 private List<YangInclude> includeList;
127
128 /**
129 * List of leaves at root level in the sub-module.
130 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530131 private List<YangLeaf> listOfLeaf;
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530132
133 /**
134 * List of leaf-lists at root level in the sub-module.
135 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530136 private List<YangLeafList> listOfLeafList;
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530137
138 /**
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530139 * Organization owner of the sub-module.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530140 */
141 private String organization;
142
143 /**
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530144 * Reference of the sub-module.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530145 */
146 private String reference;
147
148 /**
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530149 * Revision info of the sub-module.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530150 */
151 private YangRevision revision;
152
153 /**
154 * YANG version.
155 */
156 private byte version;
157
158 /**
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530159 * Prefix of parent module.
160 */
161 private String prefix;
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530162
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530163 /*-
164 * Reference RFC 6020.
165 *
166 * Nested typedefs and groupings.
167 * Typedefs and groupings may appear nested under many YANG statements,
168 * allowing these to be lexically scoped by the hierarchy under which
169 * they appear. This allows types and groupings to be defined near
170 * where they are used, rather than placing them at the top level of the
171 * hierarchy. The close proximity increases readability.
172 *
173 * Scoping also allows types to be defined without concern for naming
174 * conflicts between types in different submodules. Type names can be
175 * specified without adding leading strings designed to prevent name
176 * collisions within large modules.
177 *
178 * Finally, scoping allows the module author to keep types and groupings
179 * private to their module or submodule, preventing their reuse. Since
180 * only top-level types and groupings (i.e., those appearing as
181 * sub-statements to a module or submodule statement) can be used outside
182 * the module or submodule, the developer has more control over what
183 * pieces of their module are presented to the outside world, supporting
184 * the need to hide internal information and maintaining a boundary
185 * between what is shared with the outside world and what is kept
186 * private.
187 *
188 * Scoped definitions MUST NOT shadow definitions at a higher scope. A
189 * type or grouping cannot be defined if a higher level in the schema
190 * hierarchy has a definition with a matching identifier.
191 *
192 * A reference to an unprefixed type or grouping, or one which uses the
193 * prefix of the current module, is resolved by locating the closest
194 * matching "typedef" or "grouping" statement among the immediate
195 * sub-statements of each ancestor statement.
196 */
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530197 private List<YangResolutionInfo> derivedTypeResolutionList;
198
199 /**
200 * uses resolution list.
201 */
202 private List<YangResolutionInfo> usesResolutionList;
Gaurav Agrawal56527662016-04-20 15:49:17 +0530203
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530204 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530205 * Creates a sub module node.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530206 */
207 public YangSubModule() {
208 super(YangNodeType.SUB_MODULE_NODE);
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530209 derivedTypeResolutionList = new LinkedList<YangResolutionInfo>();
210 usesResolutionList = new LinkedList<YangResolutionInfo>();
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530211 importList = new LinkedList<YangImport>();
212 includeList = new LinkedList<YangInclude>();
213 listOfLeaf = new LinkedList<YangLeaf>();
214 listOfLeafList = new LinkedList<YangLeafList>();
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530215 }
216
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530217 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530218 * Returns the YANG name of the sub module.
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530219 *
220 * @return YANG name of the sub module
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530221 */
222 @Override
223 public String getName() {
224 return name;
225 }
226
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530227 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530228 * Sets YANG name of the sub module.
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530229 *
230 * @param subModuleName YANG name of the sub module
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530231 */
232 @Override
233 public void setName(String subModuleName) {
234 name = subModuleName;
235 }
236
237 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530238 * Returns the module info.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530239 *
240 * @return the belongs to info
241 */
242 public YangBelongsTo getBelongsTo() {
243 return belongsTo;
244 }
245
246 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530247 * Sets the module info.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530248 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530249 * @param belongsTo module info to set
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530250 */
251 public void setBelongsTo(YangBelongsTo belongsTo) {
252 this.belongsTo = belongsTo;
253 }
254
255 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530256 * Returns the contact.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530257 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530258 * @return the contact
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530259 */
260 public String getContact() {
261 return contact;
262 }
263
264 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530265 * Sets the contact.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530266 *
267 * @param contact the contact to set
268 */
269 public void setContact(String contact) {
270 this.contact = contact;
271 }
272
273 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530274 * Returns the description.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530275 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530276 * @return the description
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530277 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530278 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530279 public String getDescription() {
280 return description;
281 }
282
283 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530284 * Sets the description.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530285 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530286 * @param description set the description
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530287 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530288 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530289 public void setDescription(String description) {
290 this.description = description;
291 }
292
293 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530294 * Returns the list of imported modules.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530295 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530296 * @return the list of imported modules
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530297 */
Bharat saraswalcad0e652016-05-26 23:48:38 +0530298 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530299 public List<YangImport> getImportList() {
300 return importList;
301 }
302
303 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530304 * Adds the imported module information to the import list.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530305 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530306 * @param importedModule module being imported
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530307 */
Bharat saraswalcad0e652016-05-26 23:48:38 +0530308 @Override
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530309 public void addToImportList(YangImport importedModule) {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530310 getImportList().add(importedModule);
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530311 }
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530312
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530313 @Override
314 public void setImportList(List<YangImport> importList) {
315 this.importList = importList;
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530316 }
317
318 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530319 * Returns the list of included sub modules.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530320 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530321 * @return the included list of sub modules
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530322 */
Bharat saraswalcad0e652016-05-26 23:48:38 +0530323 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530324 public List<YangInclude> getIncludeList() {
325 return includeList;
326 }
327
328 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530329 * Returns the included sub module information to the include list.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530330 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530331 * @param includeModule submodule being included
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530332 */
Bharat saraswalcad0e652016-05-26 23:48:38 +0530333 @Override
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530334 public void addToIncludeList(YangInclude includeModule) {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530335 getIncludeList().add(includeModule);
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530336 }
337
338 @Override
339 public void setIncludeList(List<YangInclude> includeList) {
340 this.includeList = includeList;
341 }
342
343 @Override
344 public String getPrefix() {
345 return prefix;
346 }
347
348 @Override
349 public void setPrefix(String prefix) {
350 this.prefix = prefix;
351 }
352
353 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530354 public void resolveSelfFileLinking(ResolvableType type)
355 throws DataModelException {
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530356 // Get the list to be resolved.
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530357 List<YangResolutionInfo> resolutionList = getUnresolvedResolutionList(type);
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530358 // Resolve linking for a resolution list.
359 resolveLinkingForResolutionList(resolutionList, this);
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530360 }
361
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530362 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530363 public void resolveInterFileLinking(ResolvableType type)
364 throws DataModelException {
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530365 // Get the list to be resolved.
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530366 List<YangResolutionInfo> resolutionList = getUnresolvedResolutionList(type);
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530367 // Resolve linking for a resolution list.
368 linkInterFileReferences(resolutionList, this);
369 }
370
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530371 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530372 * Returns the list of leaves.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530373 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530374 * @return the list of leaves
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530375 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530376 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530377 public List<YangLeaf> getListOfLeaf() {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530378 return listOfLeaf;
379 }
380
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530381 @Override
382 public void setListOfLeaf(List<YangLeaf> leafsList) {
383 listOfLeaf = leafsList;
384 }
385
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530386 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530387 * Adds a leaf.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530388 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530389 * @param leaf the leaf to be added
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530390 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530391 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530392 public void addLeaf(YangLeaf leaf) {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530393 getListOfLeaf().add(leaf);
394 }
395
396 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530397 * Returns the list of leaf-list.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530398 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530399 * @return the list of leaf-list
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530400 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530401 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530402 public List<YangLeafList> getListOfLeafList() {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530403 return listOfLeafList;
404 }
405
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530406 @Override
407 public void setListOfLeafList(List<YangLeafList> listOfLeafList) {
408 this.listOfLeafList = listOfLeafList;
409 }
410
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530411 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530412 * Adds a leaf-list.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530413 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530414 * @param leafList the leaf-list to be added
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530415 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530416 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530417 public void addLeafList(YangLeafList leafList) {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530418 getListOfLeafList().add(leafList);
419 }
420
421 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530422 * Returns the sub-modules organization.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530423 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530424 * @return the organization
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530425 */
426 public String getOrganization() {
427 return organization;
428 }
429
430 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530431 * Sets the sub-modules organization.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530432 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530433 * @param org the organization to set
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530434 */
435 public void setOrganization(String org) {
436 organization = org;
437 }
438
439 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530440 * Returns the textual reference.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530441 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530442 * @return the reference
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530443 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530444 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530445 public String getReference() {
446 return reference;
447 }
448
449 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530450 * Sets the textual reference.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530451 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530452 * @param reference the reference to set
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530453 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530454 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530455 public void setReference(String reference) {
456 this.reference = reference;
457 }
458
459 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530460 * Returns the revision.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530461 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530462 * @return the revision
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530463 */
464 public YangRevision getRevision() {
465 return revision;
466 }
467
468 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530469 * Sets the revision.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530470 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530471 * @param revision the revision to set
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530472 */
473 public void setRevision(YangRevision revision) {
474 this.revision = revision;
475 }
476
477 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530478 * Returns the version.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530479 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530480 * @return the version
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530481 */
482 public byte getVersion() {
483 return version;
484 }
485
486 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530487 * Sets the version.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530488 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530489 * @param version the version to set
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530490 */
491 public void setVersion(byte version) {
492 this.version = version;
493 }
494
495 /**
496 * Returns the type of the parsed data.
497 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530498 * @return returns SUB_MODULE_DATA
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530499 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530500 @Override
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530501 public YangConstructType getYangConstructType() {
502 return YangConstructType.SUB_MODULE_DATA;
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530503 }
504
505 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530506 * Validates the data on entering the corresponding parse tree node.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530507 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530508 * @throws DataModelException a violation of data model rules
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530509 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530510 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530511 public void validateDataOnEntry()
512 throws DataModelException {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530513 // TODO auto-generated method stub, to be implemented by parser
514 }
515
516 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530517 * Validates the data on exiting the corresponding parse tree node.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530518 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530519 * @throws DataModelException a violation of data model rules
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530520 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530521 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530522 public void validateDataOnExit()
523 throws DataModelException {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530524 // TODO auto-generated method stub, to be implemented by parser
525 }
526
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530527 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530528 public void detectCollidingChild(String identifierName, YangConstructType dataType)
529 throws DataModelException {
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530530 // Asks helper to detect colliding child.
531 detectCollidingChildUtil(identifierName, dataType, this);
532 }
533
534 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530535 public void detectSelfCollision(String identifierName, YangConstructType dataType)
536 throws DataModelException {
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530537 // Not required as module doesn't have any parent.
538 }
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530539
540 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530541 public List<YangResolutionInfo> getUnresolvedResolutionList(ResolvableType type) {
542 if (type == ResolvableType.YANG_DERIVED_DATA_TYPE) {
543 return derivedTypeResolutionList;
544 } else {
545 return usesResolutionList;
546 }
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530547 }
548
549 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530550 public void addToResolutionList(YangResolutionInfo resolutionInfo,
551 ResolvableType type) {
552 if (type == ResolvableType.YANG_DERIVED_DATA_TYPE) {
553 derivedTypeResolutionList.add(resolutionInfo);
554 } else if (type == ResolvableType.YANG_USES) {
555 usesResolutionList.add(resolutionInfo);
556 }
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530557 }
558
559 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530560 public void setResolutionList(List<YangResolutionInfo> resolutionList,
561 ResolvableType type) {
562 if (type == ResolvableType.YANG_DERIVED_DATA_TYPE) {
563 derivedTypeResolutionList = resolutionList;
564 } else if (type == ResolvableType.YANG_USES) {
565 usesResolutionList = resolutionList;
566 }
567
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530568 }
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530569
570 /**
571 * Links the sub-module with module.
572 *
573 * @param yangFileInfoSet YANG file information set
574 * @throws DataModelException a violation in data model rule
575 */
576 public void linkWithModule(Set<YangFileInfo> yangFileInfoSet)
577 throws DataModelException {
578 getBelongsTo().linkWithModule(yangFileInfoSet);
579 }
580
581 @Override
582 public void addReferencesToIncludeList(Set<YangFileInfo> yangFileInfoSet)
583 throws LinkerException {
584 Iterator<YangInclude> includeInfoIterator = getIncludeList().iterator();
585 // Run through the included list to add references.
586 while (includeInfoIterator.hasNext()) {
587 YangInclude yangInclude = includeInfoIterator.next();
588 YangSubModule subModule = null;
589 try {
590 subModule = yangInclude.addReferenceToInclude(yangFileInfoSet);
591 } catch (DataModelException e) {
592 throw new LinkerException(e.getMessage());
593 }
594 // Check if the referred sub-modules parent is self
595 if (!(subModule.getBelongsTo().getModuleNode() == getBelongsTo().getModuleNode())) {
596 try {
597 yangInclude.reportIncludeError();
598 } catch (DataModelException e) {
599 throw new LinkerException(e.getMessage());
600 }
601 }
602 }
603 }
604
605 @Override
606 public void addReferencesToImportList(Set<YangFileInfo> yangFileInfoSet)
607 throws LinkerException {
608 Iterator<YangImport> importInfoIterator = getImportList().iterator();
609 // Run through the imported list to add references.
610 while (importInfoIterator.hasNext()) {
611 YangImport yangImport = importInfoIterator.next();
612 try {
613 yangImport.addReferenceToImport(yangFileInfoSet);
614 } catch (DataModelException e) {
615 throw new LinkerException(e.getMessage());
616 }
617 }
618 }
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530619}