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 | |
| 18 | import java.util.LinkedList; |
| 19 | import java.util.List; |
| 20 | |
Vinod Kumar S | 3804650 | 2016-03-23 15:30:27 +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 | |
| 25 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil; |
Bharat saraswal | 96dfef0 | 2016-06-16 00:29:12 +0530 | [diff] [blame] | 26 | import static org.onosproject.yangutils.datamodel.utils.YangConstructType.CASE_DATA; |
Vinod Kumar S | 3804650 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 27 | |
Vinod Kumar S | 2ff139c | 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 | |
Vidyashree Rama | deac28b | 2016-06-20 15:12:43 +0530 | [diff] [blame^] | 81 | * | if-feature | 7.18.2 | 0..n |-YangIfFeature | |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 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 | |
Vidyashree Rama | deac28b | 2016-06-20 15:12:43 +0530 | [diff] [blame^] | 88 | * | when | 7.19.5 | 0..1 |-YangWhen | |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 89 | * +--------------+---------+-------------+------------------+ |
| 90 | */ |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 91 | |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 92 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 93 | * Represents data model node to maintain information defined in YANG case. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 94 | */ |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 95 | public class YangCase |
| 96 | extends YangNode |
Vidyashree Rama | deac28b | 2016-06-20 15:12:43 +0530 | [diff] [blame^] | 97 | implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector, YangAugmentationHolder, |
| 98 | YangWhenHolder, YangIfFeatureHolder { |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 99 | |
Bharat saraswal | 96dfef0 | 2016-06-16 00:29:12 +0530 | [diff] [blame] | 100 | private static final long serialVersionUID = 806201603L; |
| 101 | |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 102 | /** |
| 103 | * Case name. |
| 104 | */ |
| 105 | private String name; |
| 106 | |
| 107 | // TODO: default field identification for the case |
| 108 | |
| 109 | /** |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 110 | * Description of case. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 111 | */ |
| 112 | private String description; |
| 113 | |
| 114 | /** |
| 115 | * List of leaves. |
| 116 | */ |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 117 | private List<YangLeaf> listOfLeaf; |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 118 | |
| 119 | /** |
| 120 | * List of leaf lists. |
| 121 | */ |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 122 | private List<YangLeafList> listOfLeafList; |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 123 | |
| 124 | /** |
| 125 | * Reference of the module. |
| 126 | */ |
| 127 | private String reference; |
| 128 | |
| 129 | /** |
| 130 | * Status of the node. |
| 131 | */ |
| 132 | private YangStatusType status; |
| 133 | |
| 134 | /** |
Vidyashree Rama | deac28b | 2016-06-20 15:12:43 +0530 | [diff] [blame^] | 135 | * When data of the node. |
| 136 | */ |
| 137 | private YangWhen when; |
| 138 | |
| 139 | /** |
| 140 | * List of if-feature. |
| 141 | */ |
| 142 | private List<YangIfFeature> ifFeatureList; |
| 143 | |
| 144 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 145 | * Creates a choice node. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 146 | */ |
| 147 | public YangCase() { |
| 148 | super(YangNodeType.CASE_NODE); |
| 149 | } |
| 150 | |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 151 | /** |
Vidyashree Rama | deac28b | 2016-06-20 15:12:43 +0530 | [diff] [blame^] | 152 | * Returns the when. |
| 153 | * |
| 154 | * @return the when |
| 155 | */ |
| 156 | @Override |
| 157 | public YangWhen getWhen() { |
| 158 | return when; |
| 159 | } |
| 160 | |
| 161 | /** |
| 162 | * Sets the when. |
| 163 | * |
| 164 | * @param when the when to set |
| 165 | */ |
| 166 | @Override |
| 167 | public void setWhen(YangWhen when) { |
| 168 | this.when = when; |
| 169 | } |
| 170 | |
| 171 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 172 | * Returns the case name. |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 173 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 174 | * @return case name |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 175 | */ |
| 176 | @Override |
| 177 | public String getName() { |
| 178 | return name; |
| 179 | } |
| 180 | |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 181 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 182 | * Sets the case name. |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 183 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 184 | * @param name case name |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 185 | */ |
| 186 | @Override |
| 187 | public void setName(String name) { |
| 188 | this.name = name; |
| 189 | } |
| 190 | |
| 191 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 192 | * Returns the description. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 193 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 194 | * @return the description |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 195 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 196 | @Override |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 197 | public String getDescription() { |
| 198 | return description; |
| 199 | } |
| 200 | |
| 201 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 202 | * Sets the description. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 203 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 204 | * @param description set the description |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 205 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 206 | @Override |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 207 | public void setDescription(String description) { |
| 208 | this.description = description; |
| 209 | } |
| 210 | |
| 211 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 212 | * Returns the list of leaves. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 213 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 214 | * @return the list of leaves |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 215 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 216 | @Override |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 217 | public List<YangLeaf> getListOfLeaf() { |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 218 | return listOfLeaf; |
| 219 | } |
| 220 | |
| 221 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 222 | * Sets the list of leaves. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 223 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 224 | * @param leafsList the list of leaf to set |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 225 | */ |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 226 | @Override |
| 227 | public void setListOfLeaf(List<YangLeaf> leafsList) { |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 228 | listOfLeaf = leafsList; |
| 229 | } |
| 230 | |
| 231 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 232 | * Adds a leaf. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 233 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 234 | * @param leaf the leaf to be added |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 235 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 236 | @Override |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 237 | public void addLeaf(YangLeaf leaf) { |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 238 | if (getListOfLeaf() == null) { |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 239 | setListOfLeaf(new LinkedList<YangLeaf>()); |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 240 | } |
| 241 | |
| 242 | getListOfLeaf().add(leaf); |
| 243 | } |
| 244 | |
| 245 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 246 | * Returns the list of leaf-list. |
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 list of leaf-list |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 249 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 250 | @Override |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 251 | public List<YangLeafList> getListOfLeafList() { |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 252 | return listOfLeafList; |
| 253 | } |
| 254 | |
| 255 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 256 | * Sets the list of leaf-list. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 257 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 258 | * @param listOfLeafList the list of leaf-list to set |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 259 | */ |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 260 | @Override |
| 261 | public void setListOfLeafList(List<YangLeafList> listOfLeafList) { |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 262 | this.listOfLeafList = listOfLeafList; |
| 263 | } |
| 264 | |
| 265 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 266 | * Adds a leaf-list. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 267 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 268 | * @param leafList the leaf-list to be added |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 269 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 270 | @Override |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 271 | public void addLeafList(YangLeafList leafList) { |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 272 | if (getListOfLeafList() == null) { |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 273 | setListOfLeafList(new LinkedList<YangLeafList>()); |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 274 | } |
| 275 | |
| 276 | getListOfLeafList().add(leafList); |
| 277 | } |
| 278 | |
| 279 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 280 | * Returns the textual reference. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 281 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 282 | * @return the reference |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 283 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 284 | @Override |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 285 | public String getReference() { |
| 286 | return reference; |
| 287 | } |
| 288 | |
| 289 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 290 | * Sets the textual reference. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 291 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 292 | * @param reference the reference to set |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 293 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 294 | @Override |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 295 | public void setReference(String reference) { |
| 296 | this.reference = reference; |
| 297 | } |
| 298 | |
| 299 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 300 | * Returns the status. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 301 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 302 | * @return the status |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 303 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 304 | @Override |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 305 | public YangStatusType getStatus() { |
| 306 | return status; |
| 307 | } |
| 308 | |
| 309 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 310 | * Sets the status. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 311 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 312 | * @param status the status to set |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 313 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 314 | @Override |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 315 | public void setStatus(YangStatusType status) { |
| 316 | this.status = status; |
| 317 | } |
| 318 | |
| 319 | /** |
| 320 | * Returns the type of the data. |
| 321 | * |
| 322 | * @return returns CASE_DATA |
| 323 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 324 | @Override |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 325 | public YangConstructType getYangConstructType() { |
Vidyashree Rama | 7142d9c | 2016-04-26 15:06:06 +0530 | [diff] [blame] | 326 | return CASE_DATA; |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 327 | } |
| 328 | |
| 329 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 330 | * Validates the data on entering the corresponding parse tree node. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 331 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 332 | * @throws DataModelException a violation of data model rules |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 333 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 334 | @Override |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 335 | public void validateDataOnEntry() |
| 336 | throws DataModelException { |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 337 | // TODO auto-generated method stub, to be implemented by parser |
| 338 | } |
| 339 | |
| 340 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 341 | * Validates the data on exiting the corresponding parse tree node. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 342 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 343 | * @throws DataModelException a violation of data model rules |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 344 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 345 | @Override |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 346 | public void validateDataOnExit() |
| 347 | throws DataModelException { |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 348 | // TODO auto-generated method stub, to be implemented by parser |
| 349 | } |
| 350 | |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 351 | @Override |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 352 | public void detectCollidingChild(String identifierName, YangConstructType dataType) |
| 353 | throws DataModelException { |
Vidyashree Rama | 7142d9c | 2016-04-26 15:06:06 +0530 | [diff] [blame] | 354 | if (!(getParent() instanceof YangChoice)) { |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 355 | throw new DataModelException("Internal Data Model Tree Error: Invalid/Missing holder in case " + |
Vinod Kumar S | 3804650 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 356 | getName()); |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 357 | } |
| 358 | // Traverse up in tree to ask parent choice start collision detection. |
Vinod Kumar S | 3804650 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 359 | ((CollisionDetector) getParent()).detectCollidingChild(identifierName, dataType); |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 360 | } |
| 361 | |
| 362 | @Override |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 363 | public void detectSelfCollision(String identifierName, YangConstructType dataType) |
| 364 | throws DataModelException { |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 365 | |
| 366 | if (dataType == CASE_DATA) { |
Vinod Kumar S | 3804650 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 367 | if (getName().equals(identifierName)) { |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 368 | throw new DataModelException("YANG File Error: Identifier collision detected in case \"" + |
Vinod Kumar S | 3804650 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 369 | getName() + "\""); |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 370 | } |
| 371 | return; |
| 372 | } |
| 373 | |
| 374 | // Asks helper to detect colliding child. |
| 375 | detectCollidingChildUtil(identifierName, dataType, this); |
Bharat saraswal | 594bc6d | 2016-02-22 22:15:21 +0530 | [diff] [blame] | 376 | } |
Vidyashree Rama | deac28b | 2016-06-20 15:12:43 +0530 | [diff] [blame^] | 377 | |
| 378 | @Override |
| 379 | public List<YangIfFeature> getIfFeatureList() { |
| 380 | return ifFeatureList; |
| 381 | } |
| 382 | |
| 383 | @Override |
| 384 | public void addIfFeatureList(YangIfFeature ifFeature) { |
| 385 | if (getIfFeatureList() == null) { |
| 386 | setIfFeatureList(new LinkedList<>()); |
| 387 | } |
| 388 | getIfFeatureList().add(ifFeature); |
| 389 | } |
| 390 | |
| 391 | @Override |
| 392 | public void setIfFeatureList(List<YangIfFeature> ifFeatureList) { |
| 393 | this.ifFeatureList = ifFeatureList; |
| 394 | } |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 395 | } |