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