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, |
Gaurav Agrawal | 72cd1b7 | 2016-06-30 13:28:14 +0530 | [diff] [blame] | 61 | YangMustHolder, YangWhenHolder, YangIfFeatureHolder, YangDataNode { |
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 | */ |
rama-huawei | 6c728a9 | 2016-07-11 14:48:12 +0530 | [diff] [blame^] | 90 | private YangMaxElement maxElement; |
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 | */ |
rama-huawei | 6c728a9 | 2016-07-11 14:48:12 +0530 | [diff] [blame^] | 110 | private YangMinElement minElements; |
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() { |
rama-huawei | 6c728a9 | 2016-07-11 14:48:12 +0530 | [diff] [blame^] | 156 | setMinElements(new YangMinElement()); |
| 157 | setMaxElements(new YangMaxElement()); |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 158 | } |
| 159 | |
| 160 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 161 | * Returns the leaf-list name. |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 162 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 163 | * @return the leaf-list name |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 164 | */ |
Vinod Kumar S | e4b9b0c | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 165 | public String getName() { |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 166 | return name; |
| 167 | } |
| 168 | |
| 169 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 170 | * Sets the leaf-list name. |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 171 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 172 | * @param leafListName the leaf-list name to set |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 173 | */ |
| 174 | public void setLeafName(String leafListName) { |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 175 | name = leafListName; |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 179 | * Returns the config flag. |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 180 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 181 | * @return the config flag |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 182 | */ |
Vidyashree Rama | f4c617c | 2016-02-24 12:28:22 +0530 | [diff] [blame] | 183 | public Boolean isConfig() { |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 184 | return isConfig; |
| 185 | } |
| 186 | |
| 187 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 188 | * Sets the config flag. |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 189 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 190 | * @param isCfg the config flag |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 191 | */ |
| 192 | public void setConfig(boolean isCfg) { |
| 193 | isConfig = isCfg; |
| 194 | } |
| 195 | |
| 196 | /** |
Vidyashree Rama | deac28b | 2016-06-20 15:12:43 +0530 | [diff] [blame] | 197 | * Returns the when. |
| 198 | * |
| 199 | * @return the when |
| 200 | */ |
| 201 | @Override |
| 202 | public YangWhen getWhen() { |
| 203 | return when; |
| 204 | } |
| 205 | |
| 206 | /** |
| 207 | * Sets the when. |
| 208 | * |
| 209 | * @param when the when to set |
| 210 | */ |
| 211 | @Override |
| 212 | public void setWhen(YangWhen when) { |
| 213 | this.when = when; |
| 214 | } |
| 215 | |
| 216 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 217 | * Returns the description. |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 218 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 219 | * @return the description |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 220 | */ |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 221 | @Override |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +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 | 19f39c7 | 2016-02-09 20:12:31 +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 | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 230 | */ |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 231 | @Override |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 232 | public void setDescription(String description) { |
| 233 | this.description = description; |
| 234 | } |
| 235 | |
| 236 | /** |
rama-huawei | 6c728a9 | 2016-07-11 14:48:12 +0530 | [diff] [blame^] | 237 | * Returns the maximum elements number. |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 238 | * |
rama-huawei | 6c728a9 | 2016-07-11 14:48:12 +0530 | [diff] [blame^] | 239 | * @return the maximum elements number |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 240 | */ |
rama-huawei | 6c728a9 | 2016-07-11 14:48:12 +0530 | [diff] [blame^] | 241 | public YangMaxElement getMaxElements() { |
| 242 | return maxElement; |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 243 | } |
| 244 | |
| 245 | /** |
rama-huawei | 6c728a9 | 2016-07-11 14:48:12 +0530 | [diff] [blame^] | 246 | * Sets the maximum elements number. |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 247 | * |
rama-huawei | 6c728a9 | 2016-07-11 14:48:12 +0530 | [diff] [blame^] | 248 | * @param maxElement maximum elements number |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 249 | */ |
rama-huawei | 6c728a9 | 2016-07-11 14:48:12 +0530 | [diff] [blame^] | 250 | public void setMaxElements(YangMaxElement maxElement) { |
| 251 | this.maxElement = maxElement; |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 252 | } |
| 253 | |
| 254 | /** |
rama-huawei | 6c728a9 | 2016-07-11 14:48:12 +0530 | [diff] [blame^] | 255 | * Returns the minimum elements number. |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 256 | * |
rama-huawei | 6c728a9 | 2016-07-11 14:48:12 +0530 | [diff] [blame^] | 257 | * @return the minimum elements number |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 258 | */ |
rama-huawei | 6c728a9 | 2016-07-11 14:48:12 +0530 | [diff] [blame^] | 259 | public YangMinElement getMinElements() { |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 260 | return minElements; |
| 261 | } |
| 262 | |
| 263 | /** |
rama-huawei | 6c728a9 | 2016-07-11 14:48:12 +0530 | [diff] [blame^] | 264 | * Sets the minimum elements number. |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 265 | * |
rama-huawei | 6c728a9 | 2016-07-11 14:48:12 +0530 | [diff] [blame^] | 266 | * @param minElements the minimum elements number |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 267 | */ |
rama-huawei | 6c728a9 | 2016-07-11 14:48:12 +0530 | [diff] [blame^] | 268 | public void setMinElements(YangMinElement minElements) { |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 269 | this.minElements = minElements; |
| 270 | } |
| 271 | |
| 272 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 273 | * Returns the textual reference. |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 274 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 275 | * @return the reference |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 276 | */ |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 277 | @Override |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 278 | public String getReference() { |
| 279 | return reference; |
| 280 | } |
| 281 | |
| 282 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 283 | * Sets the textual reference. |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 284 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 285 | * @param reference the reference to set |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 286 | */ |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 287 | @Override |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 288 | public void setReference(String reference) { |
| 289 | this.reference = reference; |
| 290 | } |
| 291 | |
| 292 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 293 | * Returns the status. |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 294 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 295 | * @return the status |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 296 | */ |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 297 | @Override |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 298 | public YangStatusType getStatus() { |
| 299 | return status; |
| 300 | } |
| 301 | |
| 302 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 303 | * Sets the status. |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 304 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 305 | * @param status the status to set |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 306 | */ |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 307 | @Override |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 308 | public void setStatus(YangStatusType status) { |
| 309 | this.status = status; |
| 310 | } |
| 311 | |
| 312 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 313 | * Returns the units. |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 314 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 315 | * @return the units |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 316 | */ |
| 317 | public String getUnits() { |
| 318 | return units; |
| 319 | } |
| 320 | |
| 321 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 322 | * Sets the units. |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 323 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 324 | * @param units the units to set |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 325 | */ |
| 326 | public void setUnits(String units) { |
| 327 | this.units = units; |
| 328 | } |
| 329 | |
| 330 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 331 | * Returns the data type. |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 332 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 333 | * @return the data type |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 334 | */ |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 335 | public YangType<?> getDataType() { |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 336 | return dataType; |
| 337 | } |
| 338 | |
| 339 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 340 | * Sets the data type. |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 341 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 342 | * @param dataType the data type to set |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 343 | */ |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 344 | public void setDataType(YangType<?> dataType) { |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 345 | this.dataType = dataType; |
| 346 | } |
| 347 | |
| 348 | /** |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 349 | * Retrieves the YANG node in which the leaf is defined. |
| 350 | * |
| 351 | * @return the YANG node in which the leaf is defined |
| 352 | */ |
| 353 | public YangLeavesHolder getContainedIn() { |
| 354 | return containedIn; |
| 355 | } |
| 356 | |
| 357 | /** |
| 358 | * Assigns the YANG node in which the leaf is defined. |
| 359 | * |
| 360 | * @param containedIn the YANG node in which the leaf is defined |
| 361 | */ |
| 362 | public void setContainedIn(YangLeavesHolder containedIn) { |
| 363 | this.containedIn = containedIn; |
| 364 | } |
| 365 | |
| 366 | @Override |
| 367 | public YangLeafList clone() |
| 368 | throws CloneNotSupportedException { |
| 369 | return (YangLeafList) super.clone(); |
| 370 | } |
| 371 | |
| 372 | /** |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 373 | * Returns the type of the parsed data. |
| 374 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 375 | * @return returns LEAF_LIST_DATA |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 376 | */ |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 377 | @Override |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 378 | public YangConstructType getYangConstructType() { |
| 379 | return YangConstructType.LEAF_LIST_DATA; |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 380 | } |
| 381 | |
| 382 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 383 | * Validates the data on entering the corresponding parse tree node. |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 384 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 385 | * @throws DataModelException a violation of data model rules |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 386 | */ |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 387 | @Override |
Vinod Kumar S | e4b9b0c | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 388 | public void validateDataOnEntry() |
| 389 | throws DataModelException { |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 390 | // TODO auto-generated method stub, to be implemented by parser |
| 391 | |
| 392 | } |
| 393 | |
| 394 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 395 | * Validates the data on exiting the corresponding parse tree node. |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 396 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 397 | * @throws DataModelException a violation of data model rules |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 398 | */ |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 399 | @Override |
Vinod Kumar S | e4b9b0c | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 400 | public void validateDataOnExit() |
| 401 | throws DataModelException { |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 402 | // TODO auto-generated method stub, to be implemented by parser |
| 403 | |
| 404 | } |
Vidyashree Rama | deac28b | 2016-06-20 15:12:43 +0530 | [diff] [blame] | 405 | |
| 406 | @Override |
| 407 | public List<YangIfFeature> getIfFeatureList() { |
| 408 | return ifFeatureList; |
| 409 | } |
| 410 | |
| 411 | @Override |
| 412 | public void addIfFeatureList(YangIfFeature ifFeature) { |
| 413 | if (getIfFeatureList() == null) { |
| 414 | setIfFeatureList(new LinkedList<>()); |
| 415 | } |
| 416 | getIfFeatureList().add(ifFeature); |
| 417 | } |
| 418 | |
| 419 | @Override |
| 420 | public void setIfFeatureList(List<YangIfFeature> ifFeatureList) { |
| 421 | this.ifFeatureList = ifFeatureList; |
| 422 | } |
| 423 | |
| 424 | @Override |
| 425 | public List<YangMust> getListOfMust() { |
| 426 | return mustConstraintList; |
| 427 | } |
| 428 | |
| 429 | @Override |
| 430 | public void setListOfMust(List<YangMust> mustConstraintList) { |
| 431 | this.mustConstraintList = mustConstraintList; |
| 432 | } |
| 433 | |
| 434 | @Override |
| 435 | public void addMust(YangMust must) { |
| 436 | if (getListOfMust() == null) { |
| 437 | setListOfMust(new LinkedList<>()); |
| 438 | } |
| 439 | getListOfMust().add(must); |
| 440 | } |
Vinod Kumar S | 19f39c7 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 441 | } |