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; |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 19 | import java.util.LinkedList; |
| 20 | import java.util.List; |
| 21 | |
Vinod Kumar S | 3804650 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 22 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
Bharat saraswal | 96dfef0 | 2016-06-16 00:29:12 +0530 | [diff] [blame] | 23 | import org.onosproject.yangutils.datamodel.utils.Parsable; |
| 24 | import org.onosproject.yangutils.datamodel.utils.YangConstructType; |
Vinod Kumar S | 3804650 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 25 | |
| 26 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil; |
Bharat saraswal | 96dfef0 | 2016-06-16 00:29:12 +0530 | [diff] [blame] | 27 | import static org.onosproject.yangutils.datamodel.utils.YangConstructType.CASE_DATA; |
Vinod Kumar S | 3804650 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 28 | |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 29 | /*- |
| 30 | * Reference RFC 6020. |
| 31 | * |
| 32 | * The "case" statement is used to define branches of the choice. It takes as an |
| 33 | * argument an identifier, followed by a block of sub-statements that holds |
| 34 | * detailed case information. |
| 35 | * |
| 36 | * The identifier is used to identify the case node in the schema tree. A case |
| 37 | * node does not exist in the data tree. |
| 38 | * |
| 39 | * Within a "case" statement, the "anyxml", "choice", "container", "leaf", |
| 40 | * "list", "leaf-list", and "uses" statements can be used to define child nodes |
| 41 | * to the case node. The identifiers of all these child nodes MUST be unique |
| 42 | * within all cases in a choice. For example, the following is illegal: |
| 43 | * |
| 44 | * choice interface-type { // This example is illegal YANG |
| 45 | * case a { |
| 46 | * leaf ethernet { ... } |
| 47 | * } |
| 48 | * case b { |
| 49 | * container ethernet { ...} |
| 50 | * } |
| 51 | * } |
| 52 | * |
| 53 | * As a shorthand, the "case" statement can be omitted if the branch |
| 54 | * contains a single "anyxml", "container", "leaf", "list", or |
| 55 | * "leaf-list" statement. In this case, the identifier of the case node |
| 56 | * is the same as the identifier in the branch statement. The following |
| 57 | * example: |
| 58 | * |
| 59 | * choice interface-type { |
| 60 | * container ethernet { ... } |
| 61 | * } |
| 62 | * |
| 63 | * is equivalent to: |
| 64 | * |
| 65 | * choice interface-type { |
| 66 | * case ethernet { |
| 67 | * container ethernet { ... } |
| 68 | * } |
| 69 | * } |
| 70 | * |
| 71 | * The case identifier MUST be unique within a choice. |
| 72 | * |
| 73 | * The case's sub-statements |
| 74 | * |
| 75 | * +--------------+---------+-------------+------------------+ |
| 76 | * | substatement | section | cardinality |data model mapping| |
| 77 | * +--------------+---------+-------------+------------------+ |
| 78 | * | anyxml | 7.10 | 0..n |-not supported | |
| 79 | * | choice | 7.9 | 0..n |-child nodes | |
| 80 | * | container | 7.5 | 0..n |-child nodes | |
| 81 | * | description | 7.19.3 | 0..1 |-string | |
Vidyashree Rama | deac28b | 2016-06-20 15:12:43 +0530 | [diff] [blame] | 82 | * | if-feature | 7.18.2 | 0..n |-YangIfFeature | |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 83 | * | leaf | 7.6 | 0..n |-YangLeaf | |
| 84 | * | leaf-list | 7.7 | 0..n |-YangLeafList | |
| 85 | * | list | 7.8 | 0..n |-child nodes | |
| 86 | * | reference | 7.19.4 | 0..1 |-string | |
| 87 | * | status | 7.19.2 | 0..1 |-YangStatus | |
| 88 | * | uses | 7.12 | 0..n |-child node | |
Vidyashree Rama | deac28b | 2016-06-20 15:12:43 +0530 | [diff] [blame] | 89 | * | when | 7.19.5 | 0..1 |-YangWhen | |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 90 | * +--------------+---------+-------------+------------------+ |
| 91 | */ |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 92 | |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 93 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 94 | * Represents data model node to maintain information defined in YANG case. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 95 | */ |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 96 | public class YangCase |
| 97 | extends YangNode |
Bharat saraswal | b1170bd | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 98 | implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector, YangAugmentableNode, |
Bharat saraswal | 2d90b0c | 2016-08-04 02:00:03 +0530 | [diff] [blame^] | 99 | YangWhenHolder, YangIfFeatureHolder, YangIsFilterContentNodes { |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 100 | |
Bharat saraswal | 96dfef0 | 2016-06-16 00:29:12 +0530 | [diff] [blame] | 101 | private static final long serialVersionUID = 806201603L; |
| 102 | |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 103 | /** |
| 104 | * Case name. |
| 105 | */ |
| 106 | private String name; |
| 107 | |
| 108 | // TODO: default field identification for the case |
| 109 | |
| 110 | /** |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 111 | * Description of case. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 112 | */ |
| 113 | private String description; |
| 114 | |
| 115 | /** |
| 116 | * List of leaves. |
| 117 | */ |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 118 | private List<YangLeaf> listOfLeaf; |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 119 | |
| 120 | /** |
| 121 | * List of leaf lists. |
| 122 | */ |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 123 | private List<YangLeafList> listOfLeafList; |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 124 | |
| 125 | /** |
| 126 | * Reference of the module. |
| 127 | */ |
| 128 | private String reference; |
| 129 | |
| 130 | /** |
| 131 | * Status of the node. |
| 132 | */ |
| 133 | private YangStatusType status; |
| 134 | |
| 135 | /** |
Vidyashree Rama | deac28b | 2016-06-20 15:12:43 +0530 | [diff] [blame] | 136 | * When data of the node. |
| 137 | */ |
| 138 | private YangWhen when; |
| 139 | |
| 140 | /** |
| 141 | * List of if-feature. |
| 142 | */ |
| 143 | private List<YangIfFeature> ifFeatureList; |
| 144 | |
Bharat saraswal | b1170bd | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 145 | private List<YangAugmentedInfo> yangAugmentedInfo = new ArrayList<>(); |
| 146 | |
Vidyashree Rama | deac28b | 2016-06-20 15:12:43 +0530 | [diff] [blame] | 147 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 148 | * Creates a choice node. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 149 | */ |
| 150 | public YangCase() { |
| 151 | super(YangNodeType.CASE_NODE); |
Bharat saraswal | 2d90b0c | 2016-08-04 02:00:03 +0530 | [diff] [blame^] | 152 | listOfLeaf = new LinkedList<>(); |
| 153 | listOfLeafList = new LinkedList<>(); |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 154 | } |
| 155 | |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 156 | /** |
Vidyashree Rama | deac28b | 2016-06-20 15:12:43 +0530 | [diff] [blame] | 157 | * Returns the when. |
| 158 | * |
| 159 | * @return the when |
| 160 | */ |
| 161 | @Override |
| 162 | public YangWhen getWhen() { |
| 163 | return when; |
| 164 | } |
| 165 | |
| 166 | /** |
| 167 | * Sets the when. |
| 168 | * |
| 169 | * @param when the when to set |
| 170 | */ |
| 171 | @Override |
| 172 | public void setWhen(YangWhen when) { |
| 173 | this.when = when; |
| 174 | } |
| 175 | |
| 176 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 177 | * Returns the case name. |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 178 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 179 | * @return case name |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 180 | */ |
| 181 | @Override |
| 182 | public String getName() { |
| 183 | return name; |
| 184 | } |
| 185 | |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 186 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 187 | * Sets the case name. |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 188 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 189 | * @param name case name |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 190 | */ |
| 191 | @Override |
| 192 | public void setName(String name) { |
| 193 | this.name = name; |
| 194 | } |
| 195 | |
| 196 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 197 | * Returns the description. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 198 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 199 | * @return the description |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 200 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 201 | @Override |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 202 | public String getDescription() { |
| 203 | return description; |
| 204 | } |
| 205 | |
| 206 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 207 | * Sets the description. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 208 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 209 | * @param description set the description |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 210 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 211 | @Override |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 212 | public void setDescription(String description) { |
| 213 | this.description = description; |
| 214 | } |
| 215 | |
| 216 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 217 | * Returns the list of leaves. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 218 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 219 | * @return the list of leaves |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 220 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 221 | @Override |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 222 | public List<YangLeaf> getListOfLeaf() { |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 223 | return listOfLeaf; |
| 224 | } |
| 225 | |
| 226 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 227 | * Sets the list of leaves. |
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 | * @param leafsList the list of leaf to set |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 230 | */ |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 231 | @Override |
| 232 | public void setListOfLeaf(List<YangLeaf> leafsList) { |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 233 | listOfLeaf = leafsList; |
| 234 | } |
| 235 | |
| 236 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 237 | * Adds a leaf. |
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 leaf the leaf to be added |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 240 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 241 | @Override |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 242 | public void addLeaf(YangLeaf leaf) { |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 243 | if (getListOfLeaf() == null) { |
Bharat saraswal | 2d90b0c | 2016-08-04 02:00:03 +0530 | [diff] [blame^] | 244 | setListOfLeaf(new LinkedList<>()); |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 245 | } |
| 246 | |
| 247 | getListOfLeaf().add(leaf); |
| 248 | } |
| 249 | |
| 250 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 251 | * Returns the list of leaf-list. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 252 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 253 | * @return the list of leaf-list |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 254 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 255 | @Override |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 256 | public List<YangLeafList> getListOfLeafList() { |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 257 | return listOfLeafList; |
| 258 | } |
| 259 | |
| 260 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 261 | * Sets the list of leaf-list. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 262 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 263 | * @param listOfLeafList the list of leaf-list to set |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 264 | */ |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 265 | @Override |
| 266 | public void setListOfLeafList(List<YangLeafList> listOfLeafList) { |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 267 | this.listOfLeafList = listOfLeafList; |
| 268 | } |
| 269 | |
| 270 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 271 | * Adds a leaf-list. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 272 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 273 | * @param leafList the leaf-list to be added |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 274 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 275 | @Override |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 276 | public void addLeafList(YangLeafList leafList) { |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 277 | if (getListOfLeafList() == null) { |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 278 | setListOfLeafList(new LinkedList<YangLeafList>()); |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 279 | } |
| 280 | |
| 281 | getListOfLeafList().add(leafList); |
| 282 | } |
| 283 | |
| 284 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 285 | * Returns the textual reference. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 286 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 287 | * @return the reference |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 288 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 289 | @Override |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 290 | public String getReference() { |
| 291 | return reference; |
| 292 | } |
| 293 | |
| 294 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 295 | * Sets the textual reference. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 296 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 297 | * @param reference the reference to set |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 298 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 299 | @Override |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 300 | public void setReference(String reference) { |
| 301 | this.reference = reference; |
| 302 | } |
| 303 | |
| 304 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 305 | * Returns the status. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 306 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 307 | * @return the status |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 308 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 309 | @Override |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 310 | public YangStatusType getStatus() { |
| 311 | return status; |
| 312 | } |
| 313 | |
| 314 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 315 | * Sets the status. |
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 | * @param status the status to set |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 318 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 319 | @Override |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 320 | public void setStatus(YangStatusType status) { |
| 321 | this.status = status; |
| 322 | } |
| 323 | |
| 324 | /** |
| 325 | * Returns the type of the data. |
| 326 | * |
| 327 | * @return returns CASE_DATA |
| 328 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 329 | @Override |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 330 | public YangConstructType getYangConstructType() { |
Vidyashree Rama | 7142d9c | 2016-04-26 15:06:06 +0530 | [diff] [blame] | 331 | return CASE_DATA; |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 332 | } |
| 333 | |
| 334 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 335 | * Validates the data on entering the corresponding parse tree node. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 336 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 337 | * @throws DataModelException a violation of data model rules |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 338 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 339 | @Override |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 340 | public void validateDataOnEntry() |
| 341 | throws DataModelException { |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 342 | // TODO auto-generated method stub, to be implemented by parser |
| 343 | } |
| 344 | |
| 345 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 346 | * Validates the data on exiting the corresponding parse tree node. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 347 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 348 | * @throws DataModelException a violation of data model rules |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 349 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 350 | @Override |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 351 | public void validateDataOnExit() |
| 352 | throws DataModelException { |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 353 | // TODO auto-generated method stub, to be implemented by parser |
| 354 | } |
| 355 | |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 356 | @Override |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 357 | public void detectCollidingChild(String identifierName, YangConstructType dataType) |
| 358 | throws DataModelException { |
Vidyashree Rama | 36f2fab | 2016-07-15 14:06:56 +0530 | [diff] [blame] | 359 | if (!(getParent() instanceof YangChoice || getParent() instanceof YangAugment)) { |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 360 | 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] | 361 | getName()); |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 362 | } |
| 363 | // Traverse up in tree to ask parent choice start collision detection. |
Vinod Kumar S | 3804650 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 364 | ((CollisionDetector) getParent()).detectCollidingChild(identifierName, dataType); |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 365 | } |
| 366 | |
| 367 | @Override |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 368 | public void detectSelfCollision(String identifierName, YangConstructType dataType) |
| 369 | throws DataModelException { |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 370 | |
| 371 | if (dataType == CASE_DATA) { |
Vinod Kumar S | 3804650 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 372 | if (getName().equals(identifierName)) { |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 373 | throw new DataModelException("YANG File Error: Identifier collision detected in case \"" + |
Vinod Kumar S | 3804650 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 374 | getName() + "\""); |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 375 | } |
| 376 | return; |
| 377 | } |
| 378 | |
| 379 | // Asks helper to detect colliding child. |
| 380 | detectCollidingChildUtil(identifierName, dataType, this); |
Bharat saraswal | 594bc6d | 2016-02-22 22:15:21 +0530 | [diff] [blame] | 381 | } |
Vidyashree Rama | deac28b | 2016-06-20 15:12:43 +0530 | [diff] [blame] | 382 | |
| 383 | @Override |
| 384 | public List<YangIfFeature> getIfFeatureList() { |
| 385 | return ifFeatureList; |
| 386 | } |
| 387 | |
| 388 | @Override |
| 389 | public void addIfFeatureList(YangIfFeature ifFeature) { |
| 390 | if (getIfFeatureList() == null) { |
| 391 | setIfFeatureList(new LinkedList<>()); |
| 392 | } |
| 393 | getIfFeatureList().add(ifFeature); |
| 394 | } |
| 395 | |
| 396 | @Override |
| 397 | public void setIfFeatureList(List<YangIfFeature> ifFeatureList) { |
| 398 | this.ifFeatureList = ifFeatureList; |
| 399 | } |
Bharat saraswal | b1170bd | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 400 | |
| 401 | @Override |
| 402 | public void addAugmentation(YangAugmentedInfo augmentInfo) { |
| 403 | yangAugmentedInfo.add(augmentInfo); |
| 404 | } |
| 405 | |
| 406 | @Override |
| 407 | public void removeAugmentation(YangAugmentedInfo augmentInfo) { |
| 408 | yangAugmentedInfo.remove(augmentInfo); |
| 409 | } |
| 410 | |
| 411 | @Override |
| 412 | public List<YangAugmentedInfo> getAugmentedInfoList() { |
| 413 | return yangAugmentedInfo; |
| 414 | } |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 415 | } |