Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 1 | /* |
| 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 | package org.onosproject.yangutils.datamodel; |
| 17 | |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 18 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
| 19 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil; |
| 20 | import org.onosproject.yangutils.parser.Parsable; |
| 21 | import org.onosproject.yangutils.translator.CachedFileHandle; |
| 22 | import org.onosproject.yangutils.utils.YangConstructType; |
| 23 | import static org.onosproject.yangutils.utils.YangConstructType.CASE_DATA; |
| 24 | |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 25 | import java.util.LinkedList; |
| 26 | import java.util.List; |
| 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 | /** |
| 92 | * Data model node to maintain information defined in YANG case. |
| 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 | /** |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 130 | * Package of the generated java code. |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 131 | */ |
| 132 | private String pkg; |
| 133 | |
| 134 | /** |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 135 | * Create a choice node. |
| 136 | */ |
| 137 | public YangCase() { |
| 138 | super(YangNodeType.CASE_NODE); |
| 139 | } |
| 140 | |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 141 | /** |
| 142 | * Get the case name. |
| 143 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 144 | * @return case name |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 145 | */ |
| 146 | @Override |
| 147 | public String getName() { |
| 148 | return name; |
| 149 | } |
| 150 | |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 151 | /** |
| 152 | * Set the case name. |
| 153 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 154 | * @param name case name |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 155 | */ |
| 156 | @Override |
| 157 | public void setName(String name) { |
| 158 | this.name = name; |
| 159 | } |
| 160 | |
| 161 | /** |
| 162 | * Get the description. |
| 163 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 164 | * @return the description |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 165 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 166 | @Override |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 167 | public String getDescription() { |
| 168 | return description; |
| 169 | } |
| 170 | |
| 171 | /** |
| 172 | * Set the description. |
| 173 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 174 | * @param description set the description |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 175 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 176 | @Override |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 177 | public void setDescription(String description) { |
| 178 | this.description = description; |
| 179 | } |
| 180 | |
| 181 | /** |
| 182 | * Get the list of leaves. |
| 183 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 184 | * @return the list of leaves |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 185 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 186 | @Override |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 187 | public List<YangLeaf> getListOfLeaf() { |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 188 | return listOfLeaf; |
| 189 | } |
| 190 | |
| 191 | /** |
| 192 | * Set the list of leaves. |
| 193 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 194 | * @param leafsList the list of leaf to set |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 195 | */ |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 196 | private void setListOfLeaf(List<YangLeaf> leafsList) { |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 197 | listOfLeaf = leafsList; |
| 198 | } |
| 199 | |
| 200 | /** |
| 201 | * Add a leaf. |
| 202 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 203 | * @param leaf the leaf to be added |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 204 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 205 | @Override |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 206 | public void addLeaf(YangLeaf leaf) { |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 207 | if (getListOfLeaf() == null) { |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 208 | setListOfLeaf(new LinkedList<YangLeaf>()); |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 209 | } |
| 210 | |
| 211 | getListOfLeaf().add(leaf); |
| 212 | } |
| 213 | |
| 214 | /** |
| 215 | * Get the list of leaf-list. |
| 216 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 217 | * @return the list of leaf-list |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 218 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 219 | @Override |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 220 | public List<YangLeafList> getListOfLeafList() { |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 221 | return listOfLeafList; |
| 222 | } |
| 223 | |
| 224 | /** |
| 225 | * Set the list of leaf-list. |
| 226 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 227 | * @param listOfLeafList the list of leaf-list to set |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 228 | */ |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 229 | private void setListOfLeafList(List<YangLeafList> listOfLeafList) { |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 230 | this.listOfLeafList = listOfLeafList; |
| 231 | } |
| 232 | |
| 233 | /** |
| 234 | * Add a leaf-list. |
| 235 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 236 | * @param leafList the leaf-list to be added |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 237 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 238 | @Override |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 239 | public void addLeafList(YangLeafList leafList) { |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 240 | if (getListOfLeafList() == null) { |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 241 | setListOfLeafList(new LinkedList<YangLeafList>()); |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 242 | } |
| 243 | |
| 244 | getListOfLeafList().add(leafList); |
| 245 | } |
| 246 | |
| 247 | /** |
| 248 | * Get the textual reference. |
| 249 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 250 | * @return the reference |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 251 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 252 | @Override |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 253 | public String getReference() { |
| 254 | return reference; |
| 255 | } |
| 256 | |
| 257 | /** |
| 258 | * Set the textual reference. |
| 259 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 260 | * @param reference the reference to set |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 261 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 262 | @Override |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 263 | public void setReference(String reference) { |
| 264 | this.reference = reference; |
| 265 | } |
| 266 | |
| 267 | /** |
| 268 | * Get the status. |
| 269 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 270 | * @return the status |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 271 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 272 | @Override |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 273 | public YangStatusType getStatus() { |
| 274 | return status; |
| 275 | } |
| 276 | |
| 277 | /** |
| 278 | * Set the status. |
| 279 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 280 | * @param status the status to set |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 281 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 282 | @Override |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 283 | public void setStatus(YangStatusType status) { |
| 284 | this.status = status; |
| 285 | } |
| 286 | |
| 287 | /** |
| 288 | * Returns the type of the data. |
| 289 | * |
| 290 | * @return returns CASE_DATA |
| 291 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 292 | @Override |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 293 | public YangConstructType getYangConstructType() { |
| 294 | return YangConstructType.CASE_DATA; |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 295 | } |
| 296 | |
| 297 | /** |
| 298 | * Validate the data on entering the corresponding parse tree node. |
| 299 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 300 | * @throws DataModelException a violation of data model rules |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 301 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 302 | @Override |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 303 | public void validateDataOnEntry() throws DataModelException { |
| 304 | // TODO auto-generated method stub, to be implemented by parser |
| 305 | } |
| 306 | |
| 307 | /** |
| 308 | * Validate the data on exiting the corresponding parse tree node. |
| 309 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 310 | * @throws DataModelException a violation of data model rules |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 311 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 312 | @Override |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 313 | public void validateDataOnExit() throws DataModelException { |
| 314 | // TODO auto-generated method stub, to be implemented by parser |
| 315 | } |
| 316 | |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 317 | /** |
| 318 | * Get the mapped java package. |
| 319 | * |
| 320 | * @return the java package |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 321 | */ |
| 322 | @Override |
| 323 | public String getPackage() { |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 324 | return pkg; |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 325 | } |
| 326 | |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 327 | /** |
| 328 | * Set the mapped java package. |
| 329 | * |
| 330 | * @param pakg the package to set |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 331 | */ |
| 332 | @Override |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 333 | public void setPackage(String pakg) { |
| 334 | pkg = pakg; |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 335 | |
| 336 | } |
| 337 | |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 338 | /** |
| 339 | * Generate the code corresponding to YANG case info. |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 340 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 341 | @Override |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 342 | public void generateJavaCodeEntry() { |
| 343 | // TODO Auto-generated method stub |
| 344 | |
| 345 | } |
| 346 | |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 347 | /** |
| 348 | * Free resource used for generating code and generate valid java files |
| 349 | * corresponding to YANG case info. |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 350 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 351 | @Override |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 352 | public void generateJavaCodeExit() { |
| 353 | // TODO Auto-generated method stub |
| 354 | |
| 355 | } |
Bharat saraswal | 5e3c45c | 2016-02-22 22:15:21 +0530 | [diff] [blame] | 356 | |
| 357 | @Override |
| 358 | public CachedFileHandle getFileHandle() { |
| 359 | // TODO Auto-generated method stub |
| 360 | return null; |
| 361 | } |
| 362 | |
| 363 | @Override |
| 364 | public void setFileHandle(CachedFileHandle fileHandle) { |
| 365 | // TODO Auto-generated method stub |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 366 | } |
Bharat saraswal | 5e3c45c | 2016-02-22 22:15:21 +0530 | [diff] [blame] | 367 | |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 368 | @Override |
| 369 | public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException { |
| 370 | if ((this.getParent() == null) || (!(this.getParent() instanceof YangChoice))) { |
| 371 | throw new DataModelException("Internal Data Model Tree Error: Invalid/Missing holder in case " + |
| 372 | this.getName()); |
| 373 | } |
| 374 | // Traverse up in tree to ask parent choice start collision detection. |
| 375 | ((CollisionDetector) this.getParent()).detectCollidingChild(identifierName, dataType); |
| 376 | } |
| 377 | |
| 378 | @Override |
| 379 | public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException { |
| 380 | |
| 381 | if (dataType == CASE_DATA) { |
| 382 | if (this.getName().equals(identifierName)) { |
| 383 | throw new DataModelException("YANG File Error: Identifier collision detected in case \"" + |
| 384 | this.getName() + "\""); |
| 385 | } |
| 386 | return; |
| 387 | } |
| 388 | |
| 389 | // Asks helper to detect colliding child. |
| 390 | detectCollidingChildUtil(identifierName, dataType, this); |
Bharat saraswal | 5e3c45c | 2016-02-22 22:15:21 +0530 | [diff] [blame] | 391 | } |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 392 | } |