Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | 0f7908b | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 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 | package org.onosproject.yangutils.datamodel; |
| 17 | |
| 18 | import java.util.LinkedList; |
| 19 | import java.util.List; |
| 20 | |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 21 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
| 22 | import org.onosproject.yangutils.parser.Parsable; |
| 23 | import org.onosproject.yangutils.utils.YangConstructType; |
| 24 | |
| 25 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil; |
| 26 | import static org.onosproject.yangutils.utils.YangConstructType.CASE_DATA; |
| 27 | |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 28 | /*- |
| 29 | * Reference RFC 6020. |
| 30 | * |
| 31 | * The "case" statement is used to define branches of the choice. It takes as an |
| 32 | * argument an identifier, followed by a block of sub-statements that holds |
| 33 | * detailed case information. |
| 34 | * |
| 35 | * The identifier is used to identify the case node in the schema tree. A case |
| 36 | * node does not exist in the data tree. |
| 37 | * |
| 38 | * Within a "case" statement, the "anyxml", "choice", "container", "leaf", |
| 39 | * "list", "leaf-list", and "uses" statements can be used to define child nodes |
| 40 | * to the case node. The identifiers of all these child nodes MUST be unique |
| 41 | * within all cases in a choice. For example, the following is illegal: |
| 42 | * |
| 43 | * choice interface-type { // This example is illegal YANG |
| 44 | * case a { |
| 45 | * leaf ethernet { ... } |
| 46 | * } |
| 47 | * case b { |
| 48 | * container ethernet { ...} |
| 49 | * } |
| 50 | * } |
| 51 | * |
| 52 | * As a shorthand, the "case" statement can be omitted if the branch |
| 53 | * contains a single "anyxml", "container", "leaf", "list", or |
| 54 | * "leaf-list" statement. In this case, the identifier of the case node |
| 55 | * is the same as the identifier in the branch statement. The following |
| 56 | * example: |
| 57 | * |
| 58 | * choice interface-type { |
| 59 | * container ethernet { ... } |
| 60 | * } |
| 61 | * |
| 62 | * is equivalent to: |
| 63 | * |
| 64 | * choice interface-type { |
| 65 | * case ethernet { |
| 66 | * container ethernet { ... } |
| 67 | * } |
| 68 | * } |
| 69 | * |
| 70 | * The case identifier MUST be unique within a choice. |
| 71 | * |
| 72 | * The case's sub-statements |
| 73 | * |
| 74 | * +--------------+---------+-------------+------------------+ |
| 75 | * | substatement | section | cardinality |data model mapping| |
| 76 | * +--------------+---------+-------------+------------------+ |
| 77 | * | anyxml | 7.10 | 0..n |-not supported | |
| 78 | * | choice | 7.9 | 0..n |-child nodes | |
| 79 | * | container | 7.5 | 0..n |-child nodes | |
| 80 | * | description | 7.19.3 | 0..1 |-string | |
| 81 | * | if-feature | 7.18.2 | 0..n |-TODO | |
| 82 | * | leaf | 7.6 | 0..n |-YangLeaf | |
| 83 | * | leaf-list | 7.7 | 0..n |-YangLeafList | |
| 84 | * | list | 7.8 | 0..n |-child nodes | |
| 85 | * | reference | 7.19.4 | 0..1 |-string | |
| 86 | * | status | 7.19.2 | 0..1 |-YangStatus | |
| 87 | * | uses | 7.12 | 0..n |-child node | |
| 88 | * | when | 7.19.5 | 0..1 |-TODO | |
| 89 | * +--------------+---------+-------------+------------------+ |
| 90 | */ |
| 91 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 92 | * Represents data model node to maintain information defined in YANG case. |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 93 | */ |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 94 | public class YangCase extends YangNode |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 95 | implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector { |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 96 | |
| 97 | /** |
| 98 | * Case name. |
| 99 | */ |
| 100 | private String name; |
| 101 | |
| 102 | // TODO: default field identification for the case |
| 103 | |
| 104 | /** |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 105 | * Description of case. |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 106 | */ |
| 107 | private String description; |
| 108 | |
| 109 | /** |
| 110 | * List of leaves. |
| 111 | */ |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 112 | private List<YangLeaf> listOfLeaf; |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 113 | |
| 114 | /** |
| 115 | * List of leaf lists. |
| 116 | */ |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 117 | private List<YangLeafList> listOfLeafList; |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 118 | |
| 119 | /** |
| 120 | * Reference of the module. |
| 121 | */ |
| 122 | private String reference; |
| 123 | |
| 124 | /** |
| 125 | * Status of the node. |
| 126 | */ |
| 127 | private YangStatusType status; |
| 128 | |
| 129 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 130 | * Creates a choice node. |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 131 | */ |
| 132 | public YangCase() { |
| 133 | super(YangNodeType.CASE_NODE); |
| 134 | } |
| 135 | |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 136 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 137 | * Returns the case name. |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 138 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 139 | * @return case name |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 140 | */ |
| 141 | @Override |
| 142 | public String getName() { |
| 143 | return name; |
| 144 | } |
| 145 | |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 146 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 147 | * Sets the case name. |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 148 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 149 | * @param name case name |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 150 | */ |
| 151 | @Override |
| 152 | public void setName(String name) { |
| 153 | this.name = name; |
| 154 | } |
| 155 | |
| 156 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 157 | * Returns the description. |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 158 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 159 | * @return the description |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 160 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 161 | @Override |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 162 | public String getDescription() { |
| 163 | return description; |
| 164 | } |
| 165 | |
| 166 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 167 | * Sets the description. |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 168 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 169 | * @param description set the description |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 170 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 171 | @Override |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 172 | public void setDescription(String description) { |
| 173 | this.description = description; |
| 174 | } |
| 175 | |
| 176 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 177 | * Returns the list of leaves. |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 178 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 179 | * @return the list of leaves |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 180 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 181 | @Override |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 182 | public List<YangLeaf> getListOfLeaf() { |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 183 | return listOfLeaf; |
| 184 | } |
| 185 | |
| 186 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 187 | * Sets the list of leaves. |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 188 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 189 | * @param leafsList the list of leaf to set |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 190 | */ |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 191 | private void setListOfLeaf(List<YangLeaf> leafsList) { |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 192 | listOfLeaf = leafsList; |
| 193 | } |
| 194 | |
| 195 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 196 | * Adds a leaf. |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 197 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 198 | * @param leaf the leaf to be added |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 199 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 200 | @Override |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 201 | public void addLeaf(YangLeaf leaf) { |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 202 | if (getListOfLeaf() == null) { |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 203 | setListOfLeaf(new LinkedList<YangLeaf>()); |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 204 | } |
| 205 | |
| 206 | getListOfLeaf().add(leaf); |
| 207 | } |
| 208 | |
| 209 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 210 | * Returns the list of leaf-list. |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 211 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 212 | * @return the list of leaf-list |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 213 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 214 | @Override |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 215 | public List<YangLeafList> getListOfLeafList() { |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 216 | return listOfLeafList; |
| 217 | } |
| 218 | |
| 219 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 220 | * Sets the list of leaf-list. |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 221 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 222 | * @param listOfLeafList the list of leaf-list to set |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 223 | */ |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 224 | private void setListOfLeafList(List<YangLeafList> listOfLeafList) { |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 225 | this.listOfLeafList = listOfLeafList; |
| 226 | } |
| 227 | |
| 228 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 229 | * Adds a leaf-list. |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 230 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 231 | * @param leafList the leaf-list to be added |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 232 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 233 | @Override |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 234 | public void addLeafList(YangLeafList leafList) { |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 235 | if (getListOfLeafList() == null) { |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 236 | setListOfLeafList(new LinkedList<YangLeafList>()); |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | getListOfLeafList().add(leafList); |
| 240 | } |
| 241 | |
| 242 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 243 | * Returns the textual reference. |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 244 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 245 | * @return the reference |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 246 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 247 | @Override |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 248 | public String getReference() { |
| 249 | return reference; |
| 250 | } |
| 251 | |
| 252 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 253 | * Sets the textual reference. |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 254 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 255 | * @param reference the reference to set |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 256 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 257 | @Override |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 258 | public void setReference(String reference) { |
| 259 | this.reference = reference; |
| 260 | } |
| 261 | |
| 262 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 263 | * Returns the status. |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 264 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 265 | * @return the status |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 266 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 267 | @Override |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 268 | public YangStatusType getStatus() { |
| 269 | return status; |
| 270 | } |
| 271 | |
| 272 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 273 | * Sets the status. |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 274 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 275 | * @param status the status to set |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 276 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 277 | @Override |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 278 | public void setStatus(YangStatusType status) { |
| 279 | this.status = status; |
| 280 | } |
| 281 | |
| 282 | /** |
| 283 | * Returns the type of the data. |
| 284 | * |
| 285 | * @return returns CASE_DATA |
| 286 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 287 | @Override |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 288 | public YangConstructType getYangConstructType() { |
Vidyashree Rama | 1396065 | 2016-04-26 15:06:06 +0530 | [diff] [blame] | 289 | return CASE_DATA; |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 290 | } |
| 291 | |
| 292 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 293 | * Validates the data on entering the corresponding parse tree node. |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 294 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 295 | * @throws DataModelException a violation of data model rules |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 296 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 297 | @Override |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 298 | public void validateDataOnEntry() throws DataModelException { |
| 299 | // TODO auto-generated method stub, to be implemented by parser |
| 300 | } |
| 301 | |
| 302 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 303 | * Validates the data on exiting the corresponding parse tree node. |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 304 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 305 | * @throws DataModelException a violation of data model rules |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 306 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 307 | @Override |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 308 | public void validateDataOnExit() throws DataModelException { |
| 309 | // TODO auto-generated method stub, to be implemented by parser |
| 310 | } |
| 311 | |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 312 | @Override |
| 313 | public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException { |
Vidyashree Rama | 1396065 | 2016-04-26 15:06:06 +0530 | [diff] [blame] | 314 | if (!(getParent() instanceof YangChoice)) { |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 315 | throw new DataModelException("Internal Data Model Tree Error: Invalid/Missing holder in case " + |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 316 | getName()); |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 317 | } |
| 318 | // Traverse up in tree to ask parent choice start collision detection. |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 319 | ((CollisionDetector) getParent()).detectCollidingChild(identifierName, dataType); |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 320 | } |
| 321 | |
| 322 | @Override |
| 323 | public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException { |
| 324 | |
| 325 | if (dataType == CASE_DATA) { |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 326 | if (getName().equals(identifierName)) { |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 327 | throw new DataModelException("YANG File Error: Identifier collision detected in case \"" + |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 328 | getName() + "\""); |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 329 | } |
| 330 | return; |
| 331 | } |
| 332 | |
| 333 | // Asks helper to detect colliding child. |
| 334 | detectCollidingChildUtil(identifierName, dataType, this); |
Bharat saraswal | 5e3c45c | 2016-02-22 22:15:21 +0530 | [diff] [blame] | 335 | } |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 336 | } |