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