blob: f737e32bf7718a627fe494a076ac8131c4a28bde [file] [log] [blame]
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +05301/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +05303 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.yangutils.datamodel;
17
Bharat saraswal2f00b4b2016-03-04 20:08:09 +053018import java.util.LinkedList;
19import java.util.List;
Vinod Kumar Se4b9b0c2016-04-30 21:09:15 +053020
Bharat saraswal2f00b4b2016-03-04 20:08:09 +053021import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
Vinod Kumar S67e7be62016-02-11 20:13:28 +053022import org.onosproject.yangutils.parser.Parsable;
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +053023import org.onosproject.yangutils.utils.YangConstructType;
Vinod Kumar S38046502016-03-23 15:30:27 +053024
25import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil;
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +053026import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.resolveLinkingForResolutionList;
Vinod Kumar S67e7be62016-02-11 20:13:28 +053027
28/*-
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +053029 * Reference:RFC 6020.
30 * The "module" statement defines the module's name,
31 * and groups all statements that belong to the module together. The "module"
32 * statement's argument is the name of the module, followed by a block of
33 * sub statements that hold detailed module information.
34 * The module's sub statements
35 *
36 * +--------------+---------+-------------+-----------------------+
37 * |sub statement | section | cardinality | data model mapping |
38 * +--------------+---------+-------------+-----------------------+
39 * | anyxml | 7.10 | 0..n | not supported |
40 * | augment | 7.15 | 0..n | child nodes |
41 * | choice | 7.9 | 0..n | child nodes |
42 * | contact | 7.1.8 | 0..1 | string |
43 * | container | 7.5 | 0..n | child nodes |
44 * | description | 7.19.3 | 0..1 | string |
45 * | deviation | 7.18.3 | 0..n | TODO |
46 * | extension | 7.17 | 0..n | TODO |
47 * | feature | 7.18.1 | 0..n | TODO |
48 * | grouping | 7.11 | 0..n | child nodes |
49 * | identity | 7.16 | 0..n | TODO |
50 * | import | 7.1.5 | 0..n | list of import info |
51 * | include | 7.1.6 | 0..n | list of include info |
52 * | leaf | 7.6 | 0..n | list of leaf info |
53 * | leaf-list | 7.7 | 0..n | list of leaf-list info|
54 * | list | 7.8 | 0..n | child nodes |
55 * | namespace | 7.1.3 | 1 | string/uri |
56 * | notification | 7.14 | 0..n | TODO |
57 * | organization | 7.1.7 | 0..1 | string |
58 * | prefix | 7.1.4 | 1 | string |
59 * | reference | 7.19.4 | 0..1 | string |
60 * | revision | 7.1.9 | 0..n | revision |
61 * | rpc | 7.13 | 0..n | TODO |
62 * | typedef | 7.3 | 0..n | child nodes |
63 * | uses | 7.12 | 0..n | child nodes |
64 * | YANG-version | 7.1.2 | 0..1 | int |
65 * +--------------+---------+-------------+-----------------------+
66 */
67
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +053068/**
Bharat saraswald9822e92016-04-05 15:13:44 +053069 * Represents data model node to maintain information defined in YANG module.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +053070 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +053071public class YangModule extends YangNode
Vinod Kumar Se4b9b0c2016-04-30 21:09:15 +053072 implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector, YangReferenceResolver,
73 RpcNotificationContainer {
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +053074
75 /**
76 * Name of the module.
77 */
78 private String name;
79
80 /**
81 * Reference:RFC 6020.
Vinod Kumar S67e7be62016-02-11 20:13:28 +053082 *
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +053083 * The "contact" statement provides contact information for the module. The
84 * argument is a string that is used to specify contact information for the
85 * person or persons to whom technical queries concerning this module should
86 * be sent, such as their name, postal address, telephone number, and
87 * electronic mail address.
88 */
89 private String contact;
90
91 /**
92 * Reference:RFC 6020.
Vinod Kumar S67e7be62016-02-11 20:13:28 +053093 *
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +053094 * The "description" statement takes as an argument a string that contains a
95 * human-readable textual description of this definition. The text is
96 * provided in a language (or languages) chosen by the module developer; for
97 * the sake of interoperability.
98 */
99 private String description;
100
101 /**
102 * List of YANG modules imported.
103 */
104 private List<YangImport> importList;
105
106 /**
107 * List of YANG sub-modules included.
108 */
109 private List<YangInclude> includeList;
110
111 /**
112 * List of leaves at root level in the module.
113 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530114 private List<YangLeaf> listOfLeaf;
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530115
116 /**
117 * List of leaf-lists at root level in the module.
118 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530119 private List<YangLeafList> listOfLeafList;
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530120
121 /**
122 * Name space of the module.
123 */
124 private YangNameSpace nameSpace;
125
126 /**
127 * Reference:RFC 6020.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530128 *
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530129 * The "organization" statement defines the party responsible for this
130 * module. The argument is a string that is used to specify a textual
131 * description of the organization(s) under whose auspices this module was
132 * developed.
133 */
134 private String organization;
135
136 /**
137 * Prefix to refer to the objects in module.
138 */
139 private String prefix;
140
141 /**
142 * Reference of the module.
143 */
144 private String reference;
145
146 /**
147 * Revision info of the module.
148 */
149 private YangRevision revision;
150
151 /**
152 * YANG version.
153 */
154 private byte version;
155
Vinod Kumar S71cba682016-02-25 15:52:16 +0530156 /*-
Vinod Kumar Sc4216002016-03-03 19:55:30 +0530157 * Reference RFC 6020.
158 *
Vinod Kumar S71cba682016-02-25 15:52:16 +0530159 * Nested typedefs and groupings.
160 * Typedefs and groupings may appear nested under many YANG statements,
161 * allowing these to be lexically scoped by the hierarchy under which
162 * they appear. This allows types and groupings to be defined near
163 * where they are used, rather than placing them at the top level of the
164 * hierarchy. The close proximity increases readability.
165 *
166 * Scoping also allows types to be defined without concern for naming
167 * conflicts between types in different submodules. Type names can be
168 * specified without adding leading strings designed to prevent name
169 * collisions within large modules.
170 *
171 * Finally, scoping allows the module author to keep types and groupings
172 * private to their module or submodule, preventing their reuse. Since
173 * only top-level types and groupings (i.e., those appearing as
174 * sub-statements to a module or submodule statement) can be used outside
175 * the module or submodule, the developer has more control over what
176 * pieces of their module are presented to the outside world, supporting
177 * the need to hide internal information and maintaining a boundary
178 * between what is shared with the outside world and what is kept
179 * private.
180 *
181 * Scoped definitions MUST NOT shadow definitions at a higher scope. A
182 * type or grouping cannot be defined if a higher level in the schema
183 * hierarchy has a definition with a matching identifier.
184 *
185 * A reference to an unprefixed type or grouping, or one which uses the
186 * prefix of the current module, is resolved by locating the closest
187 * matching "typedef" or "grouping" statement among the immediate
188 * sub-statements of each ancestor statement.
189 */
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530190 private List<YangResolutionInfo> unresolvedResolutionList;
Vinod Kumar S71cba682016-02-25 15:52:16 +0530191
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530192 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530193 * Creates a YANG node of module type.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530194 */
195 public YangModule() {
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530196
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530197 super(YangNodeType.MODULE_NODE);
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530198 unresolvedResolutionList = new LinkedList<YangResolutionInfo>();
199 importList = new LinkedList<YangImport>();
200 includeList = new LinkedList<YangInclude>();
201 listOfLeaf = new LinkedList<YangLeaf>();
202 listOfLeafList = new LinkedList<YangLeafList>();
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530203 }
204
Vinod Kumar S71cba682016-02-25 15:52:16 +0530205 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530206 * Returns name of the module.
Vinod Kumar S71cba682016-02-25 15:52:16 +0530207 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530208 * @return module name
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530209 */
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530210 @Override
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530211 public String getName() {
212 return name;
213 }
214
Vinod Kumar S71cba682016-02-25 15:52:16 +0530215 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530216 * Sets module name.
Vinod Kumar S71cba682016-02-25 15:52:16 +0530217 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530218 * @param moduleName module name
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530219 */
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530220 @Override
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530221 public void setName(String moduleName) {
222 name = moduleName;
223 }
224
225 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530226 * Returns the contact details of the module owner.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530227 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530228 * @return the contact details of YANG owner
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530229 */
230 public String getContact() {
231 return contact;
232 }
233
234 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530235 * Sets the contact details of the module owner.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530236 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530237 * @param contact the contact details of YANG owner
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530238 */
239 public void setContact(String contact) {
240 this.contact = contact;
241 }
242
243 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530244 * Returns the description of module.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530245 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530246 * @return the description of YANG module
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530247 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530248 @Override
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530249 public String getDescription() {
250 return description;
251 }
252
253 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530254 * Sets the description of module.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530255 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530256 * @param description set the description of YANG module
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530257 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530258 @Override
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530259 public void setDescription(String description) {
260 this.description = description;
261 }
262
263 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530264 * Returns the list of imported modules.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530265 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530266 * @return the list of imported modules
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530267 */
268 public List<YangImport> getImportList() {
269 return importList;
270 }
271
272 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530273 * Adds the imported module information to the import list.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530274 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530275 * @param importedModule module being imported
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530276 */
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530277 public void addToImportList(YangImport importedModule) {
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530278 getImportList().add(importedModule);
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530279 }
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530280
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530281 @Override
282 public void setImportList(List<YangImport> importList) {
283 this.importList = importList;
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530284 }
285
286 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530287 * Returns the list of included sub modules.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530288 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530289 * @return the included list of sub modules
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530290 */
291 public List<YangInclude> getIncludeList() {
292 return includeList;
293 }
294
295 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530296 * Adds the included sub module information to the include list.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530297 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530298 * @param includeModule submodule being included
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530299 */
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530300 public void addToIncludeList(YangInclude includeModule) {
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530301 getIncludeList().add(includeModule);
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530302 }
303
304 @Override
305 public void setIncludeList(List<YangInclude> includeList) {
306 this.includeList = includeList;
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530307 }
308
309 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530310 * Returns the list of leaves in module.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530311 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530312 * @return the list of leaves
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530313 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530314 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530315 public List<YangLeaf> getListOfLeaf() {
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530316 return listOfLeaf;
317 }
318
319 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530320 * Adds a leaf in module.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530321 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530322 * @param leaf the leaf to be added
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530323 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530324 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530325 public void addLeaf(YangLeaf leaf) {
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530326 getListOfLeaf().add(leaf);
327 }
328
329 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530330 * Returns the list of leaf-list from module.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530331 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530332 * @return the list of leaf-list
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530333 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530334 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530335 public List<YangLeafList> getListOfLeafList() {
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530336 return listOfLeafList;
337 }
338
339 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530340 * Adds a leaf-list in module.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530341 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530342 * @param leafList the leaf-list to be added
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530343 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530344 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530345 public void addLeafList(YangLeafList leafList) {
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530346 getListOfLeafList().add(leafList);
347 }
348
349 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530350 * Returns the name space of module elements.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530351 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530352 * @return the nameSpace
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530353 */
354 public YangNameSpace getNameSpace() {
355 return nameSpace;
356 }
357
358 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530359 * Sets the name space of module elements.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530360 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530361 * @param nameSpace the nameSpace to set
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530362 */
363 public void setNameSpace(YangNameSpace nameSpace) {
364 this.nameSpace = nameSpace;
365 }
366
367 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530368 * Returns the modules organization.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530369 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530370 * @return the organization
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530371 */
372 public String getOrganization() {
373 return organization;
374 }
375
376 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530377 * Sets the modules organization.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530378 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530379 * @param org the organization to set
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530380 */
381 public void setOrganization(String org) {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530382 organization = org;
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530383 }
384
385 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530386 * Returns the prefix.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530387 *
388 * @return the prefix
389 */
390 public String getPrefix() {
391 return prefix;
392 }
393
394 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530395 * Sets the prefix.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530396 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530397 * @param prefix the prefix to set
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530398 */
399 public void setPrefix(String prefix) {
400 this.prefix = prefix;
401 }
402
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530403 @Override
404 public void resolveSelfFileLinking() throws DataModelException {
405 // Get the list to be resolved.
406 List<YangResolutionInfo> resolutionList = getUnresolvedResolutionList();
407 // Resolve linking for a resolution list.
408 resolveLinkingForResolutionList(resolutionList, this);
409 }
410
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530411 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530412 * Returns the textual reference.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530413 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530414 * @return the reference
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530415 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530416 @Override
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530417 public String getReference() {
418 return reference;
419 }
420
421 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530422 * Sets the textual reference.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530423 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530424 * @param reference the reference to set
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530425 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530426 @Override
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530427 public void setReference(String reference) {
428 this.reference = reference;
429 }
430
431 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530432 * Returns the revision.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530433 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530434 * @return the revision
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530435 */
436 public YangRevision getRevision() {
437 return revision;
438 }
439
440 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530441 * Sets the revision.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530442 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530443 * @param revision the revision to set
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530444 */
445 public void setRevision(YangRevision revision) {
446 this.revision = revision;
447 }
448
449 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530450 * Returns the version.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530451 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530452 * @return the version
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530453 */
454 public byte getVersion() {
455 return version;
456 }
457
458 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530459 * Sets the version.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530460 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530461 * @param version the version to set
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530462 */
463 public void setVersion(byte version) {
464 this.version = version;
465 }
466
467 /**
468 * Returns the type of the parsed data.
469 *
Bharat saraswal2f00b4b2016-03-04 20:08:09 +0530470 * @return returns MODULE_DATA
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530471 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530472 @Override
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530473 public YangConstructType getYangConstructType() {
474 return YangConstructType.MODULE_DATA;
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530475 }
476
477 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530478 * Validates the data on entering the corresponding parse tree node.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530479 *
480 * @throws DataModelException a violation of data model rules
481 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530482 @Override
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530483 public void validateDataOnEntry() throws DataModelException {
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530484 /*
485 * Module is root in the data model tree, hence there is no entry
486 * validation
487 */
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530488 }
489
490 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530491 * Validates the data on exiting the corresponding parse tree node.
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530492 *
493 * @throws DataModelException a violation of data model rules
494 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530495 @Override
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530496 public void validateDataOnExit() throws DataModelException {
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530497 /*
498 * TODO: perform symbol linking for the imported or included YANG info.
499 * TODO: perform symbol resolution for referred YANG entities.
500 */
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530501 }
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530502
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530503 @Override
504 public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException {
505 // Asks helper to detect colliding child.
506 detectCollidingChildUtil(identifierName, dataType, this);
507 }
508
509 @Override
510 public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException {
511 // Not required as module doesn't have any parent.
512 }
Vinod Kumar S38046502016-03-23 15:30:27 +0530513
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530514 @Override
515 public List<YangResolutionInfo> getUnresolvedResolutionList() {
516 return unresolvedResolutionList;
517 }
518
519 @Override
520 public void addToResolutionList(YangResolutionInfo resolutionInfo) {
521 unresolvedResolutionList.add(resolutionInfo);
522 }
523
524 @Override
525 public void setResolutionList(List<YangResolutionInfo> resolutionList) {
526 unresolvedResolutionList = resolutionList;
527 }
Vinod Kumar S1ede5ab2016-02-09 20:14:53 +0530528}