blob: 65261cc0887dff32487ad6c94f132ab13a2e20ed [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
Bharat saraswalb1170bd2016-07-14 13:26:18 +053019import java.util.ArrayList;
Vinod Kumar S67e7be62016-02-11 20:13:28 +053020import java.util.LinkedList;
21import java.util.List;
22
23import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
Bharat saraswal96dfef02016-06-16 00:29:12 +053024import org.onosproject.yangutils.datamodel.utils.Parsable;
25import org.onosproject.yangutils.datamodel.utils.YangConstructType;
Vinod Kumar S38046502016-03-23 15:30:27 +053026
27import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil;
28
Vinod Kumar S67e7be62016-02-11 20:13:28 +053029/*-
30 * Reference RFC 6020.
31 *
32 * The "container" statement is used to define an interior data node in the
33 * schema tree. It takes one argument, which is an identifier, followed by a
34 * block of sub-statements that holds detailed container information.
35 *
36 * A container node does not have a value, but it has a list of child nodes in
37 * the data tree. The child nodes are defined in the container's sub-statements.
38 *
39 * Containers with Presence
40 *
41 * YANG supports two styles of containers, those that exist only for organizing
42 * the hierarchy of data nodes, and those whose presence in the configuration
43 * has an explicit meaning.
44 *
45 * In the first style, the container has no meaning of its own, existing only to
46 * contain child nodes. This is the default style.
47 *
48 * For example, the set of scrambling options for Synchronous Optical Network
49 * (SONET) interfaces may be placed inside a "scrambling" container to enhance
50 * the organization of the configuration hierarchy, and to keep these nodes
51 * together. The "scrambling" node itself has no meaning, so removing the node
52 * when it becomes empty relieves the user from performing this task.
53 *
54 * In the second style, the presence of the container itself is configuration
55 * data, representing a single bit of configuration data. The container acts as
56 * both a configuration knob and a means of organizing related configuration.
57 * These containers are explicitly created and deleted.
58 *
59 * YANG calls this style a "presence container" and it is indicated using the
60 * "presence" statement, which takes as its argument a text string indicating
61 * what the presence of the node means.
62 *
63 * The container's Substatements
64 *
65 * +--------------+---------+-------------+------------------+
66 * | substatement | section | cardinality |data model mapping|
67 * +--------------+---------+-------------+------------------+
68 * | anyxml | 7.10 | 0..n | -not supported |
69 * | choice | 7.9 | 0..n | -child nodes |
70 * | config | 7.19.1 | 0..1 | -boolean |
71 * | container | 7.5 | 0..n | -child nodes |
72 * | description | 7.19.3 | 0..1 | -string |
73 * | grouping | 7.11 | 0..n | -child nodes |
Vidyashree Ramadeac28b2016-06-20 15:12:43 +053074 * | if-feature | 7.18.2 | 0..n | -YangIfFeature |
Vinod Kumar S67e7be62016-02-11 20:13:28 +053075 * | leaf | 7.6 | 0..n | -YangLeaf |
76 * | leaf-list | 7.7 | 0..n | -YangLeafList |
77 * | list | 7.8 | 0..n | -child nodes |
Vidyashree Ramadeac28b2016-06-20 15:12:43 +053078 * | must | 7.5.3 | 0..n | -YangMust |
Vinod Kumar S67e7be62016-02-11 20:13:28 +053079 * | presence | 7.5.5 | 0..1 | -boolean |
80 * | reference | 7.19.4 | 0..1 | -string |
81 * | status | 7.19.2 | 0..1 | -YangStatus |
82 * | typedef | 7.3 | 0..n | -child nodes |
83 * | uses | 7.12 | 0..n | -child nodes |
Vidyashree Ramadeac28b2016-06-20 15:12:43 +053084 * | when | 7.19.5 | 0..1 | -YangWhen |
Vinod Kumar S67e7be62016-02-11 20:13:28 +053085 * +--------------+---------+-------------+------------------+
86 */
87
88/**
Bharat saraswald9822e92016-04-05 15:13:44 +053089 * Represents data model node to maintain information defined in YANG container.
Vinod Kumar S67e7be62016-02-11 20:13:28 +053090 */
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +053091public class YangContainer
92 extends YangNode
Bharat saraswalb1170bd2016-07-14 13:26:18 +053093 implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector,
94 YangAugmentableNode, YangMustHolder, YangWhenHolder, YangIfFeatureHolder {
Vinod Kumar S67e7be62016-02-11 20:13:28 +053095
Bharat saraswal96dfef02016-06-16 00:29:12 +053096 private static final long serialVersionUID = 806201605L;
97
Vinod Kumar S67e7be62016-02-11 20:13:28 +053098 /**
99 * Name of the container.
100 */
101 private String name;
102
103 /**
104 * If container maintains config data.
105 */
Vidyashree Ramaf4c617c2016-02-24 12:28:22 +0530106 private Boolean isConfig;
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530107
108 /**
109 * Description of container.
110 */
111 private String description;
112
113 /**
114 * List of leaves contained.
115 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530116 private List<YangLeaf> listOfLeaf;
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530117
118 /**
119 * List of leaf-lists contained.
120 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530121 private List<YangLeafList> listOfLeafList;
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530122
123 /**
124 * If it is a presence container, then the textual documentation of presence
125 * usage.
126 */
127 private String presence;
128
129 /**
130 * Reference of the module.
131 */
132 private String reference;
133
Bharat saraswalb1170bd2016-07-14 13:26:18 +0530134 private List<YangAugmentedInfo> yangAugmentedInfo = new ArrayList<>();
135
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530136 /**
137 * Status of the node.
138 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530139 private YangStatusType status = YangStatusType.CURRENT;
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530140
141 /**
Vidyashree Ramadeac28b2016-06-20 15:12:43 +0530142 * List of must statement constraints.
143 */
144 private List<YangMust> mustConstraintList;
145
146 /**
147 * When data of the node.
148 */
149 private YangWhen when;
150
151 /**
152 * List of if-feature.
153 */
154 private List<YangIfFeature> ifFeatureList;
155
156 /**
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530157 * Create a container node.
158 */
159 public YangContainer() {
160 super(YangNodeType.CONTAINER_NODE);
161 }
162
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530163 /**
Vidyashree Ramadeac28b2016-06-20 15:12:43 +0530164 * Returns the when.
165 *
166 * @return the when
167 */
168 @Override
169 public YangWhen getWhen() {
170 return when;
171 }
172
173 /**
174 * Sets the when.
175 *
176 * @param when the when to set
177 */
178 @Override
179 public void setWhen(YangWhen when) {
180 this.when = when;
181 }
182
183 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530184 * Returns the YANG name of container.
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530185 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530186 * @return the name of container as defined in YANG file
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530187 */
188 @Override
189 public String getName() {
190 return name;
191 }
192
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530193 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530194 * Sets the YANG name of container.
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530195 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530196 * @param name the name of container as defined in YANG file
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530197 */
198 @Override
199 public void setName(String name) {
200 this.name = name;
201 }
202
203 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530204 * Returns the config flag.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530205 *
206 * @return the isConfig
207 */
Vidyashree Ramaf4c617c2016-02-24 12:28:22 +0530208 public Boolean isConfig() {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530209 return isConfig;
210 }
211
212 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530213 * Sets the config flag.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530214 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530215 * @param isCfg the config flag
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530216 */
217 public void setConfig(boolean isCfg) {
218 isConfig = isCfg;
219 }
220
221 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530222 * Returns the description.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530223 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530224 * @return the description
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530225 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530226 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530227 public String getDescription() {
228 return description;
229 }
230
231 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530232 * Sets the description.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530233 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530234 * @param description set the description
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530235 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530236 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530237 public void setDescription(String description) {
238 this.description = description;
239 }
240
241 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530242 * Returns the list of leaves.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530243 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530244 * @return the list of leaves
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530245 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530246 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530247 public List<YangLeaf> getListOfLeaf() {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530248 return listOfLeaf;
249 }
250
251 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530252 * Sets the list of leaves.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530253 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530254 * @param leafsList the list of leaf to set
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530255 */
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530256 @Override
257 public void setListOfLeaf(List<YangLeaf> leafsList) {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530258 listOfLeaf = leafsList;
259 }
260
261 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530262 * Adds a leaf.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530263 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530264 * @param leaf the leaf to be added
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530265 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530266 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530267 public void addLeaf(YangLeaf leaf) {
Bharat saraswald9822e92016-04-05 15:13:44 +0530268
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530269 if (getListOfLeaf() == null) {
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530270 setListOfLeaf(new LinkedList<YangLeaf>());
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530271 }
272
273 getListOfLeaf().add(leaf);
274 }
275
276 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530277 * Returns the list of leaf-list.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530278 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530279 * @return the list of leaf-list
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530280 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530281 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530282 public List<YangLeafList> getListOfLeafList() {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530283 return listOfLeafList;
284 }
285
286 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530287 * Sets the list of leaf-list.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530288 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530289 * @param listOfLeafList the list of leaf-list to set
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530290 */
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530291 @Override
292 public void setListOfLeafList(List<YangLeafList> listOfLeafList) {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530293 this.listOfLeafList = listOfLeafList;
294 }
295
296 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530297 * Adds a leaf-list.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530298 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530299 * @param leafList the leaf-list to be added
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530300 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530301 @Override
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530302 public void addLeafList(YangLeafList leafList) {
Bharat saraswald9822e92016-04-05 15:13:44 +0530303
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530304 if (getListOfLeafList() == null) {
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530305 setListOfLeafList(new LinkedList<YangLeafList>());
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530306 }
307
308 getListOfLeafList().add(leafList);
309 }
310
311 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530312 * Returns the presence string if present.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530313 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530314 * @return the presence
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530315 */
316 public String getPresence() {
317 return presence;
318 }
319
320 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530321 * Sets the presence string.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530322 *
323 * @param presence the presence flag
324 */
325 public void setPresence(String presence) {
326 this.presence = presence;
327 }
328
329 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530330 * Returns the textual reference.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530331 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530332 * @return the reference
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530333 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530334 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530335 public String getReference() {
336 return reference;
337 }
338
339 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530340 * Sets the textual reference.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530341 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530342 * @param reference the reference to set
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530343 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530344 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530345 public void setReference(String reference) {
346 this.reference = reference;
347 }
348
349 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530350 * Returns the status.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530351 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530352 * @return the status
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530353 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530354 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530355 public YangStatusType getStatus() {
356 return status;
357 }
358
359 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530360 * Sets the status.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530361 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530362 * @param status the status to set
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530363 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530364 @Override
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530365 public void setStatus(YangStatusType status) {
366 this.status = status;
367 }
368
369 /**
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530370 * Returns the type of the data.
371 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530372 * @return returns CONTAINER_DATA
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530373 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530374 @Override
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530375 public YangConstructType getYangConstructType() {
376 return YangConstructType.CONTAINER_DATA;
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530377 }
378
379 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530380 * Validates the data on entering the corresponding parse tree node.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530381 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530382 * @throws DataModelException a violation of data model rules
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530383 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530384 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530385 public void validateDataOnEntry()
386 throws DataModelException {
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530387 // TODO auto-generated method stub, to be implemented by parser
388 }
389
390 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530391 * Validates the data on exiting the corresponding parse tree node.
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530392 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530393 * @throws DataModelException a violation of data model rules
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530394 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530395 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530396 public void validateDataOnExit()
397 throws DataModelException {
Vidyashree Ramaf4c617c2016-02-24 12:28:22 +0530398 List<YangLeaf> leaves = getListOfLeaf();
399 List<YangLeafList> leafLists = getListOfLeafList();
400
401 setDefaultConfigValueToChild(leaves, leafLists);
402 validateConfig(leaves, leafLists);
403 }
404
405 /**
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530406 * Sets the config's value to all leaf if leaf's config statement is not
407 * specified.
Vidyashree Ramaf4c617c2016-02-24 12:28:22 +0530408 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530409 * @param leaves list of leaf attributes of container
410 * @param leafLists list of leaf-list attributes of container
Vidyashree Ramaf4c617c2016-02-24 12:28:22 +0530411 */
412 private void setDefaultConfigValueToChild(List<YangLeaf> leaves, List<YangLeafList> leafLists) {
413
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530414 /*
415 * If "config" is not specified, the default is the same as the parent
416 * schema node's "config" value.
417 */
Vidyashree Ramaf4c617c2016-02-24 12:28:22 +0530418 if (leaves != null) {
419 for (YangLeaf leaf : leaves) {
420 if (leaf.isConfig() == null) {
421 leaf.setConfig(isConfig);
422 }
423 }
424 }
425
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530426 /*
427 * If "config" is not specified, the default is the same as the parent
428 * schema node's "config" value.
429 */
Vidyashree Ramaf4c617c2016-02-24 12:28:22 +0530430 if (leafLists != null) {
431 for (YangLeafList leafList : leafLists) {
432 if (leafList.isConfig() == null) {
433 leafList.setConfig(isConfig);
434 }
435 }
436 }
437 }
438
439 /**
440 * Validates config statement of container.
441 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530442 * @param leaves list of leaf attributes of container
443 * @param leafLists list of leaf-list attributes of container
444 * @throws DataModelException a violation of data model rules
Vidyashree Ramaf4c617c2016-02-24 12:28:22 +0530445 */
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530446 private void validateConfig(List<YangLeaf> leaves, List<YangLeafList> leafLists)
447 throws DataModelException {
Vidyashree Ramaf4c617c2016-02-24 12:28:22 +0530448
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530449 /*
450 * If a node has "config" set to "false", no node underneath it can have
451 * "config" set to "true".
452 */
Vinod Kumar S38046502016-03-23 15:30:27 +0530453 if (!isConfig && leaves != null) {
Vidyashree Ramaf4c617c2016-02-24 12:28:22 +0530454 for (YangLeaf leaf : leaves) {
455 if (leaf.isConfig()) {
456 throw new DataModelException("If a container has \"config\" set to \"false\", no node underneath " +
457 "it can have \"config\" set to \"true\".");
458 }
459 }
460 }
461
Vinod Kumar S38046502016-03-23 15:30:27 +0530462 if (!isConfig && leafLists != null) {
Vidyashree Ramaf4c617c2016-02-24 12:28:22 +0530463 for (YangLeafList leafList : leafLists) {
464 if (leafList.isConfig()) {
465 throw new DataModelException("If a container has \"config\" set to \"false\", no node underneath " +
466 "it can have \"config\" set to \"true\".");
467 }
468 }
469 }
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530470 }
471
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530472 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530473 public void detectCollidingChild(String identifierName, YangConstructType dataType)
474 throws DataModelException {
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530475 // Asks helper to detect colliding child.
476 detectCollidingChildUtil(identifierName, dataType, this);
477 }
478
479 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530480 public void detectSelfCollision(String identifierName, YangConstructType dataType)
481 throws DataModelException {
Vinod Kumar S38046502016-03-23 15:30:27 +0530482 if (getName().equals(identifierName)) {
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530483 throw new DataModelException("YANG file error: Duplicate input identifier detected, same as container \""
Vinod Kumar S38046502016-03-23 15:30:27 +0530484 + getName() + "\"");
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530485 }
486 }
Vidyashree Ramadeac28b2016-06-20 15:12:43 +0530487
488 @Override
489 public List<YangIfFeature> getIfFeatureList() {
490 return ifFeatureList;
491 }
492
493 @Override
494 public void addIfFeatureList(YangIfFeature ifFeature) {
495 if (getIfFeatureList() == null) {
496 setIfFeatureList(new LinkedList<>());
497 }
498 getIfFeatureList().add(ifFeature);
499 }
500
501 @Override
502 public void setIfFeatureList(List<YangIfFeature> ifFeatureList) {
503 this.ifFeatureList = ifFeatureList;
504 }
505
506 @Override
507 public List<YangMust> getListOfMust() {
508 return mustConstraintList;
509 }
510
511 @Override
512 public void setListOfMust(List<YangMust> mustConstraintList) {
513 this.mustConstraintList = mustConstraintList;
514 }
515
516 @Override
517 public void addMust(YangMust must) {
518 if (getListOfMust() == null) {
519 setListOfMust(new LinkedList<>());
520 }
521 getListOfMust().add(must);
522 }
523
Bharat saraswalb1170bd2016-07-14 13:26:18 +0530524 @Override
525 public void addAugmentation(YangAugmentedInfo augmentInfo) {
526 yangAugmentedInfo.add(augmentInfo);
527 }
528
529 @Override
530 public void removeAugmentation(YangAugmentedInfo augmentInfo) {
531 yangAugmentedInfo.remove(augmentInfo);
532 }
533
534 @Override
535 public List<YangAugmentedInfo> getAugmentedInfoList() {
536 return yangAugmentedInfo;
537 }
Vinod Kumar S67e7be62016-02-11 20:13:28 +0530538}