blob: d2514795dc63c9dc256b72b05117ed9af8bf8926 [file] [log] [blame]
Vinod Kumar S67e7be62016-02-11 20:13:28 +05301/*
2 * Copyright 2016 Open Networking Laboratory
3 *
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 */
16
17package org.onosproject.yangutils.datamodel;
18
Bharat saraswal870c56f2016-02-20 21:57:16 +053019import java.io.IOException;
Vinod Kumar S67e7be62016-02-11 20:13:28 +053020import java.util.LinkedList;
21import java.util.List;
22
23import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +053024import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil;
Vinod Kumar S67e7be62016-02-11 20:13:28 +053025import org.onosproject.yangutils.parser.Parsable;
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +053026import org.onosproject.yangutils.utils.YangConstructType;
Bharat saraswal870c56f2016-02-20 21:57:16 +053027import org.onosproject.yangutils.translator.CachedFileHandle;
28import org.onosproject.yangutils.translator.GeneratedFileType;
29import org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax;
Bharat saraswal4bf8b152016-02-25 02:26:43 +053030import org.onosproject.yangutils.utils.UtilConstants;
Bharat saraswal870c56f2016-02-20 21:57:16 +053031import org.onosproject.yangutils.utils.io.impl.FileSystemUtil;
Vinod Kumar S67e7be62016-02-11 20:13:28 +053032/*-
33 * Reference RFC 6020.
34 *
35 * The "container" statement is used to define an interior data node in the
36 * schema tree. It takes one argument, which is an identifier, followed by a
37 * block of sub-statements that holds detailed container information.
38 *
39 * A container node does not have a value, but it has a list of child nodes in
40 * the data tree. The child nodes are defined in the container's sub-statements.
41 *
42 * Containers with Presence
43 *
44 * YANG supports two styles of containers, those that exist only for organizing
45 * the hierarchy of data nodes, and those whose presence in the configuration
46 * has an explicit meaning.
47 *
48 * In the first style, the container has no meaning of its own, existing only to
49 * contain child nodes. This is the default style.
50 *
51 * For example, the set of scrambling options for Synchronous Optical Network
52 * (SONET) interfaces may be placed inside a "scrambling" container to enhance
53 * the organization of the configuration hierarchy, and to keep these nodes
54 * together. The "scrambling" node itself has no meaning, so removing the node
55 * when it becomes empty relieves the user from performing this task.
56 *
57 * In the second style, the presence of the container itself is configuration
58 * data, representing a single bit of configuration data. The container acts as
59 * both a configuration knob and a means of organizing related configuration.
60 * These containers are explicitly created and deleted.
61 *
62 * YANG calls this style a "presence container" and it is indicated using the
63 * "presence" statement, which takes as its argument a text string indicating
64 * what the presence of the node means.
65 *
66 * The container's Substatements
67 *
68 * +--------------+---------+-------------+------------------+
69 * | substatement | section | cardinality |data model mapping|
70 * +--------------+---------+-------------+------------------+
71 * | anyxml | 7.10 | 0..n | -not supported |
72 * | choice | 7.9 | 0..n | -child nodes |
73 * | config | 7.19.1 | 0..1 | -boolean |
74 * | container | 7.5 | 0..n | -child nodes |
75 * | description | 7.19.3 | 0..1 | -string |
76 * | grouping | 7.11 | 0..n | -child nodes |
77 * | if-feature | 7.18.2 | 0..n | -TODO |
78 * | leaf | 7.6 | 0..n | -YangLeaf |
79 * | leaf-list | 7.7 | 0..n | -YangLeafList |
80 * | list | 7.8 | 0..n | -child nodes |
81 * | must | 7.5.3 | 0..n | -TODO |
82 * | presence | 7.5.5 | 0..1 | -boolean |
83 * | reference | 7.19.4 | 0..1 | -string |
84 * | status | 7.19.2 | 0..1 | -YangStatus |
85 * | typedef | 7.3 | 0..n | -child nodes |
86 * | uses | 7.12 | 0..n | -child nodes |
87 * | when | 7.19.5 | 0..1 | -TODO |
88 * +--------------+---------+-------------+------------------+
89 */
90
91/**
92 * Data model node to maintain information defined in YANG container.
93 */
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +053094public class YangContainer extends YangNode implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector {
Vinod Kumar S67e7be62016-02-11 20:13:28 +053095
96 /**
97 * Name of the container.
98 */
99 private String name;
100
101 /**
102 * If container maintains config data.
103 */
Vidyashree Ramaf4c617c2016-02-24 12:28:22 +0530104 private Boolean isConfig;
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530105
106 /**
107 * Description of container.
108 */
109 private String description;
110
111 /**
112 * List of leaves contained.
113 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530114 private List<YangLeaf> listOfLeaf;
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530115
116 /**
117 * List of leaf-lists contained.
118 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530119 private List<YangLeafList> listOfLeafList;
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530120
121 /**
122 * If it is a presence container, then the textual documentation of presence
123 * usage.
124 */
125 private String presence;
126
127 /**
128 * Reference of the module.
129 */
130 private String reference;
131
132 /**
133 * Status of the node.
134 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530135 private YangStatusType status = YangStatusType.CURRENT;
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530136
137 /**
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530138 * Package of the generated java code.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530139 */
140 private String pkg;
141
142 /**
143 * Cached Java File Handle.
144 */
145 private CachedFileHandle fileHandle;
146
147 /**
148 * Create a container node.
149 */
150 public YangContainer() {
151 super(YangNodeType.CONTAINER_NODE);
152 }
153
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530154 /**
155 * Get the YANG name of container.
156 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530157 * @return the name of container as defined in YANG file
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530158 */
159 @Override
160 public String getName() {
161 return name;
162 }
163
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530164 /**
165 * Set the YANG name of container.
166 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530167 * @param name the name of container as defined in YANG file
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530168 */
169 @Override
170 public void setName(String name) {
171 this.name = name;
172 }
173
174 /**
175 * Get the config flag.
176 *
177 * @return the isConfig
178 */
Vidyashree Ramaf4c617c2016-02-24 12:28:22 +0530179 public Boolean isConfig() {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530180 return isConfig;
181 }
182
183 /**
184 * Set the config flag.
185 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530186 * @param isCfg the config flag
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530187 */
188 public void setConfig(boolean isCfg) {
189 isConfig = isCfg;
190 }
191
192 /**
193 * Get the description.
194 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530195 * @return the description
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530196 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530197 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530198 public String getDescription() {
199 return description;
200 }
201
202 /**
203 * Set the description.
204 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530205 * @param description set the description
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530206 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530207 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530208 public void setDescription(String description) {
209 this.description = description;
210 }
211
212 /**
213 * Get the list of leaves.
214 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530215 * @return the list of leaves
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530216 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530217 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530218 public List<YangLeaf> getListOfLeaf() {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530219 return listOfLeaf;
220 }
221
222 /**
223 * Set the list of leaves.
224 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530225 * @param leafsList the list of leaf to set
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530226 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530227 private void setListOfLeaf(List<YangLeaf> leafsList) {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530228 listOfLeaf = leafsList;
229 }
230
231 /**
232 * Add a leaf.
233 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530234 * @param leaf the leaf to be added
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530235 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530236 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530237 public void addLeaf(YangLeaf leaf) {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530238 if (getListOfLeaf() == null) {
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530239 setListOfLeaf(new LinkedList<YangLeaf>());
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530240 }
241
242 getListOfLeaf().add(leaf);
243 }
244
245 /**
246 * Get the list of leaf-list.
247 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530248 * @return the list of leaf-list
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530249 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530250 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530251 public List<YangLeafList> getListOfLeafList() {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530252 return listOfLeafList;
253 }
254
255 /**
256 * Set the list of leaf-list.
257 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530258 * @param listOfLeafList the list of leaf-list to set
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530259 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530260 private void setListOfLeafList(List<YangLeafList> listOfLeafList) {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530261 this.listOfLeafList = listOfLeafList;
262 }
263
264 /**
265 * Add a leaf-list.
266 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530267 * @param leafList the leaf-list to be added
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530268 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530269 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530270 public void addLeafList(YangLeafList leafList) {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530271 if (getListOfLeafList() == null) {
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530272 setListOfLeafList(new LinkedList<YangLeafList>());
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530273 }
274
275 getListOfLeafList().add(leafList);
276 }
277
278 /**
279 * Get the presence string if present.
280 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530281 * @return the presence
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530282 */
283 public String getPresence() {
284 return presence;
285 }
286
287 /**
288 * Set the presence string.
289 *
290 * @param presence the presence flag
291 */
292 public void setPresence(String presence) {
293 this.presence = presence;
294 }
295
296 /**
297 * Get the textual reference.
298 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530299 * @return the reference
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530300 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530301 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530302 public String getReference() {
303 return reference;
304 }
305
306 /**
307 * Set the textual reference.
308 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530309 * @param reference the reference to set
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530310 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530311 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530312 public void setReference(String reference) {
313 this.reference = reference;
314 }
315
316 /**
317 * Get the status.
318 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530319 * @return the status
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530320 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530321 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530322 public YangStatusType getStatus() {
323 return status;
324 }
325
326 /**
327 * Set the status.
328 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530329 * @param status the status to set
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530330 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530331 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530332 public void setStatus(YangStatusType status) {
333 this.status = status;
334 }
335
336 /**
337 * Get the cached file handle.
338 *
339 * @return the fileHandle
340 */
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530341 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530342 public CachedFileHandle getFileHandle() {
343 return fileHandle;
344 }
345
346 /**
347 * Set the cached file handle.
348 *
349 * @param handle the fileHandle to set
350 */
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530351 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530352 public void setFileHandle(CachedFileHandle handle) {
353 fileHandle = handle;
354 }
355
356 /**
357 * Returns the type of the data.
358 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530359 * @return returns CONTAINER_DATA
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530360 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530361 @Override
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530362 public YangConstructType getYangConstructType() {
363 return YangConstructType.CONTAINER_DATA;
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530364 }
365
366 /**
367 * Validate the data on entering the corresponding parse tree node.
368 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530369 * @throws DataModelException a violation of data model rules
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530370 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530371 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530372 public void validateDataOnEntry() throws DataModelException {
373 // TODO auto-generated method stub, to be implemented by parser
374 }
375
376 /**
377 * Validate the data on exiting the corresponding parse tree node.
378 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530379 * @throws DataModelException a violation of data model rules
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530380 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530381 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530382 public void validateDataOnExit() throws DataModelException {
Vidyashree Ramaf4c617c2016-02-24 12:28:22 +0530383 List<YangLeaf> leaves = getListOfLeaf();
384 List<YangLeafList> leafLists = getListOfLeafList();
385
386 setDefaultConfigValueToChild(leaves, leafLists);
387 validateConfig(leaves, leafLists);
388 }
389
390 /**
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530391 * Sets the config's value to all leaf if leaf's config statement is not
392 * specified.
Vidyashree Ramaf4c617c2016-02-24 12:28:22 +0530393 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530394 * @param leaves list of leaf attributes of container
395 * @param leafLists list of leaf-list attributes of container
Vidyashree Ramaf4c617c2016-02-24 12:28:22 +0530396 */
397 private void setDefaultConfigValueToChild(List<YangLeaf> leaves, List<YangLeafList> leafLists) {
398
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530399 /*
400 * If "config" is not specified, the default is the same as the parent
401 * schema node's "config" value.
402 */
Vidyashree Ramaf4c617c2016-02-24 12:28:22 +0530403 if (leaves != null) {
404 for (YangLeaf leaf : leaves) {
405 if (leaf.isConfig() == null) {
406 leaf.setConfig(isConfig);
407 }
408 }
409 }
410
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530411 /*
412 * If "config" is not specified, the default is the same as the parent
413 * schema node's "config" value.
414 */
Vidyashree Ramaf4c617c2016-02-24 12:28:22 +0530415 if (leafLists != null) {
416 for (YangLeafList leafList : leafLists) {
417 if (leafList.isConfig() == null) {
418 leafList.setConfig(isConfig);
419 }
420 }
421 }
422 }
423
424 /**
425 * Validates config statement of container.
426 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530427 * @param leaves list of leaf attributes of container
428 * @param leafLists list of leaf-list attributes of container
429 * @throws DataModelException a violation of data model rules
Vidyashree Ramaf4c617c2016-02-24 12:28:22 +0530430 */
431 private void validateConfig(List<YangLeaf> leaves, List<YangLeafList> leafLists) throws DataModelException {
432
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530433 /*
434 * If a node has "config" set to "false", no node underneath it can have
435 * "config" set to "true".
436 */
Vidyashree Ramaf4c617c2016-02-24 12:28:22 +0530437 if ((!isConfig) && (leaves != null)) {
438 for (YangLeaf leaf : leaves) {
439 if (leaf.isConfig()) {
440 throw new DataModelException("If a container has \"config\" set to \"false\", no node underneath " +
441 "it can have \"config\" set to \"true\".");
442 }
443 }
444 }
445
446 if ((!isConfig) && (leafLists != null)) {
447 for (YangLeafList leafList : leafLists) {
448 if (leafList.isConfig()) {
449 throw new DataModelException("If a container has \"config\" set to \"false\", no node underneath " +
450 "it can have \"config\" set to \"true\".");
451 }
452 }
453 }
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530454 }
455
456 /**
457 * Get the mapped java package.
458 *
459 * @return the java package
460 */
461 @Override
462 public String getPackage() {
463 return pkg;
464 }
465
466 /**
467 * Set the mapped java package.
468 *
469 * @param pcg the package to set
470 */
471 @Override
472 public void setPackage(String pcg) {
473 pkg = pcg;
474 }
475
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530476 /**
477 * Generate the java code corresponding to YANG container.
478 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530479 * @throws IOException when fails to generate the source files
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530480 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530481 @Override
482 public void generateJavaCodeEntry() throws IOException {
483 YangNode parent = getParent();
Bharat saraswal4bf8b152016-02-25 02:26:43 +0530484 String contPkg = JavaIdentifierSyntax.getPackageFromParent(parent.getPackage(), parent.getName());
485 setPackage(contPkg);
Bharat saraswal870c56f2016-02-20 21:57:16 +0530486
487 CachedFileHandle handle = null;
488 try {
Bharat saraswal4bf8b152016-02-25 02:26:43 +0530489 FileSystemUtil.createPackage(UtilConstants.YANG_GEN_DIR + getPackage(), getName());
Bharat saraswal870c56f2016-02-20 21:57:16 +0530490 handle = FileSystemUtil.createSourceFiles(getPackage(), getName(), GeneratedFileType.ALL);
Bharat saraswal4bf8b152016-02-25 02:26:43 +0530491 handle.setFilePath(UtilConstants.YANG_GEN_DIR + getPackage().replace(".", "/"));
Bharat saraswal870c56f2016-02-20 21:57:16 +0530492 } catch (IOException e) {
493 throw new IOException("Failed to create the source files.");
494 }
495 setFileHandle(handle);
Bharat saraswal4bf8b152016-02-25 02:26:43 +0530496
497 addLeavesAttributes();
498 addLeafListAttributes();
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530499 addAttributeInParent();
500 }
501
502 /**
503 * Adds current node attribute to parent file.
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530504 */
505 private void addAttributeInParent() {
506 if (getParent() != null) {
507 getParent().getFileHandle().setChildsPackage(getPackage());
508 getParent().getFileHandle().addAttributeInfo(null, getName(), false);
509 }
510 }
511
512 @Override
513 public void generateJavaCodeExit() throws IOException {
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530514 getFileHandle().close();
515 return;
Bharat saraswal870c56f2016-02-20 21:57:16 +0530516 }
517
518 /**
519 * Adds leaf attributes in generated files.
520 */
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530521 private void addLeavesAttributes() {
Bharat saraswal870c56f2016-02-20 21:57:16 +0530522
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530523 List<YangLeaf> leaves = getListOfLeaf();
Bharat saraswal870c56f2016-02-20 21:57:16 +0530524 if (leaves != null) {
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530525 for (YangLeaf leaf : leaves) {
Bharat saraswal870c56f2016-02-20 21:57:16 +0530526 getFileHandle().addAttributeInfo(leaf.getDataType(), leaf.getLeafName(), false);
527 }
528 }
529 }
530
531 /**
532 * Adds leaf list's attributes in generated files.
533 */
534 private void addLeafListAttributes() {
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530535 List<YangLeafList> leavesList = getListOfLeafList();
Bharat saraswal870c56f2016-02-20 21:57:16 +0530536 if (leavesList != null) {
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530537 for (YangLeafList leafList : leavesList) {
Bharat saraswal870c56f2016-02-20 21:57:16 +0530538 getFileHandle().addAttributeInfo(leafList.getDataType(), leafList.getLeafName(), true);
539 }
540 }
541 return;
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530542 }
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530543
544 @Override
545 public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException {
546 // Asks helper to detect colliding child.
547 detectCollidingChildUtil(identifierName, dataType, this);
548 }
549
550 @Override
551 public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException {
552 if (this.getName().equals(identifierName)) {
553 throw new DataModelException("YANG file error: Duplicate input identifier detected, same as container \""
554 + this.getName() + "\"");
555 }
556 }
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530557}