Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +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 | 67e7be6 | 2016-02-11 20:13:28 +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 | |
| 17 | package org.onosproject.yangutils.datamodel; |
| 18 | |
| 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; |
| 27 | |
| 28 | /* |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 29 | * The "list" statement is used to define an interior data node in the |
| 30 | * schema tree. A list node may exist in multiple instances in the data |
| 31 | * tree. Each such instance is known as a list entry. The "list" |
| 32 | * statement takes one argument, which is an identifier, followed by a |
| 33 | * block of sub-statements that holds detailed list information. |
| 34 | * |
| 35 | * A list entry is uniquely identified by the values of the list's keys, |
| 36 | * if defined. |
| 37 | * |
| 38 | * The list's sub-statements |
| 39 | * |
| 40 | * +--------------+---------+-------------+------------------+ |
| 41 | * | substatement | section | cardinality |data model mapping| |
| 42 | * +--------------+---------+-------------+------------------+ |
| 43 | * | anyxml | 7.10 | 0..n |-not supported | |
| 44 | * | choice | 7.9 | 0..n |-child nodes | |
| 45 | * | config | 7.19.1 | 0..1 |-boolean | |
| 46 | * | container | 7.5 | 0..n |-child nodes | |
| 47 | * | description | 7.19.3 | 0..1 |-string | |
| 48 | * | grouping | 7.11 | 0..n |-child nodes | |
| 49 | * | if-feature | 7.18.2 | 0..n |-TODO | |
| 50 | * | key | 7.8.2 | 0..1 |-String list | |
| 51 | * | leaf | 7.6 | 0..n |-YangLeaf | |
| 52 | * | leaf-list | 7.7 | 0..n |-YangLeafList | |
| 53 | * | list | 7.8 | 0..n |-child nodes | |
| 54 | * | max-elements | 7.7.4 | 0..1 |-int | |
| 55 | * | min-elements | 7.7.3 | 0..1 |-int | |
| 56 | * | must | 7.5.3 | 0..n |-TODO | |
| 57 | * | ordered-by | 7.7.5 | 0..1 |-TODO | |
| 58 | * | reference | 7.19.4 | 0..1 |-string | |
| 59 | * | status | 7.19.2 | 0..1 |-YangStatus | |
| 60 | * | typedef | 7.3 | 0..n |-child nodes | |
| 61 | * | unique | 7.8.3 | 0..n |-TODO | |
| 62 | * | uses | 7.12 | 0..n |-child nodes(TODO)| |
| 63 | * | when | 7.19.5 | 0..1 |-TODO | |
| 64 | * +--------------+---------+-------------+------------------+ |
| 65 | */ |
| 66 | |
| 67 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 68 | * Represents list data represented in YANG. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 69 | */ |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 70 | public class YangList |
| 71 | extends YangNode |
Bharat saraswal | ab4c6ba | 2016-05-17 14:19:38 +0530 | [diff] [blame] | 72 | implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector, YangAugmentationHolder { |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 73 | |
Bharat saraswal | 96dfef0 | 2016-06-16 00:29:12 +0530 | [diff] [blame^] | 74 | private static final long serialVersionUID = 806201609L; |
| 75 | |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 76 | /** |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 77 | * Name of the YANG list. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 78 | */ |
| 79 | private String name; |
| 80 | |
| 81 | /** |
| 82 | * If list maintains config data. |
| 83 | */ |
Vidyashree Rama | f4c617c | 2016-02-24 12:28:22 +0530 | [diff] [blame] | 84 | private Boolean isConfig; |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 85 | |
| 86 | /** |
| 87 | * Description of list. |
| 88 | */ |
| 89 | private String description; |
| 90 | |
| 91 | /** |
| 92 | * Reference RFC 6020. |
| 93 | * |
| 94 | * The "key" statement, which MUST be present if the list represents |
| 95 | * configuration, and MAY be present otherwise, takes as an argument a |
| 96 | * string that specifies a space-separated list of leaf identifiers of this |
| 97 | * list. A leaf identifier MUST NOT appear more than once in the key. Each |
| 98 | * such leaf identifier MUST refer to a child leaf of the list. The leafs |
| 99 | * can be defined directly in sub-statements to the list, or in groupings |
| 100 | * used in the list. |
| 101 | * |
| 102 | * The combined values of all the leafs specified in the key are used to |
| 103 | * uniquely identify a list entry. All key leafs MUST be given values when a |
| 104 | * list entry is created. Thus, any default values in the key leafs or their |
| 105 | * types are ignored. It also implies that any mandatory statement in the |
| 106 | * key leafs are ignored. |
| 107 | * |
| 108 | * A leaf that is part of the key can be of any built-in or derived type, |
| 109 | * except it MUST NOT be the built-in type "empty". |
| 110 | * |
| 111 | * All key leafs in a list MUST have the same value for their "config" as |
| 112 | * the list itself. |
| 113 | * |
| 114 | * List of key leaf names. |
| 115 | */ |
| 116 | private List<String> keyList; |
| 117 | |
| 118 | /** |
| 119 | * List of leaves. |
| 120 | */ |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 121 | private List<YangLeaf> listOfLeaf; |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 122 | |
| 123 | /** |
| 124 | * List of leaf-lists. |
| 125 | */ |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 126 | private List<YangLeafList> listOfLeafList; |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 127 | |
| 128 | /** |
Vinod Kumar S | c421600 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 129 | * Reference RFC 6020. |
| 130 | * |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 131 | * The "max-elements" statement, which is optional, takes as an argument a |
| 132 | * positive integer or the string "unbounded", which puts a constraint on |
| 133 | * valid list entries. A valid leaf-list or list always has at most |
| 134 | * max-elements entries. |
| 135 | * |
| 136 | * If no "max-elements" statement is present, it defaults to "unbounded". |
| 137 | */ |
Vinod Kumar S | c421600 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 138 | private int maxElements = Integer.MAX_VALUE; |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 139 | |
| 140 | /** |
Vinod Kumar S | c421600 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 141 | * Reference RFC 6020. |
| 142 | * |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 143 | * The "min-elements" statement, which is optional, takes as an argument a |
| 144 | * non-negative integer that puts a constraint on valid list entries. A |
| 145 | * valid leaf-list or list MUST have at least min-elements entries. |
| 146 | * |
| 147 | * If no "min-elements" statement is present, it defaults to zero. |
| 148 | * |
| 149 | * The behavior of the constraint depends on the type of the leaf-list's or |
| 150 | * list's closest ancestor node in the schema tree that is not a non- |
| 151 | * presence container: |
| 152 | * |
| 153 | * o If this ancestor is a case node, the constraint is enforced if any |
| 154 | * other node from the case exists. |
| 155 | * |
| 156 | * o Otherwise, it is enforced if the ancestor node exists. |
| 157 | */ |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 158 | private int minElements = 0; |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 159 | |
| 160 | /** |
| 161 | * reference. |
| 162 | */ |
| 163 | private String reference; |
| 164 | |
| 165 | /** |
| 166 | * Status of the node. |
| 167 | */ |
| 168 | |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 169 | private YangStatusType status = YangStatusType.CURRENT; |
| 170 | |
| 171 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 172 | * Creates a YANG list object. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 173 | */ |
Vinod Kumar S | c421600 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 174 | public YangList() { |
| 175 | super(YangNodeType.LIST_NODE); |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 176 | } |
| 177 | |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 178 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 179 | * Returns the YANG list name. |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 180 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 181 | * @return YANG list name |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 182 | */ |
| 183 | @Override |
| 184 | public String getName() { |
| 185 | return name; |
| 186 | } |
| 187 | |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 188 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 189 | * Sets the YANG list name. |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 190 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 191 | * @param name YANG list name |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 192 | */ |
| 193 | @Override |
| 194 | public void setName(String name) { |
| 195 | this.name = name; |
| 196 | } |
| 197 | |
| 198 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 199 | * Returns the config flag. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 200 | * |
| 201 | * @return the isConfig |
| 202 | */ |
Vidyashree Rama | f4c617c | 2016-02-24 12:28:22 +0530 | [diff] [blame] | 203 | public Boolean isConfig() { |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 204 | return isConfig; |
| 205 | } |
| 206 | |
| 207 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 208 | * Sets the config flag. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 209 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 210 | * @param isCfg the config flag |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 211 | */ |
| 212 | public void setConfig(boolean isCfg) { |
| 213 | isConfig = isCfg; |
| 214 | } |
| 215 | |
| 216 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 217 | * Returns the description. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 218 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 219 | * @return the description |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 220 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 221 | @Override |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 222 | public String getDescription() { |
| 223 | return description; |
| 224 | } |
| 225 | |
| 226 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 227 | * Sets the description. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 228 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 229 | * @param description set the description |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 230 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 231 | @Override |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 232 | public void setDescription(String description) { |
| 233 | this.description = description; |
| 234 | } |
| 235 | |
| 236 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 237 | * Returns the list of key field names. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 238 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 239 | * @return the list of key field names |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 240 | */ |
| 241 | public List<String> getKeyList() { |
| 242 | return keyList; |
| 243 | } |
| 244 | |
| 245 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 246 | * Sets the list of key field names. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 247 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 248 | * @param keyList the list of key field names |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 249 | */ |
| 250 | private void setKeyList(List<String> keyList) { |
| 251 | this.keyList = keyList; |
| 252 | } |
| 253 | |
| 254 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 255 | * Adds a key field name. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 256 | * |
| 257 | * @param key key field name. |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 258 | * @throws DataModelException a violation of data model rules |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 259 | */ |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 260 | public void addKey(String key) |
| 261 | throws DataModelException { |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 262 | if (getKeyList() == null) { |
| 263 | setKeyList(new LinkedList<String>()); |
| 264 | } |
Vidyashree Rama | f4c617c | 2016-02-24 12:28:22 +0530 | [diff] [blame] | 265 | |
| 266 | if (getKeyList().contains(key)) { |
| 267 | throw new DataModelException("A leaf identifier must not appear more than once in the\n" + |
| 268 | " key"); |
| 269 | } |
| 270 | |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 271 | getKeyList().add(key); |
| 272 | } |
| 273 | |
| 274 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 275 | * Returns the list of leaves. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 276 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 277 | * @return the list of leaves |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 278 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 279 | @Override |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 280 | public List<YangLeaf> getListOfLeaf() { |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 281 | return listOfLeaf; |
| 282 | } |
| 283 | |
| 284 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 285 | * Sets the list of leaves. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 286 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 287 | * @param leafsList the list of leaf to set |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 288 | */ |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 289 | @Override |
| 290 | public void setListOfLeaf(List<YangLeaf> leafsList) { |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 291 | listOfLeaf = leafsList; |
| 292 | } |
| 293 | |
| 294 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 295 | * Adds a leaf. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 296 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 297 | * @param leaf the leaf to be added |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 298 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 299 | @Override |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 300 | public void addLeaf(YangLeaf leaf) { |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 301 | if (getListOfLeaf() == null) { |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 302 | setListOfLeaf(new LinkedList<YangLeaf>()); |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 303 | } |
| 304 | |
| 305 | getListOfLeaf().add(leaf); |
| 306 | } |
| 307 | |
| 308 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 309 | * Returns the list of leaf-list. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 310 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 311 | * @return the list of leaf-list |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 312 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 313 | @Override |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 314 | public List<YangLeafList> getListOfLeafList() { |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 315 | return listOfLeafList; |
| 316 | } |
| 317 | |
| 318 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 319 | * Sets the list of leaf-list. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 320 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 321 | * @param listOfLeafList the list of leaf-list to set |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 322 | */ |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 323 | @Override |
| 324 | public void setListOfLeafList(List<YangLeafList> listOfLeafList) { |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 325 | this.listOfLeafList = listOfLeafList; |
| 326 | } |
| 327 | |
| 328 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 329 | * Adds a leaf-list. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 330 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 331 | * @param leafList the leaf-list to be added |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 332 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 333 | @Override |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 334 | public void addLeafList(YangLeafList leafList) { |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 335 | if (getListOfLeafList() == null) { |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 336 | setListOfLeafList(new LinkedList<YangLeafList>()); |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 337 | } |
| 338 | |
| 339 | getListOfLeafList().add(leafList); |
| 340 | } |
| 341 | |
| 342 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 343 | * Returns the max elements. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 344 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 345 | * @return the max elements |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 346 | */ |
Vinod Kumar S | c421600 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 347 | public int getMaxElements() { |
| 348 | return maxElements; |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 349 | } |
| 350 | |
| 351 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 352 | * Sets the max elements. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 353 | * |
Vinod Kumar S | c421600 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 354 | * @param max the max elements |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 355 | */ |
Vinod Kumar S | c421600 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 356 | public void setMaxElements(int max) { |
| 357 | maxElements = max; |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 358 | } |
| 359 | |
| 360 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 361 | * Returns the minimum elements. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 362 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 363 | * @return the minimum elements |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 364 | */ |
| 365 | public int getMinElements() { |
| 366 | return minElements; |
| 367 | } |
| 368 | |
| 369 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 370 | * Sets the minimum elements. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 371 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 372 | * @param minElements the minimum elements |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 373 | */ |
| 374 | public void setMinElements(int minElements) { |
| 375 | this.minElements = minElements; |
| 376 | } |
| 377 | |
| 378 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 379 | * Returns the textual reference. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 380 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 381 | * @return the reference |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 382 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 383 | @Override |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 384 | public String getReference() { |
| 385 | return reference; |
| 386 | } |
| 387 | |
| 388 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 389 | * Sets the textual reference. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 390 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 391 | * @param reference the reference to set |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 392 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 393 | @Override |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 394 | public void setReference(String reference) { |
| 395 | this.reference = reference; |
| 396 | } |
| 397 | |
| 398 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 399 | * Returns the status. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 400 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 401 | * @return the status |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 402 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 403 | @Override |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 404 | public YangStatusType getStatus() { |
| 405 | return status; |
| 406 | } |
| 407 | |
| 408 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 409 | * Sets the status. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 410 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 411 | * @param status the status to set |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 412 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 413 | @Override |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 414 | public void setStatus(YangStatusType status) { |
| 415 | this.status = status; |
| 416 | } |
| 417 | |
| 418 | /** |
| 419 | * Returns the type of the parsed data. |
| 420 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 421 | * @return returns LIST_DATA |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 422 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 423 | @Override |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 424 | public YangConstructType getYangConstructType() { |
| 425 | return YangConstructType.LIST_DATA; |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 426 | } |
| 427 | |
| 428 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 429 | * Validates the data on entering the corresponding parse tree node. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 430 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 431 | * @throws DataModelException a violation of data model rules |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 432 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 433 | @Override |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 434 | public void validateDataOnEntry() |
| 435 | throws DataModelException { |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 436 | // TODO auto-generated method stub, to be implemented by parser |
| 437 | } |
| 438 | |
| 439 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 440 | * Validates the data on exiting the corresponding parse tree node. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 441 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 442 | * @throws DataModelException a violation of data model rules |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 443 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 444 | @Override |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 445 | public void validateDataOnExit() |
| 446 | throws DataModelException { |
Vinod Kumar S | 71cba68 | 2016-02-25 15:52:16 +0530 | [diff] [blame] | 447 | List<String> keys = getKeyList(); |
Vidyashree Rama | f4c617c | 2016-02-24 12:28:22 +0530 | [diff] [blame] | 448 | List<YangLeaf> leaves = getListOfLeaf(); |
| 449 | List<YangLeafList> leafLists = getListOfLeafList(); |
| 450 | |
| 451 | setDefaultConfigValueToChild(leaves, leafLists); |
| 452 | validateConfig(leaves, leafLists); |
| 453 | |
| 454 | /* A list must have atleast one key leaf if config is true */ |
janani b | dd1314f | 2016-05-19 17:39:50 +0530 | [diff] [blame] | 455 | if (isConfig && (keys == null || leaves == null && leafLists == null) && !isUsesPresentInList() |
| 456 | && !isListPresentInGrouping()) { |
Vinod Kumar S | 71cba68 | 2016-02-25 15:52:16 +0530 | [diff] [blame] | 457 | throw new DataModelException("A list must have atleast one key leaf if config is true;"); |
| 458 | } else if (keys != null) { |
Vidyashree Rama | 1db1556 | 2016-05-17 16:16:15 +0530 | [diff] [blame] | 459 | validateKey(leaves, leafLists, keys); |
Vidyashree Rama | f4c617c | 2016-02-24 12:28:22 +0530 | [diff] [blame] | 460 | } |
| 461 | } |
| 462 | |
| 463 | /** |
Vinod Kumar S | 71cba68 | 2016-02-25 15:52:16 +0530 | [diff] [blame] | 464 | * Sets the config's value to all leaf if leaf's config statement is not |
| 465 | * specified. |
Vidyashree Rama | f4c617c | 2016-02-24 12:28:22 +0530 | [diff] [blame] | 466 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 467 | * @param leaves list of leaf attributes of YANG list |
| 468 | * @param leafLists list of leaf-list attributes of YANG list |
Vidyashree Rama | f4c617c | 2016-02-24 12:28:22 +0530 | [diff] [blame] | 469 | */ |
| 470 | private void setDefaultConfigValueToChild(List<YangLeaf> leaves, List<YangLeafList> leafLists) { |
| 471 | |
Vinod Kumar S | 71cba68 | 2016-02-25 15:52:16 +0530 | [diff] [blame] | 472 | /* |
| 473 | * If "config" is not specified, the default is the same as the parent |
| 474 | * schema node's "config" value. |
| 475 | */ |
Vidyashree Rama | f4c617c | 2016-02-24 12:28:22 +0530 | [diff] [blame] | 476 | if (leaves != null) { |
| 477 | for (YangLeaf leaf : leaves) { |
| 478 | if (leaf.isConfig() == null) { |
| 479 | leaf.setConfig(isConfig); |
| 480 | } |
| 481 | } |
| 482 | } |
| 483 | |
Vinod Kumar S | 71cba68 | 2016-02-25 15:52:16 +0530 | [diff] [blame] | 484 | /* |
| 485 | * If "config" is not specified, the default is the same as the parent |
| 486 | * schema node's "config" value. |
| 487 | */ |
Vidyashree Rama | f4c617c | 2016-02-24 12:28:22 +0530 | [diff] [blame] | 488 | if (leafLists != null) { |
| 489 | for (YangLeafList leafList : leafLists) { |
| 490 | if (leafList.isConfig() == null) { |
| 491 | leafList.setConfig(isConfig); |
| 492 | } |
| 493 | } |
| 494 | } |
| 495 | } |
| 496 | |
| 497 | /** |
| 498 | * Validates config statement of YANG list. |
| 499 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 500 | * @param leaves list of leaf attributes of YANG list |
| 501 | * @param leafLists list of leaf-list attributes of YANG list |
| 502 | * @throws DataModelException a violation of data model rules |
Vidyashree Rama | f4c617c | 2016-02-24 12:28:22 +0530 | [diff] [blame] | 503 | */ |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 504 | private void validateConfig(List<YangLeaf> leaves, List<YangLeafList> leafLists) |
| 505 | throws DataModelException { |
Vidyashree Rama | f4c617c | 2016-02-24 12:28:22 +0530 | [diff] [blame] | 506 | |
Vinod Kumar S | 71cba68 | 2016-02-25 15:52:16 +0530 | [diff] [blame] | 507 | /* |
| 508 | * If a node has "config" set to "false", no node underneath it can have |
| 509 | * "config" set to "true". |
| 510 | */ |
Vinod Kumar S | c421600 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 511 | if (!isConfig && leaves != null) { |
Vidyashree Rama | f4c617c | 2016-02-24 12:28:22 +0530 | [diff] [blame] | 512 | for (YangLeaf leaf : leaves) { |
| 513 | if (leaf.isConfig()) { |
| 514 | throw new DataModelException("If a list has \"config\" set to \"false\", no node underneath " + |
| 515 | "it can have \"config\" set to \"true\"."); |
| 516 | } |
| 517 | } |
| 518 | } |
| 519 | |
Vinod Kumar S | c421600 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 520 | if (!isConfig && leafLists != null) { |
Vidyashree Rama | f4c617c | 2016-02-24 12:28:22 +0530 | [diff] [blame] | 521 | for (YangLeafList leafList : leafLists) { |
| 522 | if (leafList.isConfig()) { |
| 523 | throw new DataModelException("If a list has \"config\" set to \"false\", no node underneath " + |
| 524 | "it can have \"config\" set to \"true\"."); |
| 525 | } |
| 526 | } |
| 527 | } |
| 528 | } |
| 529 | |
| 530 | /** |
| 531 | * Validates key statement of list. |
| 532 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 533 | * @param leaves list of leaf attributes of list |
Vidyashree Rama | 1db1556 | 2016-05-17 16:16:15 +0530 | [diff] [blame] | 534 | * @param leafLists list of leaf-list attributes of list |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 535 | * @param keys list of key attributes of list |
| 536 | * @throws DataModelException a violation of data model rules |
Vidyashree Rama | f4c617c | 2016-02-24 12:28:22 +0530 | [diff] [blame] | 537 | */ |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 538 | private void validateKey(List<YangLeaf> leaves, List<YangLeafList> leafLists, List<String> keys) |
| 539 | throws |
Vidyashree Rama | 1db1556 | 2016-05-17 16:16:15 +0530 | [diff] [blame] | 540 | DataModelException { |
Vidyashree Rama | f4c617c | 2016-02-24 12:28:22 +0530 | [diff] [blame] | 541 | boolean leafFound = false; |
| 542 | List<YangLeaf> keyLeaves = new LinkedList<>(); |
Vidyashree Rama | 1db1556 | 2016-05-17 16:16:15 +0530 | [diff] [blame] | 543 | List<YangLeafList> keyLeafLists = new LinkedList<>(); |
Vidyashree Rama | f4c617c | 2016-02-24 12:28:22 +0530 | [diff] [blame] | 544 | |
Vinod Kumar S | 71cba68 | 2016-02-25 15:52:16 +0530 | [diff] [blame] | 545 | /* |
| 546 | * 1. Leaf identifier must refer to a child leaf of the list 2. A leaf |
| 547 | * that is part of the key must not be the built-in type "empty". |
| 548 | */ |
| 549 | for (String key : keys) { |
Vidyashree Rama | 1db1556 | 2016-05-17 16:16:15 +0530 | [diff] [blame] | 550 | if (leaves != null && !leaves.isEmpty()) { |
| 551 | for (YangLeaf leaf : leaves) { |
| 552 | if (key.equals(leaf.getName())) { |
| 553 | if (leaf.getDataType().getDataType() == YangDataTypes.EMPTY) { |
| 554 | throw new DataModelException(" A leaf that is part of the key must not be the built-in " + |
| 555 | "type \"empty\"."); |
| 556 | } |
| 557 | leafFound = true; |
| 558 | keyLeaves.add(leaf); |
| 559 | break; |
Vidyashree Rama | f4c617c | 2016-02-24 12:28:22 +0530 | [diff] [blame] | 560 | } |
Vidyashree Rama | f4c617c | 2016-02-24 12:28:22 +0530 | [diff] [blame] | 561 | } |
| 562 | } |
Vidyashree Rama | 1db1556 | 2016-05-17 16:16:15 +0530 | [diff] [blame] | 563 | |
| 564 | if (leafLists != null && !leafLists.isEmpty()) { |
| 565 | for (YangLeafList leafList : leafLists) { |
| 566 | if (key.equals(leafList.getName())) { |
| 567 | if (leafList.getDataType().getDataType() == YangDataTypes.EMPTY) { |
| 568 | throw new DataModelException(" A leaf-list that is part of the key" + |
| 569 | " must not be the built-in type \"empty\"."); |
| 570 | } |
| 571 | leafFound = true; |
| 572 | keyLeafLists.add(leafList); |
| 573 | break; |
| 574 | } |
| 575 | } |
| 576 | } |
| 577 | |
janani b | dd1314f | 2016-05-19 17:39:50 +0530 | [diff] [blame] | 578 | if (!leafFound && !isUsesPresentInList() && !isListPresentInGrouping()) { |
Vidyashree Rama | 1db1556 | 2016-05-17 16:16:15 +0530 | [diff] [blame] | 579 | throw new DataModelException("An identifier, in key, must refer to a child leaf of the list"); |
Vidyashree Rama | f4c617c | 2016-02-24 12:28:22 +0530 | [diff] [blame] | 580 | } |
| 581 | leafFound = false; |
| 582 | } |
| 583 | |
Vinod Kumar S | 71cba68 | 2016-02-25 15:52:16 +0530 | [diff] [blame] | 584 | /* |
| 585 | * All key leafs in a list MUST have the same value for their "config" |
| 586 | * as the list itself. |
| 587 | */ |
Vidyashree Rama | f4c617c | 2016-02-24 12:28:22 +0530 | [diff] [blame] | 588 | for (YangLeaf keyLeaf : keyLeaves) { |
| 589 | if (isConfig != keyLeaf.isConfig()) { |
| 590 | throw new DataModelException("All key leafs in a list must have the same value for their" + |
| 591 | " \"config\" as the list itself."); |
| 592 | } |
| 593 | } |
Vidyashree Rama | f4c617c | 2016-02-24 12:28:22 +0530 | [diff] [blame] | 594 | |
Vidyashree Rama | 1db1556 | 2016-05-17 16:16:15 +0530 | [diff] [blame] | 595 | /* |
Vinod Kumar S | 71cba68 | 2016-02-25 15:52:16 +0530 | [diff] [blame] | 596 | * All key leafs in a list MUST have the same value for their "config" |
| 597 | * as the list itself. |
| 598 | */ |
Vidyashree Rama | f4c617c | 2016-02-24 12:28:22 +0530 | [diff] [blame] | 599 | for (YangLeafList keyLeafList : keyLeafLists) { |
| 600 | if (isConfig() != keyLeafList.isConfig()) { |
| 601 | throw new DataModelException("All key leaf-lists in a list must have the same value for their" + |
| 602 | " \"config\" as the list itself."); |
| 603 | } |
| 604 | } |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 605 | } |
| 606 | |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 607 | @Override |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 608 | public void detectCollidingChild(String identifierName, YangConstructType dataType) |
| 609 | throws DataModelException { |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 610 | // Asks helper to detect colliding child. |
| 611 | detectCollidingChildUtil(identifierName, dataType, this); |
| 612 | } |
| 613 | |
| 614 | @Override |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 615 | public void detectSelfCollision(String identifierName, YangConstructType dataType) |
| 616 | throws DataModelException { |
Vinod Kumar S | 3804650 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 617 | if (getName().equals(identifierName)) { |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 618 | throw new DataModelException("YANG file error: Duplicate input identifier detected, same as list \"" + |
Vinod Kumar S | 3804650 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 619 | getName() + "\""); |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 620 | } |
| 621 | } |
Vidyashree Rama | 1db1556 | 2016-05-17 16:16:15 +0530 | [diff] [blame] | 622 | |
| 623 | private boolean isUsesPresentInList() { |
Bharat saraswal | 96dfef0 | 2016-06-16 00:29:12 +0530 | [diff] [blame^] | 624 | YangNode node = getChild(); |
Vidyashree Rama | 1db1556 | 2016-05-17 16:16:15 +0530 | [diff] [blame] | 625 | while (node != null) { |
| 626 | if (node instanceof YangUses) { |
| 627 | return true; |
| 628 | } |
| 629 | node = node.getNextSibling(); |
| 630 | } |
| 631 | return false; |
janani b | dd1314f | 2016-05-19 17:39:50 +0530 | [diff] [blame] | 632 | // TODO When grouping linking is done this method has to be modified. |
Vidyashree Rama | 1db1556 | 2016-05-17 16:16:15 +0530 | [diff] [blame] | 633 | } |
| 634 | |
janani b | dd1314f | 2016-05-19 17:39:50 +0530 | [diff] [blame] | 635 | private boolean isListPresentInGrouping() { |
Bharat saraswal | 96dfef0 | 2016-06-16 00:29:12 +0530 | [diff] [blame^] | 636 | YangNode node = getParent(); |
janani b | dd1314f | 2016-05-19 17:39:50 +0530 | [diff] [blame] | 637 | while (node != null) { |
| 638 | if (node instanceof YangGrouping) { |
| 639 | return true; |
| 640 | } |
| 641 | node = node.getParent(); |
| 642 | } |
| 643 | return false; |
| 644 | // TODO When grouping linking is done this method has to be modified. |
| 645 | } |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 646 | } |