Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
Vinod Kumar S | 2ff139c | 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 | |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 18 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
Bharat saraswal | 96dfef0 | 2016-06-16 00:29:12 +0530 | [diff] [blame] | 19 | import org.onosproject.yangutils.datamodel.utils.Parsable; |
| 20 | import org.onosproject.yangutils.datamodel.utils.YangConstructType; |
Vinod Kumar S | 3804650 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 21 | |
Bharat saraswal | 96dfef0 | 2016-06-16 00:29:12 +0530 | [diff] [blame] | 22 | import static org.onosproject.yangutils.datamodel.utils.YangConstructType.CHOICE_DATA; |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 23 | |
| 24 | /*- |
| 25 | * Reference RFC 6020. |
| 26 | * |
| 27 | * The "choice" statement defines a set of alternatives, only one of |
| 28 | * which may exist at any one time. The argument is an identifier, |
| 29 | * followed by a block of sub-statements that holds detailed choice |
| 30 | * information. The identifier is used to identify the choice node in |
| 31 | * the schema tree. A choice node does not exist in the data tree. |
| 32 | * |
| 33 | * A choice consists of a number of branches, defined with the "case" |
| 34 | * sub-statement. Each branch contains a number of child nodes. The |
| 35 | * nodes from at most one of the choice's branches exist at the same |
| 36 | * time. |
| 37 | * |
| 38 | * The choice's sub-statements |
| 39 | * |
| 40 | * +--------------+---------+-------------+------------------+ |
| 41 | * | substatement | section | cardinality |data model mapping| |
| 42 | * +--------------+---------+-------------+------------------+ |
| 43 | * | anyxml | 7.10 | 0..n |-not supported | |
| 44 | * | case | 7.9.2 | 0..n |-YangChoice | |
| 45 | * | config | 7.19.1 | 0..1 |-boolean | |
| 46 | * | container | 7.5 | 0..n |-child case nodes | |
| 47 | * | default | 7.9.3 | 0..1 |-string | |
| 48 | * | description | 7.19.3 | 0..1 |-string | |
| 49 | * | if-feature | 7.18.2 | 0..n |-TODO | |
| 50 | * | leaf | 7.6 | 0..n |-child case nodes | |
| 51 | * | leaf-list | 7.7 | 0..n |-child case nodes | |
| 52 | * | list | 7.8 | 0..n |-child case nodes | |
| 53 | * | mandatory | 7.9.4 | 0..1 |-string | |
| 54 | * | reference | 7.19.4 | 0..1 |-string | |
| 55 | * | status | 7.19.2 | 0..1 |-string | |
| 56 | * | when | 7.19.5 | 0..1 |-TODO | |
| 57 | * +--------------+---------+-------------+------------------+ |
| 58 | */ |
| 59 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 60 | * Represents data model node to maintain information defined in YANG choice. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 61 | */ |
Bharat saraswal | ab4c6ba | 2016-05-17 14:19:38 +0530 | [diff] [blame] | 62 | public class YangChoice extends YangNode |
| 63 | implements YangCommonInfo, Parsable, CollisionDetector, YangAugmentationHolder { |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 64 | |
Bharat saraswal | 96dfef0 | 2016-06-16 00:29:12 +0530 | [diff] [blame] | 65 | private static final long serialVersionUID = 806201604L; |
| 66 | |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 67 | /** |
| 68 | * Name of choice. |
| 69 | */ |
| 70 | private String name; |
| 71 | |
| 72 | /** |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 73 | * If the choice represents config data. |
| 74 | */ |
| 75 | private boolean isConfig; |
| 76 | |
| 77 | /** |
| 78 | * Reference RFC 6020. |
| 79 | * |
| 80 | * The "default" statement indicates if a case should be considered as the |
| 81 | * default if no child nodes from any of the choice's cases exist. The |
| 82 | * argument is the identifier of the "case" statement. If the "default" |
| 83 | * statement is missing, there is no default case. |
| 84 | * |
| 85 | * The "default" statement MUST NOT be present on choices where "mandatory" |
| 86 | * is true. |
| 87 | * |
| 88 | * The default case is only important when considering the default values of |
| 89 | * nodes under the cases. The default values for nodes under the default |
| 90 | * case are used if none of the nodes under any of the cases are present. |
| 91 | * |
| 92 | * There MUST NOT be any mandatory nodes directly under the default case. |
| 93 | * |
| 94 | * Default values for child nodes under a case are only used if one of the |
| 95 | * nodes under that case is present, or if that case is the default case. If |
| 96 | * none of the nodes under a case are present and the case is not the |
| 97 | * default case, the default values of the cases' child nodes are ignored. |
| 98 | * |
| 99 | * the default case to be used if no case members is present. |
| 100 | */ |
| 101 | private String defaultCase; |
| 102 | |
| 103 | /** |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 104 | * Description of choice. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 105 | */ |
| 106 | private String description; |
| 107 | |
| 108 | /** |
| 109 | * Reference RFC 6020. |
| 110 | * |
| 111 | * The "mandatory" statement, which is optional, takes as an argument the |
| 112 | * string "true" or "false", and puts a constraint on valid data. If |
| 113 | * "mandatory" is "true", at least one node from exactly one of the choice's |
| 114 | * case branches MUST exist. |
| 115 | * |
| 116 | * If not specified, the default is "false". |
| 117 | * |
| 118 | * The behavior of the constraint depends on the type of the choice's |
| 119 | * closest ancestor node in the schema tree which is not a non-presence |
| 120 | * container: |
| 121 | * |
| 122 | * o If this ancestor is a case node, the constraint is enforced if any |
| 123 | * other node from the case exists. |
| 124 | * |
| 125 | * o Otherwise, it is enforced if the ancestor node exists. |
| 126 | */ |
| 127 | private String mandatory; |
| 128 | |
| 129 | /** |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 130 | * Reference of the choice. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 131 | */ |
| 132 | private String reference; |
| 133 | |
| 134 | /** |
| 135 | * Status of the node. |
| 136 | */ |
| 137 | private YangStatusType status; |
| 138 | |
| 139 | /** |
Vidyashree Rama | 1db1556 | 2016-05-17 16:16:15 +0530 | [diff] [blame] | 140 | * Default value in string, needs to be converted to the target object, |
| 141 | * based on the type. |
| 142 | */ |
| 143 | private String defaultValueInString; |
| 144 | |
| 145 | /** |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 146 | * Create a choice node. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 147 | */ |
| 148 | public YangChoice() { |
| 149 | super(YangNodeType.CHOICE_NODE); |
| 150 | } |
| 151 | |
Vinod Kumar S | 3804650 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 152 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 153 | * Returns the choice name. |
Vinod Kumar S | 3804650 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 154 | * |
| 155 | * @return choice name |
| 156 | */ |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 157 | @Override |
| 158 | public String getName() { |
| 159 | return name; |
| 160 | } |
| 161 | |
Vinod Kumar S | 3804650 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 162 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 163 | * Sets the choice name. |
Vinod Kumar S | 3804650 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 164 | * |
| 165 | * @param name choice name |
| 166 | */ |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 167 | @Override |
| 168 | public void setName(String name) { |
| 169 | this.name = name; |
| 170 | } |
| 171 | |
| 172 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 173 | * Returns config flag. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 174 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 175 | * @return the config flag |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 176 | */ |
| 177 | public boolean isConfig() { |
| 178 | return isConfig; |
| 179 | } |
| 180 | |
| 181 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 182 | * Sets config flag. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 183 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 184 | * @param isCfg the config flag |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 185 | */ |
| 186 | public void setConfig(boolean isCfg) { |
| 187 | isConfig = isCfg; |
| 188 | } |
| 189 | |
| 190 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 191 | * Returns the default case. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 192 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 193 | * @return the default case |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 194 | */ |
| 195 | public String getDefaultCase() { |
| 196 | return defaultCase; |
| 197 | } |
| 198 | |
| 199 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 200 | * Sets the default case. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 201 | * |
| 202 | * @param defaultCase the default case to set |
| 203 | */ |
| 204 | public void setDefaultCase(String defaultCase) { |
| 205 | this.defaultCase = defaultCase; |
| 206 | } |
| 207 | |
| 208 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 209 | * Returns the mandatory status. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 210 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 211 | * @return the mandatory status |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 212 | */ |
| 213 | public String getMandatory() { |
| 214 | return mandatory; |
| 215 | } |
| 216 | |
| 217 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 218 | * Sets the mandatory status. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 219 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 220 | * @param mandatory the mandatory status |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 221 | */ |
| 222 | public void setMandatory(String mandatory) { |
| 223 | this.mandatory = mandatory; |
| 224 | } |
| 225 | |
| 226 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 227 | * Returns the description. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 228 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 229 | * @return the description |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 230 | */ |
Bharat saraswal | 594bc6d | 2016-02-22 22:15:21 +0530 | [diff] [blame] | 231 | @Override |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 232 | public String getDescription() { |
| 233 | return description; |
| 234 | } |
| 235 | |
| 236 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 237 | * Sets the description. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 238 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 239 | * @param description set the description |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 240 | */ |
Bharat saraswal | 594bc6d | 2016-02-22 22:15:21 +0530 | [diff] [blame] | 241 | @Override |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 242 | public void setDescription(String description) { |
| 243 | this.description = description; |
| 244 | } |
| 245 | |
| 246 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 247 | * Returns the textual reference. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 248 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 249 | * @return the reference |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 250 | */ |
Bharat saraswal | 594bc6d | 2016-02-22 22:15:21 +0530 | [diff] [blame] | 251 | @Override |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 252 | public String getReference() { |
| 253 | return reference; |
| 254 | } |
| 255 | |
| 256 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 257 | * Sets the textual reference. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 258 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 259 | * @param reference the reference to set |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 260 | */ |
Bharat saraswal | 594bc6d | 2016-02-22 22:15:21 +0530 | [diff] [blame] | 261 | @Override |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 262 | public void setReference(String reference) { |
| 263 | this.reference = reference; |
| 264 | } |
| 265 | |
| 266 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 267 | * Returns the status. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 268 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 269 | * @return the status |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 270 | */ |
Bharat saraswal | 594bc6d | 2016-02-22 22:15:21 +0530 | [diff] [blame] | 271 | @Override |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 272 | public YangStatusType getStatus() { |
| 273 | return status; |
| 274 | } |
| 275 | |
| 276 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 277 | * Sets the status. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 278 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 279 | * @param status the status to set |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 280 | */ |
Bharat saraswal | 594bc6d | 2016-02-22 22:15:21 +0530 | [diff] [blame] | 281 | @Override |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 282 | public void setStatus(YangStatusType status) { |
| 283 | this.status = status; |
| 284 | } |
| 285 | |
| 286 | /** |
Vidyashree Rama | 1db1556 | 2016-05-17 16:16:15 +0530 | [diff] [blame] | 287 | * Returns the default value. |
| 288 | * |
| 289 | * @return the default value |
| 290 | */ |
| 291 | public String getDefaultValueInString() { |
| 292 | return defaultValueInString; |
| 293 | } |
| 294 | |
| 295 | /** |
| 296 | * Sets the default value. |
| 297 | * |
| 298 | * @param defaultValueInString the default value |
| 299 | */ |
| 300 | public void setDefaultValueInString(String defaultValueInString) { |
| 301 | this.defaultValueInString = defaultValueInString; |
| 302 | } |
| 303 | |
| 304 | /** |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 305 | * Returns the type of the data. |
| 306 | * |
Vidyashree Rama | 7142d9c | 2016-04-26 15:06:06 +0530 | [diff] [blame] | 307 | * @return choice data |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 308 | */ |
Bharat saraswal | 594bc6d | 2016-02-22 22:15:21 +0530 | [diff] [blame] | 309 | @Override |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 310 | public YangConstructType getYangConstructType() { |
Vidyashree Rama | 7142d9c | 2016-04-26 15:06:06 +0530 | [diff] [blame] | 311 | return CHOICE_DATA; |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 312 | } |
| 313 | |
| 314 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 315 | * Validates the data on entering the corresponding parse tree node. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 316 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 317 | * @throws DataModelException a violation of data model rules |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 318 | */ |
Bharat saraswal | 594bc6d | 2016-02-22 22:15:21 +0530 | [diff] [blame] | 319 | @Override |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 320 | public void validateDataOnEntry() throws DataModelException { |
| 321 | // TODO auto-generated method stub, to be implemented by parser |
| 322 | } |
| 323 | |
| 324 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 325 | * Validates the data on exiting the corresponding parse tree node. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 326 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 327 | * @throws DataModelException a violation of data model rules |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 328 | */ |
Bharat saraswal | 594bc6d | 2016-02-22 22:15:21 +0530 | [diff] [blame] | 329 | @Override |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 330 | public void validateDataOnExit() throws DataModelException { |
| 331 | // TODO auto-generated method stub, to be implemented by parser |
| 332 | } |
| 333 | |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 334 | @Override |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 335 | public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException { |
| 336 | |
Bharat saraswal | 96dfef0 | 2016-06-16 00:29:12 +0530 | [diff] [blame] | 337 | if (getParent() instanceof YangCase && dataType != YangConstructType.CASE_DATA) { |
Vinod Kumar S | 3804650 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 338 | ((CollisionDetector) getParent()).detectCollidingChild(identifierName, dataType); |
| 339 | } |
| 340 | YangNode node = getChild(); |
| 341 | while (node != null) { |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 342 | if (node instanceof CollisionDetector) { |
| 343 | ((CollisionDetector) node).detectSelfCollision(identifierName, dataType); |
| 344 | } |
| 345 | node = node.getNextSibling(); |
| 346 | } |
| 347 | } |
| 348 | |
| 349 | @Override |
| 350 | public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException { |
| 351 | |
| 352 | if (dataType == CHOICE_DATA) { |
Vinod Kumar S | 3804650 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 353 | if (getName().equals(identifierName)) { |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 354 | throw new DataModelException("YANG file error: Identifier collision detected in choice \"" + |
Vinod Kumar S | 3804650 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 355 | getName() + "\""); |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 356 | } |
| 357 | return; |
| 358 | } |
| 359 | |
Vinod Kumar S | 3804650 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 360 | YangNode node = getChild(); |
| 361 | while (node != null) { |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 362 | if (node instanceof CollisionDetector) { |
| 363 | ((CollisionDetector) node).detectSelfCollision(identifierName, dataType); |
| 364 | } |
| 365 | node = node.getNextSibling(); |
| 366 | } |
| 367 | } |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 368 | } |