Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +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 | 19f39c7 | 2016-02-09 20:12:31 +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 | |
Bharat saraswal | 96dfef0 | 2016-06-16 00:29:12 +0530 | [diff] [blame] | 19 | import java.io.Serializable; |
Vidyashree Rama | deac28b | 2016-06-20 15:12:43 +0530 | [diff] [blame^] | 20 | import java.util.LinkedList; |
| 21 | import java.util.List; |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +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 | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 25 | |
| 26 | /* |
| 27 | * Reference:RFC 6020. |
| 28 | * Where the "leaf" statement is used to define a simple scalar variable |
| 29 | * of a particular type, the "leaf-list" statement is used to define an |
| 30 | * array of a particular type. The "leaf-list" statement takes one |
| 31 | * argument, which is an identifier, followed by a block of |
| 32 | * sub-statements that holds detailed leaf-list information. |
| 33 | * |
| 34 | * The values in a leaf-list MUST be unique. |
| 35 | * |
| 36 | * The leaf-list's sub-statements |
| 37 | * |
| 38 | * +--------------+---------+-------------+------------------+ |
| 39 | * | substatement | section | cardinality |data model mapping| |
| 40 | * +--------------+---------+-------------+------------------+ |
| 41 | * | config | 7.19.1 | 0..1 | -boolean | |
| 42 | * | description | 7.19.3 | 0..1 | -string | |
Vidyashree Rama | deac28b | 2016-06-20 15:12:43 +0530 | [diff] [blame^] | 43 | * | if-feature | 7.18.2 | 0..n | -YangIfFeature | |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 44 | * | max-elements | 7.7.4 | 0..1 | -int | |
| 45 | * | min-elements | 7.7.3 | 0..1 | -int | |
Vidyashree Rama | deac28b | 2016-06-20 15:12:43 +0530 | [diff] [blame^] | 46 | * | must | 7.5.3 | 0..n | -YangMust | |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 47 | * | ordered-by | 7.7.5 | 0..1 | -TODO | |
| 48 | * | reference | 7.19.4 | 0..1 | -string | |
| 49 | * | status | 7.19.2 | 0..1 | -YangStatus | |
| 50 | * | type | 7.4 | 1 | -YangType | |
| 51 | * | units | 7.3.3 | 0..1 | -string | |
Vidyashree Rama | deac28b | 2016-06-20 15:12:43 +0530 | [diff] [blame^] | 52 | * | when | 7.19.5 | 0..1 | -YangWhen | |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 53 | * +--------------+---------+-------------+------------------+ |
| 54 | */ |
Vinod Kumar S | e4b9b0c | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 55 | |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 56 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 57 | * Represents leaf-list data represented in YANG. |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 58 | */ |
Vinod Kumar S | e4b9b0c | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 59 | public class YangLeafList |
Vidyashree Rama | deac28b | 2016-06-20 15:12:43 +0530 | [diff] [blame^] | 60 | implements YangCommonInfo, Parsable, Cloneable, Serializable, |
| 61 | YangMustHolder, YangWhenHolder, YangIfFeatureHolder { |
Bharat saraswal | 96dfef0 | 2016-06-16 00:29:12 +0530 | [diff] [blame] | 62 | |
| 63 | private static final long serialVersionUID = 806201637L; |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 64 | |
| 65 | /** |
| 66 | * Name of leaf-list. |
| 67 | */ |
| 68 | private String name; |
| 69 | |
| 70 | /** |
| 71 | * If the leaf-list is a config parameter. |
| 72 | */ |
Vidyashree Rama | f4c617c | 2016-02-24 12:28:22 +0530 | [diff] [blame] | 73 | private Boolean isConfig; |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 74 | |
| 75 | /** |
| 76 | * Description of leaf-list. |
| 77 | */ |
| 78 | private String description; |
| 79 | |
| 80 | /** |
| 81 | * Reference:RFC 6020. |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 82 | * |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 83 | * The "max-elements" statement, which is optional, takes as an argument a |
| 84 | * positive integer or the string "unbounded", which puts a constraint on |
| 85 | * valid list entries. A valid leaf-list or list always has at most |
| 86 | * max-elements entries. |
| 87 | * |
| 88 | * If no "max-elements" statement is present, it defaults to "unbounded". |
| 89 | */ |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 90 | private int maxElelements = Integer.MAX_VALUE; |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 91 | |
| 92 | /** |
| 93 | * Reference:RFC 6020. |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 94 | * |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 95 | * The "min-elements" statement, which is optional, takes as an argument a |
| 96 | * non-negative integer that puts a constraint on valid list entries. A |
| 97 | * valid leaf-list or list MUST have at least min-elements entries. |
| 98 | * |
| 99 | * If no "min-elements" statement is present, it defaults to zero. |
| 100 | * |
| 101 | * The behavior of the constraint depends on the type of the leaf-list's or |
| 102 | * list's closest ancestor node in the schema tree that is not a non- |
| 103 | * presence container: |
| 104 | * |
| 105 | * o If this ancestor is a case node, the constraint is enforced if any |
| 106 | * other node from the case exists. |
| 107 | * |
| 108 | * o Otherwise, it is enforced if the ancestor node exists. |
| 109 | */ |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 110 | private int minElements = 0; |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 111 | |
| 112 | /** |
| 113 | * The textual reference to this leaf-list. |
| 114 | */ |
| 115 | private String reference; |
| 116 | |
| 117 | /** |
| 118 | * Status of the leaf-list in the YANG definition. |
| 119 | */ |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 120 | private YangStatusType status = YangStatusType.CURRENT; |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 121 | |
| 122 | /** |
| 123 | * Textual units. |
| 124 | */ |
| 125 | private String units; |
| 126 | |
| 127 | /** |
| 128 | * Data type of leaf-list. |
| 129 | */ |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 130 | private YangType<?> dataType; |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 131 | |
| 132 | /** |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 133 | * YANG Node in which the leaf is contained. |
| 134 | */ |
Bharat saraswal | 96dfef0 | 2016-06-16 00:29:12 +0530 | [diff] [blame] | 135 | private transient YangLeavesHolder containedIn; |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 136 | |
| 137 | /** |
Vidyashree Rama | deac28b | 2016-06-20 15:12:43 +0530 | [diff] [blame^] | 138 | * List of must statement constraints. |
| 139 | */ |
| 140 | private List<YangMust> mustConstraintList; |
| 141 | |
| 142 | /** |
| 143 | * When data of the leaf. |
| 144 | */ |
| 145 | private YangWhen when; |
| 146 | |
| 147 | /** |
| 148 | * List of if-feature. |
| 149 | */ |
| 150 | private List<YangIfFeature> ifFeatureList; |
| 151 | |
| 152 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 153 | * Creates a YANG leaf-list. |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 154 | */ |
| 155 | public YangLeafList() { |
| 156 | } |
| 157 | |
| 158 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 159 | * Returns the leaf-list name. |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 160 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 161 | * @return the leaf-list name |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 162 | */ |
Vinod Kumar S | e4b9b0c | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 163 | public String getName() { |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 164 | return name; |
| 165 | } |
| 166 | |
| 167 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 168 | * Sets the leaf-list name. |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 169 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 170 | * @param leafListName the leaf-list name to set |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 171 | */ |
| 172 | public void setLeafName(String leafListName) { |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 173 | name = leafListName; |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 174 | } |
| 175 | |
| 176 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 177 | * Returns the config flag. |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 178 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 179 | * @return the config flag |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 180 | */ |
Vidyashree Rama | f4c617c | 2016-02-24 12:28:22 +0530 | [diff] [blame] | 181 | public Boolean isConfig() { |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 182 | return isConfig; |
| 183 | } |
| 184 | |
| 185 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 186 | * Sets the config flag. |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 187 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 188 | * @param isCfg the config flag |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 189 | */ |
| 190 | public void setConfig(boolean isCfg) { |
| 191 | isConfig = isCfg; |
| 192 | } |
| 193 | |
| 194 | /** |
Vidyashree Rama | deac28b | 2016-06-20 15:12:43 +0530 | [diff] [blame^] | 195 | * Returns the when. |
| 196 | * |
| 197 | * @return the when |
| 198 | */ |
| 199 | @Override |
| 200 | public YangWhen getWhen() { |
| 201 | return when; |
| 202 | } |
| 203 | |
| 204 | /** |
| 205 | * Sets the when. |
| 206 | * |
| 207 | * @param when the when to set |
| 208 | */ |
| 209 | @Override |
| 210 | public void setWhen(YangWhen when) { |
| 211 | this.when = when; |
| 212 | } |
| 213 | |
| 214 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 215 | * Returns the description. |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 216 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 217 | * @return the description |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 218 | */ |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 219 | @Override |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 220 | public String getDescription() { |
| 221 | return description; |
| 222 | } |
| 223 | |
| 224 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 225 | * Sets the description. |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 226 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 227 | * @param description set the description |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 228 | */ |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 229 | @Override |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 230 | public void setDescription(String description) { |
| 231 | this.description = description; |
| 232 | } |
| 233 | |
| 234 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 235 | * Returns the max elements no. |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 236 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 237 | * @return the max elements no |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 238 | */ |
| 239 | public int getMaxElelements() { |
| 240 | return maxElelements; |
| 241 | } |
| 242 | |
| 243 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 244 | * Sets the max elements no. |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 245 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 246 | * @param maxElelements max elements no |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 247 | */ |
| 248 | public void setMaxElelements(int maxElelements) { |
| 249 | this.maxElelements = maxElelements; |
| 250 | } |
| 251 | |
| 252 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 253 | * Returns the min elements no. |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 254 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 255 | * @return the min elements no |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 256 | */ |
| 257 | public int getMinElements() { |
| 258 | return minElements; |
| 259 | } |
| 260 | |
| 261 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 262 | * Sets the min elements no. |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 263 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 264 | * @param minElements the min elements no |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 265 | */ |
| 266 | public void setMinElements(int minElements) { |
| 267 | this.minElements = minElements; |
| 268 | } |
| 269 | |
| 270 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 271 | * Returns the textual reference. |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 272 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 273 | * @return the reference |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 274 | */ |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 275 | @Override |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 276 | public String getReference() { |
| 277 | return reference; |
| 278 | } |
| 279 | |
| 280 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 281 | * Sets the textual reference. |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 282 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 283 | * @param reference the reference to set |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 284 | */ |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 285 | @Override |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 286 | public void setReference(String reference) { |
| 287 | this.reference = reference; |
| 288 | } |
| 289 | |
| 290 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 291 | * Returns the status. |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 292 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 293 | * @return the status |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 294 | */ |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 295 | @Override |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 296 | public YangStatusType getStatus() { |
| 297 | return status; |
| 298 | } |
| 299 | |
| 300 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 301 | * Sets the status. |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 302 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 303 | * @param status the status to set |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 304 | */ |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 305 | @Override |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 306 | public void setStatus(YangStatusType status) { |
| 307 | this.status = status; |
| 308 | } |
| 309 | |
| 310 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 311 | * Returns the units. |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 312 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 313 | * @return the units |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 314 | */ |
| 315 | public String getUnits() { |
| 316 | return units; |
| 317 | } |
| 318 | |
| 319 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 320 | * Sets the units. |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 321 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 322 | * @param units the units to set |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 323 | */ |
| 324 | public void setUnits(String units) { |
| 325 | this.units = units; |
| 326 | } |
| 327 | |
| 328 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 329 | * Returns the data type. |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 330 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 331 | * @return the data type |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 332 | */ |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 333 | public YangType<?> getDataType() { |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 334 | return dataType; |
| 335 | } |
| 336 | |
| 337 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 338 | * Sets the data type. |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 339 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 340 | * @param dataType the data type to set |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 341 | */ |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 342 | public void setDataType(YangType<?> dataType) { |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 343 | this.dataType = dataType; |
| 344 | } |
| 345 | |
| 346 | /** |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 347 | * Retrieves the YANG node in which the leaf is defined. |
| 348 | * |
| 349 | * @return the YANG node in which the leaf is defined |
| 350 | */ |
| 351 | public YangLeavesHolder getContainedIn() { |
| 352 | return containedIn; |
| 353 | } |
| 354 | |
| 355 | /** |
| 356 | * Assigns the YANG node in which the leaf is defined. |
| 357 | * |
| 358 | * @param containedIn the YANG node in which the leaf is defined |
| 359 | */ |
| 360 | public void setContainedIn(YangLeavesHolder containedIn) { |
| 361 | this.containedIn = containedIn; |
| 362 | } |
| 363 | |
| 364 | @Override |
| 365 | public YangLeafList clone() |
| 366 | throws CloneNotSupportedException { |
| 367 | return (YangLeafList) super.clone(); |
| 368 | } |
| 369 | |
| 370 | /** |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 371 | * Returns the type of the parsed data. |
| 372 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 373 | * @return returns LEAF_LIST_DATA |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 374 | */ |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 375 | @Override |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 376 | public YangConstructType getYangConstructType() { |
| 377 | return YangConstructType.LEAF_LIST_DATA; |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 378 | } |
| 379 | |
| 380 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 381 | * Validates the data on entering the corresponding parse tree node. |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 382 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 383 | * @throws DataModelException a violation of data model rules |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 384 | */ |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 385 | @Override |
Vinod Kumar S | e4b9b0c | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 386 | public void validateDataOnEntry() |
| 387 | throws DataModelException { |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 388 | // TODO auto-generated method stub, to be implemented by parser |
| 389 | |
| 390 | } |
| 391 | |
| 392 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 393 | * Validates the data on exiting the corresponding parse tree node. |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 394 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 395 | * @throws DataModelException a violation of data model rules |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 396 | */ |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 397 | @Override |
Vinod Kumar S | e4b9b0c | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 398 | public void validateDataOnExit() |
| 399 | throws DataModelException { |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 400 | // TODO auto-generated method stub, to be implemented by parser |
| 401 | |
| 402 | } |
Vidyashree Rama | deac28b | 2016-06-20 15:12:43 +0530 | [diff] [blame^] | 403 | |
| 404 | @Override |
| 405 | public List<YangIfFeature> getIfFeatureList() { |
| 406 | return ifFeatureList; |
| 407 | } |
| 408 | |
| 409 | @Override |
| 410 | public void addIfFeatureList(YangIfFeature ifFeature) { |
| 411 | if (getIfFeatureList() == null) { |
| 412 | setIfFeatureList(new LinkedList<>()); |
| 413 | } |
| 414 | getIfFeatureList().add(ifFeature); |
| 415 | } |
| 416 | |
| 417 | @Override |
| 418 | public void setIfFeatureList(List<YangIfFeature> ifFeatureList) { |
| 419 | this.ifFeatureList = ifFeatureList; |
| 420 | } |
| 421 | |
| 422 | @Override |
| 423 | public List<YangMust> getListOfMust() { |
| 424 | return mustConstraintList; |
| 425 | } |
| 426 | |
| 427 | @Override |
| 428 | public void setListOfMust(List<YangMust> mustConstraintList) { |
| 429 | this.mustConstraintList = mustConstraintList; |
| 430 | } |
| 431 | |
| 432 | @Override |
| 433 | public void addMust(YangMust must) { |
| 434 | if (getListOfMust() == null) { |
| 435 | setListOfMust(new LinkedList<>()); |
| 436 | } |
| 437 | getListOfMust().add(must); |
| 438 | } |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 439 | } |