blob: 7bb34e2895044704448703617fab82ada9029424 [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 */
16
17package org.onosproject.yangutils.datamodel;
18
19import java.util.LinkedList;
20import java.util.List;
21
22import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
Bharat saraswal96dfef02016-06-16 00:29:12 +053023import org.onosproject.yangutils.datamodel.utils.Parsable;
24import org.onosproject.yangutils.datamodel.utils.YangConstructType;
Vinod Kumar S38046502016-03-23 15:30:27 +053025
26import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil;
27
Vinod Kumar S67e7be62016-02-11 20:13:28 +053028/*-
29 * Reference RFC 6020.
30 *
31 * The "container" statement is used to define an interior data node in the
32 * schema tree. It takes one argument, which is an identifier, followed by a
33 * block of sub-statements that holds detailed container information.
34 *
35 * A container node does not have a value, but it has a list of child nodes in
36 * the data tree. The child nodes are defined in the container's sub-statements.
37 *
38 * Containers with Presence
39 *
40 * YANG supports two styles of containers, those that exist only for organizing
41 * the hierarchy of data nodes, and those whose presence in the configuration
42 * has an explicit meaning.
43 *
44 * In the first style, the container has no meaning of its own, existing only to
45 * contain child nodes. This is the default style.
46 *
47 * For example, the set of scrambling options for Synchronous Optical Network
48 * (SONET) interfaces may be placed inside a "scrambling" container to enhance
49 * the organization of the configuration hierarchy, and to keep these nodes
50 * together. The "scrambling" node itself has no meaning, so removing the node
51 * when it becomes empty relieves the user from performing this task.
52 *
53 * In the second style, the presence of the container itself is configuration
54 * data, representing a single bit of configuration data. The container acts as
55 * both a configuration knob and a means of organizing related configuration.
56 * These containers are explicitly created and deleted.
57 *
58 * YANG calls this style a "presence container" and it is indicated using the
59 * "presence" statement, which takes as its argument a text string indicating
60 * what the presence of the node means.
61 *
62 * The container's Substatements
63 *
64 * +--------------+---------+-------------+------------------+
65 * | substatement | section | cardinality |data model mapping|
66 * +--------------+---------+-------------+------------------+
67 * | anyxml | 7.10 | 0..n | -not supported |
68 * | choice | 7.9 | 0..n | -child nodes |
69 * | config | 7.19.1 | 0..1 | -boolean |
70 * | container | 7.5 | 0..n | -child nodes |
71 * | description | 7.19.3 | 0..1 | -string |
72 * | grouping | 7.11 | 0..n | -child nodes |
Vidyashree Ramadeac28b2016-06-20 15:12:43 +053073 * | if-feature | 7.18.2 | 0..n | -YangIfFeature |
Vinod Kumar S67e7be62016-02-11 20:13:28 +053074 * | leaf | 7.6 | 0..n | -YangLeaf |
75 * | leaf-list | 7.7 | 0..n | -YangLeafList |
76 * | list | 7.8 | 0..n | -child nodes |
Vidyashree Ramadeac28b2016-06-20 15:12:43 +053077 * | must | 7.5.3 | 0..n | -YangMust |
Vinod Kumar S67e7be62016-02-11 20:13:28 +053078 * | presence | 7.5.5 | 0..1 | -boolean |
79 * | reference | 7.19.4 | 0..1 | -string |
80 * | status | 7.19.2 | 0..1 | -YangStatus |
81 * | typedef | 7.3 | 0..n | -child nodes |
82 * | uses | 7.12 | 0..n | -child nodes |
Vidyashree Ramadeac28b2016-06-20 15:12:43 +053083 * | when | 7.19.5 | 0..1 | -YangWhen |
Vinod Kumar S67e7be62016-02-11 20:13:28 +053084 * +--------------+---------+-------------+------------------+
85 */
86
87/**
Bharat saraswald9822e92016-04-05 15:13:44 +053088 * Represents data model node to maintain information defined in YANG container.
Vinod Kumar S67e7be62016-02-11 20:13:28 +053089 */
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +053090public class YangContainer
91 extends YangNode
Vidyashree Ramadeac28b2016-06-20 15:12:43 +053092 implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector, YangAugmentationHolder,
93 YangMustHolder, YangWhenHolder, YangIfFeatureHolder {
Vinod Kumar S67e7be62016-02-11 20:13:28 +053094
Bharat saraswal96dfef02016-06-16 00:29:12 +053095 private static final long serialVersionUID = 806201605L;
96
Vinod Kumar S67e7be62016-02-11 20:13:28 +053097 /**
98 * Name of the container.
99 */
100 private String name;
101
102 /**
103 * If container maintains config data.
104 */
Vidyashree Ramaf4c617c2016-02-24 12:28:22 +0530105 private Boolean isConfig;
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530106
107 /**
108 * Description of container.
109 */
110 private String description;
111
112 /**
113 * List of leaves contained.
114 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530115 private List<YangLeaf> listOfLeaf;
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530116
117 /**
118 * List of leaf-lists contained.
119 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530120 private List<YangLeafList> listOfLeafList;
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530121
122 /**
123 * If it is a presence container, then the textual documentation of presence
124 * usage.
125 */
126 private String presence;
127
128 /**
129 * Reference of the module.
130 */
131 private String reference;
132
133 /**
134 * Status of the node.
135 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530136 private YangStatusType status = YangStatusType.CURRENT;
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530137
138 /**
Vidyashree Ramadeac28b2016-06-20 15:12:43 +0530139 * List of must statement constraints.
140 */
141 private List<YangMust> mustConstraintList;
142
143 /**
144 * When data of the node.
145 */
146 private YangWhen when;
147
148 /**
149 * List of if-feature.
150 */
151 private List<YangIfFeature> ifFeatureList;
152
153 /**
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530154 * Create a container node.
155 */
156 public YangContainer() {
157 super(YangNodeType.CONTAINER_NODE);
158 }
159
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530160 /**
Vidyashree Ramadeac28b2016-06-20 15:12:43 +0530161 * Returns the when.
162 *
163 * @return the when
164 */
165 @Override
166 public YangWhen getWhen() {
167 return when;
168 }
169
170 /**
171 * Sets the when.
172 *
173 * @param when the when to set
174 */
175 @Override
176 public void setWhen(YangWhen when) {
177 this.when = when;
178 }
179
180 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530181 * Returns the YANG name of container.
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530182 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530183 * @return the name of container as defined in YANG file
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530184 */
185 @Override
186 public String getName() {
187 return name;
188 }
189
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530190 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530191 * Sets the YANG name of container.
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530192 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530193 * @param name the name of container as defined in YANG file
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530194 */
195 @Override
196 public void setName(String name) {
197 this.name = name;
198 }
199
200 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530201 * Returns the config flag.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530202 *
203 * @return the isConfig
204 */
Vidyashree Ramaf4c617c2016-02-24 12:28:22 +0530205 public Boolean isConfig() {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530206 return isConfig;
207 }
208
209 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530210 * Sets the config flag.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530211 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530212 * @param isCfg the config flag
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530213 */
214 public void setConfig(boolean isCfg) {
215 isConfig = isCfg;
216 }
217
218 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530219 * Returns the description.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530220 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530221 * @return the description
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530222 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530223 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530224 public String getDescription() {
225 return description;
226 }
227
228 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530229 * Sets the description.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530230 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530231 * @param description set the description
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530232 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530233 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530234 public void setDescription(String description) {
235 this.description = description;
236 }
237
238 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530239 * Returns the list of leaves.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530240 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530241 * @return the list of leaves
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530242 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530243 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530244 public List<YangLeaf> getListOfLeaf() {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530245 return listOfLeaf;
246 }
247
248 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530249 * Sets the list of leaves.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530250 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530251 * @param leafsList the list of leaf to set
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530252 */
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530253 @Override
254 public void setListOfLeaf(List<YangLeaf> leafsList) {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530255 listOfLeaf = leafsList;
256 }
257
258 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530259 * Adds a leaf.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530260 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530261 * @param leaf the leaf to be added
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530262 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530263 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530264 public void addLeaf(YangLeaf leaf) {
Bharat saraswald9822e92016-04-05 15:13:44 +0530265
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530266 if (getListOfLeaf() == null) {
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530267 setListOfLeaf(new LinkedList<YangLeaf>());
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530268 }
269
270 getListOfLeaf().add(leaf);
271 }
272
273 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530274 * Returns the list of leaf-list.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530275 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530276 * @return the list of leaf-list
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530277 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530278 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530279 public List<YangLeafList> getListOfLeafList() {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530280 return listOfLeafList;
281 }
282
283 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530284 * Sets the list of leaf-list.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530285 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530286 * @param listOfLeafList the list of leaf-list to set
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530287 */
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530288 @Override
289 public void setListOfLeafList(List<YangLeafList> listOfLeafList) {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530290 this.listOfLeafList = listOfLeafList;
291 }
292
293 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530294 * Adds a leaf-list.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530295 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530296 * @param leafList the leaf-list to be added
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530297 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530298 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530299 public void addLeafList(YangLeafList leafList) {
Bharat saraswald9822e92016-04-05 15:13:44 +0530300
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530301 if (getListOfLeafList() == null) {
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530302 setListOfLeafList(new LinkedList<YangLeafList>());
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530303 }
304
305 getListOfLeafList().add(leafList);
306 }
307
308 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530309 * Returns the presence string if present.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530310 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530311 * @return the presence
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530312 */
313 public String getPresence() {
314 return presence;
315 }
316
317 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530318 * Sets the presence string.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530319 *
320 * @param presence the presence flag
321 */
322 public void setPresence(String presence) {
323 this.presence = presence;
324 }
325
326 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530327 * Returns the textual reference.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530328 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530329 * @return the reference
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 String getReference() {
333 return reference;
334 }
335
336 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530337 * Sets the textual reference.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530338 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530339 * @param reference the reference to set
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530340 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530341 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530342 public void setReference(String reference) {
343 this.reference = reference;
344 }
345
346 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530347 * Returns the status.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530348 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530349 * @return the status
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530350 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530351 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530352 public YangStatusType getStatus() {
353 return status;
354 }
355
356 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530357 * Sets the status.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530358 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530359 * @param status the status to set
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530360 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530361 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530362 public void setStatus(YangStatusType status) {
363 this.status = status;
364 }
365
366 /**
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530367 * Returns the type of the data.
368 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530369 * @return returns CONTAINER_DATA
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530370 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530371 @Override
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530372 public YangConstructType getYangConstructType() {
373 return YangConstructType.CONTAINER_DATA;
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530374 }
375
376 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530377 * Validates the data on entering the corresponding parse tree node.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530378 *
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
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530382 public void validateDataOnEntry()
383 throws DataModelException {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530384 // TODO auto-generated method stub, to be implemented by parser
385 }
386
387 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530388 * Validates the data on exiting the corresponding parse tree node.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530389 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530390 * @throws DataModelException a violation of data model rules
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530391 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530392 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530393 public void validateDataOnExit()
394 throws DataModelException {
Vidyashree Ramaf4c617c2016-02-24 12:28:22 +0530395 List<YangLeaf> leaves = getListOfLeaf();
396 List<YangLeafList> leafLists = getListOfLeafList();
397
398 setDefaultConfigValueToChild(leaves, leafLists);
399 validateConfig(leaves, leafLists);
400 }
401
402 /**
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530403 * Sets the config's value to all leaf if leaf's config statement is not
404 * specified.
Vidyashree Ramaf4c617c2016-02-24 12:28:22 +0530405 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530406 * @param leaves list of leaf attributes of container
407 * @param leafLists list of leaf-list attributes of container
Vidyashree Ramaf4c617c2016-02-24 12:28:22 +0530408 */
409 private void setDefaultConfigValueToChild(List<YangLeaf> leaves, List<YangLeafList> leafLists) {
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 (leaves != null) {
416 for (YangLeaf leaf : leaves) {
417 if (leaf.isConfig() == null) {
418 leaf.setConfig(isConfig);
419 }
420 }
421 }
422
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530423 /*
424 * If "config" is not specified, the default is the same as the parent
425 * schema node's "config" value.
426 */
Vidyashree Ramaf4c617c2016-02-24 12:28:22 +0530427 if (leafLists != null) {
428 for (YangLeafList leafList : leafLists) {
429 if (leafList.isConfig() == null) {
430 leafList.setConfig(isConfig);
431 }
432 }
433 }
434 }
435
436 /**
437 * Validates config statement of container.
438 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530439 * @param leaves list of leaf attributes of container
440 * @param leafLists list of leaf-list attributes of container
441 * @throws DataModelException a violation of data model rules
Vidyashree Ramaf4c617c2016-02-24 12:28:22 +0530442 */
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530443 private void validateConfig(List<YangLeaf> leaves, List<YangLeafList> leafLists)
444 throws DataModelException {
Vidyashree Ramaf4c617c2016-02-24 12:28:22 +0530445
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530446 /*
447 * If a node has "config" set to "false", no node underneath it can have
448 * "config" set to "true".
449 */
Vinod Kumar S38046502016-03-23 15:30:27 +0530450 if (!isConfig && leaves != null) {
Vidyashree Ramaf4c617c2016-02-24 12:28:22 +0530451 for (YangLeaf leaf : leaves) {
452 if (leaf.isConfig()) {
453 throw new DataModelException("If a container has \"config\" set to \"false\", no node underneath " +
454 "it can have \"config\" set to \"true\".");
455 }
456 }
457 }
458
Vinod Kumar S38046502016-03-23 15:30:27 +0530459 if (!isConfig && leafLists != null) {
Vidyashree Ramaf4c617c2016-02-24 12:28:22 +0530460 for (YangLeafList leafList : leafLists) {
461 if (leafList.isConfig()) {
462 throw new DataModelException("If a container has \"config\" set to \"false\", no node underneath " +
463 "it can have \"config\" set to \"true\".");
464 }
465 }
466 }
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530467 }
468
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530469 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530470 public void detectCollidingChild(String identifierName, YangConstructType dataType)
471 throws DataModelException {
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530472 // Asks helper to detect colliding child.
473 detectCollidingChildUtil(identifierName, dataType, this);
474 }
475
476 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530477 public void detectSelfCollision(String identifierName, YangConstructType dataType)
478 throws DataModelException {
Vinod Kumar S38046502016-03-23 15:30:27 +0530479 if (getName().equals(identifierName)) {
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530480 throw new DataModelException("YANG file error: Duplicate input identifier detected, same as container \""
Vinod Kumar S38046502016-03-23 15:30:27 +0530481 + getName() + "\"");
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530482 }
483 }
Vidyashree Ramadeac28b2016-06-20 15:12:43 +0530484
485 @Override
486 public List<YangIfFeature> getIfFeatureList() {
487 return ifFeatureList;
488 }
489
490 @Override
491 public void addIfFeatureList(YangIfFeature ifFeature) {
492 if (getIfFeatureList() == null) {
493 setIfFeatureList(new LinkedList<>());
494 }
495 getIfFeatureList().add(ifFeature);
496 }
497
498 @Override
499 public void setIfFeatureList(List<YangIfFeature> ifFeatureList) {
500 this.ifFeatureList = ifFeatureList;
501 }
502
503 @Override
504 public List<YangMust> getListOfMust() {
505 return mustConstraintList;
506 }
507
508 @Override
509 public void setListOfMust(List<YangMust> mustConstraintList) {
510 this.mustConstraintList = mustConstraintList;
511 }
512
513 @Override
514 public void addMust(YangMust must) {
515 if (getListOfMust() == null) {
516 setListOfMust(new LinkedList<>());
517 }
518 getListOfMust().add(must);
519 }
520
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530521}