blob: b0d9ed9008e82974c9a6fa164ff767e0ba9d8542 [file] [log] [blame]
Vinod Kumar S2ff139c2016-02-16 01:37:16 +05301/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Vinod Kumar S2ff139c2016-02-16 01:37:16 +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
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +053018import java.util.LinkedList;
19import java.util.List;
Bharat saraswal96dfef02016-06-16 00:29:12 +053020
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053021import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
Bharat saraswal96dfef02016-06-16 00:29:12 +053022import org.onosproject.yangutils.datamodel.utils.Parsable;
23import org.onosproject.yangutils.datamodel.utils.ResolvableStatus;
24import org.onosproject.yangutils.datamodel.utils.YangConstructType;
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053025
janani b4e53f9b2016-04-26 18:49:20 +053026import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil;
Bharat saraswal96dfef02016-06-16 00:29:12 +053027import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.getParentNodeInGenCode;
Vinod Kumar S427d2932016-04-20 13:02:58 +053028
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053029/*-
30 * Reference RFC 6020.
31 *
32 * The "uses" statement is used to reference a "grouping" definition. It takes
33 * one argument, which is the name of the grouping.
34 *
35 * The effect of a "uses" reference to a grouping is that the nodes defined by
36 * the grouping are copied into the current schema tree, and then updated
37 * according to the "refine" and "augment" statements.
38 *
39 * The identifiers defined in the grouping are not bound to a namespace until
40 * the contents of the grouping are added to the schema tree via a "uses"
41 * statement that does not appear inside a "grouping" statement, at which point
42 * they are bound to the namespace of the current module.
43 *
44 * The uses's sub-statements
45 *
46 * +--------------+---------+-------------+------------------+
47 * | substatement | section | cardinality |data model mapping|
48 * +--------------+---------+-------------+------------------+
49 * | augment | 7.15 | 0..1 | -child nodes |
50 * | description | 7.19.3 | 0..1 | -string |
51 * | if-feature | 7.18.2 | 0..n | -TODO |
52 * | refine | 7.12.2 | 0..1 | -TODO |
53 * | reference | 7.19.4 | 0..1 | -string |
54 * | status | 7.19.2 | 0..1 | -YangStatus |
55 * | when | 7.19.5 | 0..1 | -TODO |
56 * +--------------+---------+-------------+------------------+
57 */
Vinod Kumar Sd4deb062016-04-15 18:08:57 +053058
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053059/**
Bharat saraswald9822e92016-04-05 15:13:44 +053060 * Represents data model node to maintain information defined in YANG uses.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053061 */
Vinod Kumar Sd4deb062016-04-15 18:08:57 +053062public class YangUses
63 extends YangNode
janani b4e53f9b2016-04-26 18:49:20 +053064 implements YangCommonInfo, Parsable, Resolvable, CollisionDetector {
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053065
Bharat saraswal96dfef02016-06-16 00:29:12 +053066 private static final long serialVersionUID = 806201617L;
67
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053068 /**
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +053069 * YANG node identifier.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053070 */
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +053071 private YangNodeIdentifier nodeIdentifier;
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053072
73 /**
Gaurav Agrawalbd804472016-03-25 11:25:36 +053074 * Referred group.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053075 */
76 private YangGrouping refGroup;
77
78 /**
Gaurav Agrawalbd804472016-03-25 11:25:36 +053079 * Description of YANG uses.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053080 */
81 private String description;
82
83 /**
84 * YANG reference.
85 */
86 private String reference;
87
88 /**
Gaurav Agrawalbd804472016-03-25 11:25:36 +053089 * Status of YANG uses.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053090 */
91 private YangStatusType status;
92
93 /**
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +053094 * Status of resolution. If completely resolved enum value is "RESOLVED",
95 * if not enum value is "UNRESOLVED", in case reference of grouping/typedef
96 * is added to uses/type but it's not resolved value of enum should be
Vinod Kumar Sd4deb062016-04-15 18:08:57 +053097 * "INTRA_FILE_RESOLVED".
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +053098 */
99 private ResolvableStatus resolvableStatus;
100
101 /**
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530102 * Effective list of nodes of grouping that needs to replicated at YANG uses.
103 */
Bharat saraswal96dfef02016-06-16 00:29:12 +0530104 private List<YangNode> resolvedGroupingNodes;
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530105
106 /**
107 * Effective list of leaves of grouping that needs to replicated at YANG uses.
108 */
Bharat saraswal96dfef02016-06-16 00:29:12 +0530109 private List<List<YangLeaf>> resolvedGroupingLeaves;
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530110
111 /**
112 * Effective list of leaf lists of grouping that needs to replicated at YANG uses.
113 */
Bharat saraswal96dfef02016-06-16 00:29:12 +0530114 private List<List<YangLeafList>> resolvedGroupingLeafLists;
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530115
116 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530117 * Creates an YANG uses node.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530118 */
119 public YangUses() {
120 super(YangNodeType.USES_NODE);
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530121 nodeIdentifier = new YangNodeIdentifier();
122 resolvableStatus = ResolvableStatus.UNRESOLVED;
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530123 resolvedGroupingNodes = new LinkedList<YangNode>();
124 resolvedGroupingLeaves = new LinkedList<List<YangLeaf>>();
125 resolvedGroupingLeafLists = new LinkedList<List<YangLeafList>>();
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530126 }
127
128 /**
Gaurav Agrawalbd804472016-03-25 11:25:36 +0530129 * Returns the referred group.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530130 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530131 * @return the referred group
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530132 */
133 public YangGrouping getRefGroup() {
134 return refGroup;
135 }
136
137 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530138 * Sets the referred group.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530139 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530140 * @param refGroup the referred group
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530141 */
142 public void setRefGroup(YangGrouping refGroup) {
143 this.refGroup = refGroup;
144 }
145
146 /**
Gaurav Agrawalbd804472016-03-25 11:25:36 +0530147 * Returns the description.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530148 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530149 * @return the description
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530150 */
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530151 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530152 public String getDescription() {
153 return description;
154 }
155
156 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530157 * Sets the description.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530158 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530159 * @param description set the description
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530160 */
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530161 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530162 public void setDescription(String description) {
163 this.description = description;
164 }
165
166 /**
Gaurav Agrawalbd804472016-03-25 11:25:36 +0530167 * Returns the textual reference.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530168 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530169 * @return the reference
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530170 */
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530171 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530172 public String getReference() {
173 return reference;
174 }
175
176 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530177 * Sets the textual reference.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530178 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530179 * @param reference the reference to set
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530180 */
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530181 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530182 public void setReference(String reference) {
183 this.reference = reference;
184 }
185
186 /**
Gaurav Agrawalbd804472016-03-25 11:25:36 +0530187 * Returns the status.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530188 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530189 * @return the status
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530190 */
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530191 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530192 public YangStatusType getStatus() {
193 return status;
194 }
195
196 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530197 * Sets the status.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530198 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530199 * @param status the status to set
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530200 */
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530201 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530202 public void setStatus(YangStatusType status) {
203 this.status = status;
204 }
205
206 /**
207 * Returns the type of the data.
208 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530209 * @return returns USES_DATA
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530210 */
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530211 @Override
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530212 public YangConstructType getYangConstructType() {
213 return YangConstructType.USES_DATA;
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530214 }
215
216 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530217 * Validates the data on entering the corresponding parse tree node.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530218 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530219 * @throws DataModelException a violation of data model rules
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530220 */
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530221 @Override
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530222 public void validateDataOnEntry()
223 throws DataModelException {
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530224 // TODO auto-generated method stub, to be implemented by parser
225 }
226
227 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530228 * Validates the data on exiting the corresponding parse tree node.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530229 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530230 * @throws DataModelException a violation of data model rules
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530231 */
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530232 @Override
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530233 public void validateDataOnExit()
234 throws DataModelException {
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530235 // TODO auto-generated method stub, to be implemented by parser
236 }
237
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530238 @Override
239 public String getName() {
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530240 return nodeIdentifier.getName();
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530241 }
242
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530243 @Override
244 public void setName(String name) {
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530245 nodeIdentifier.setName(name);
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530246 }
247
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530248 /**
249 * Returns node identifier.
250 *
251 * @return node identifier
252 */
253 public YangNodeIdentifier getNodeIdentifier() {
254 return nodeIdentifier;
255 }
256
257 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530258 * Sets node identifier.
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530259 *
260 * @param nodeIdentifier the node identifier
261 */
262 public void setNodeIdentifier(YangNodeIdentifier nodeIdentifier) {
263 this.nodeIdentifier = nodeIdentifier;
264 }
265
266 /**
267 * Returns prefix associated with uses.
268 *
269 * @return prefix associated with uses
270 */
271 public String getPrefix() {
272 return nodeIdentifier.getPrefix();
273 }
274
275 /**
276 * Get prefix associated with uses.
277 *
278 * @param prefix prefix associated with uses
279 */
280 public void setPrefix(String prefix) {
281 nodeIdentifier.setPrefix(prefix);
282 }
283
284 @Override
Vinod Kumar S427d2932016-04-20 13:02:58 +0530285 public void resolve()
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530286 throws DataModelException {
Vinod Kumar S427d2932016-04-20 13:02:58 +0530287
288 YangGrouping referredGrouping = getRefGroup();
289
290 if (referredGrouping == null) {
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530291 throw new DataModelException("YANG uses linker error, cannot resolve uses");
Vinod Kumar S427d2932016-04-20 13:02:58 +0530292 }
293
294 YangNode usesParentNode = getParentNodeInGenCode(this);
Bharat saraswalcad0e652016-05-26 23:48:38 +0530295 if (!(usesParentNode instanceof YangLeavesHolder)
296 || !(usesParentNode instanceof CollisionDetector)) {
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530297 throw new DataModelException("YANG uses holder construct is wrong");
Vinod Kumar S427d2932016-04-20 13:02:58 +0530298 }
299
300 YangLeavesHolder usesParentLeavesHolder = (YangLeavesHolder) usesParentNode;
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530301 if (referredGrouping.getListOfLeaf() != null
302 && referredGrouping.getListOfLeaf().size() != 0) {
303 addLeavesOfGrouping(
304 cloneLeavesList(referredGrouping.getListOfLeaf(),
305 usesParentLeavesHolder));
Vinod Kumar S427d2932016-04-20 13:02:58 +0530306 }
307
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530308 if (referredGrouping.getListOfLeafList() != null
309 && referredGrouping.getListOfLeafList().size() != 0) {
310 addListOfLeafListOfGrouping(
311 cloneListOfLeafList(referredGrouping.getListOfLeafList(),
312 usesParentLeavesHolder));
313 }
314
315 YangNode childInGrouping = referredGrouping.getChild();
316
317 while (childInGrouping != null) {
Bharat saraswal96dfef02016-06-16 00:29:12 +0530318 if (childInGrouping instanceof YangEnumeration
319 || childInGrouping instanceof YangUnion
320 || childInGrouping instanceof YangTypeDef) {
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530321
322 /*
Bharat saraswal96dfef02016-06-16 00:29:12 +0530323 * No need to copy the leaves, union / enum class, as these will
324 * be generated in the scope of grouping
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530325 */
326 childInGrouping = childInGrouping.getNextSibling();
327 continue;
Bharat saraswal96dfef02016-06-16 00:29:12 +0530328 } else if (childInGrouping instanceof YangUses) {
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530329 addResolvedUsesInfoOfGrouping((YangUses) childInGrouping,
330 usesParentLeavesHolder);
331 } else {
332 addNodeOfGrouping(childInGrouping);
333 }
334
335 childInGrouping = childInGrouping.getNextSibling();
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +0530336 }
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530337 }
338
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530339 /**
340 * Clone the resolved uses contained in grouping to the uses of grouping.
341 *
342 * @param usesInGrouping resolved uses in grouping
343 * @param usesHolder holder of uses
344 */
345 private void addResolvedUsesInfoOfGrouping(YangUses usesInGrouping,
Bharat saraswal96dfef02016-06-16 00:29:12 +0530346 YangLeavesHolder usesHolder) throws DataModelException {
347 for (YangNode usesResolvedNode : usesInGrouping.getUsesResolvedNodeList()) {
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530348 addNodeOfGrouping(usesResolvedNode);
349 }
350
Bharat saraswal96dfef02016-06-16 00:29:12 +0530351 for (List<YangLeaf> leavesList : usesInGrouping.getUsesResolvedLeavesList()) {
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530352 addLeavesOfGrouping(cloneLeavesList(leavesList, usesHolder));
353 }
354
Bharat saraswal96dfef02016-06-16 00:29:12 +0530355 for (List<YangLeafList> listOfLeafLists : usesInGrouping.getUsesResolvedListOfLeafList()) {
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530356 addListOfLeafListOfGrouping(
357 cloneListOfLeafList(listOfLeafLists, usesHolder));
358 }
359 }
360
361 /**
362 * Clone the list of leaves and return the cloned list leaves.
363 *
364 * @param listOfLeaves list of leaves to be cloned
365 * @param usesParentNode parent of the cloned location
366 * @return cloned list of leaves
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530367 * @throws DataModelException a violation in data model rule
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530368 */
369 private List<YangLeaf> cloneLeavesList(List<YangLeaf> listOfLeaves,
Bharat saraswal96dfef02016-06-16 00:29:12 +0530370 YangLeavesHolder usesParentNode) throws DataModelException {
371 if (listOfLeaves == null || listOfLeaves.size() == 0) {
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530372 throw new DataModelException("No leaves to clone");
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530373 }
374
375 List<YangLeaf> newLeavesList = new LinkedList<YangLeaf>();
376 for (YangLeaf leaf : listOfLeaves) {
377 YangLeaf clonedLeaf;
378 try {
379 ((CollisionDetector) usesParentNode).detectCollidingChild(leaf.getName(),
380 YangConstructType.LEAF_DATA);
381 clonedLeaf = leaf.clone();
382 } catch (CloneNotSupportedException | DataModelException e) {
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530383 throw new DataModelException(e.getMessage());
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530384 }
385
386 clonedLeaf.setContainedIn(usesParentNode);
387 newLeavesList.add(clonedLeaf);
388 }
389
390 return newLeavesList;
391 }
392
393 /**
394 * Clone the list of leaf list.
395 *
396 * @param listOfLeafList list of leaf list that needs to be cloned
397 * @param usesParentNode parent of uses
398 * @return cloned list of leaf list
399 */
400 private List<YangLeafList> cloneListOfLeafList(List<YangLeafList> listOfLeafList,
Bharat saraswal96dfef02016-06-16 00:29:12 +0530401 YangLeavesHolder usesParentNode) throws DataModelException {
402 if (listOfLeafList == null || listOfLeafList.size() == 0) {
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530403 throw new DataModelException("No leaf lists to clone");
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530404 }
405
406 List<YangLeafList> newListOfLeafList = new LinkedList<YangLeafList>();
407 for (YangLeafList leafList : listOfLeafList) {
408 YangLeafList clonedLeafList;
409 try {
410 ((CollisionDetector) usesParentNode).detectCollidingChild(leafList.getName(),
411 YangConstructType.LEAF_LIST_DATA);
412 clonedLeafList = leafList.clone();
413 } catch (CloneNotSupportedException | DataModelException e) {
Gaurav Agrawal95b416c2016-06-07 14:00:26 +0530414 throw new DataModelException(e.getMessage());
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530415 }
416
417 clonedLeafList.setContainedIn(usesParentNode);
418 newListOfLeafList.add(clonedLeafList);
419 }
420
421 return newListOfLeafList;
422 }
423
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530424 @Override
425 public ResolvableStatus getResolvableStatus() {
426 return resolvableStatus;
427 }
428
429 @Override
430 public void setResolvableStatus(ResolvableStatus resolvableStatus) {
431 this.resolvableStatus = resolvableStatus;
432 }
janani b4e53f9b2016-04-26 18:49:20 +0530433
434 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530435 public void detectCollidingChild(String identifierName, YangConstructType dataType)
436 throws DataModelException {
janani b4e53f9b2016-04-26 18:49:20 +0530437 detectCollidingChildUtil(identifierName, dataType, this);
438 }
439
440 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530441 public void detectSelfCollision(String identifierName, YangConstructType dataType)
442 throws DataModelException {
janani b4e53f9b2016-04-26 18:49:20 +0530443
444 if (getName().equals(identifierName)) {
445 throw new DataModelException("YANG file error: Duplicate input identifier detected, same as uses \""
446 + getName() + "\"");
447 }
448 }
449
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530450 /**
451 * Adds the node under grouping to the effective uses resolved info.
452 *
453 * @param nodeInGrouping node defined under grouping which needs to be copied in
454 * the context of uses
455 */
456 public void addNodeOfGrouping(YangNode nodeInGrouping) {
457 resolvedGroupingNodes.add(nodeInGrouping);
458 }
459
460 /**
461 * Returns the effective list of nodes added due to uses linking.
462 *
463 * @return effective list of nodes added due to uses linking
464 */
465 public List<YangNode> getUsesResolvedNodeList() {
466 return resolvedGroupingNodes;
467 }
468
469 /**
470 * Adds the leaves under grouping to the effective uses resolved info.
471 *
472 * @param leavesInGrouping Leaves defined under grouping which needs to be copied in
473 * the context of uses
474 */
475 public void addLeavesOfGrouping(List<YangLeaf> leavesInGrouping) {
476 resolvedGroupingLeaves.add(leavesInGrouping);
477 }
478
479 /**
480 * Returns the effective list of Leaves added due to uses linking.
481 *
482 * @return effective list of Leaves added due to uses linking
483 */
484 public List<List<YangLeaf>> getUsesResolvedLeavesList() {
485 return resolvedGroupingLeaves;
486 }
487
488 /**
489 * Adds the leaf-lists under grouping to the effective uses resolved info.
490 *
491 * @param leafListsInGrouping leaf-lists defined under grouping which needs to be copied in
492 * the context of uses
493 */
494 public void addListOfLeafListOfGrouping(List<YangLeafList> leafListsInGrouping) {
495 resolvedGroupingLeafLists.add(leafListsInGrouping);
496 }
497
498 /**
499 * Returns the effective list of Leaves added due to uses linking.
500 *
501 * @return effective list of Leaves added due to uses linking
502 */
503 public List<List<YangLeafList>> getUsesResolvedListOfLeafList() {
504 return resolvedGroupingLeafLists;
505 }
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530506}