blob: 6ce34309563e0dff87b741ad1b5e8dc410f9c2a1 [file] [log] [blame]
Vinod Kumar S19f39c72016-02-09 20:12:31 +05301/*
2 * Copyright 2016 Open Networking Laboratory
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
17package org.onosproject.yangutils.datamodel;
18
19import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
20import org.onosproject.yangutils.parser.Parsable;
21import org.onosproject.yangutils.parser.ParsableDataType;
22
23/*
24 * Reference:RFC 6020.
25 * Where the "leaf" statement is used to define a simple scalar variable
26 * of a particular type, the "leaf-list" statement is used to define an
27 * array of a particular type. The "leaf-list" statement takes one
28 * argument, which is an identifier, followed by a block of
29 * sub-statements that holds detailed leaf-list information.
30 *
31 * The values in a leaf-list MUST be unique.
32 *
33 * The leaf-list's sub-statements
34 *
35 * +--------------+---------+-------------+------------------+
36 * | substatement | section | cardinality |data model mapping|
37 * +--------------+---------+-------------+------------------+
38 * | config | 7.19.1 | 0..1 | -boolean |
39 * | description | 7.19.3 | 0..1 | -string |
40 * | if-feature | 7.18.2 | 0..n | -TODO |
41 * | max-elements | 7.7.4 | 0..1 | -int |
42 * | min-elements | 7.7.3 | 0..1 | -int |
43 * | must | 7.5.3 | 0..n | -TODO |
44 * | ordered-by | 7.7.5 | 0..1 | -TODO |
45 * | reference | 7.19.4 | 0..1 | -string |
46 * | status | 7.19.2 | 0..1 | -YangStatus |
47 * | type | 7.4 | 1 | -YangType |
48 * | units | 7.3.3 | 0..1 | -string |
49 * | when | 7.19.5 | 0..1 | -TODO |
50 * +--------------+---------+-------------+------------------+
51 */
52/**
53 * Leaf-list data represented in YANG.
Vinod Kumar S19f39c72016-02-09 20:12:31 +053054 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +053055public class YangLeafList implements YangCommonInfo, Parsable {
Vinod Kumar S19f39c72016-02-09 20:12:31 +053056
57 /**
58 * Name of leaf-list.
59 */
60 private String name;
61
62 /**
63 * If the leaf-list is a config parameter.
64 */
Vidyashree Ramaf4c617c2016-02-24 12:28:22 +053065 private Boolean isConfig;
Vinod Kumar S19f39c72016-02-09 20:12:31 +053066
67 /**
68 * Description of leaf-list.
69 */
70 private String description;
71
72 /**
73 * Reference:RFC 6020.
Vinod Kumar S0c330cd2016-02-23 22:36:57 +053074 *
Vinod Kumar S19f39c72016-02-09 20:12:31 +053075 * The "max-elements" statement, which is optional, takes as an argument a
76 * positive integer or the string "unbounded", which puts a constraint on
77 * valid list entries. A valid leaf-list or list always has at most
78 * max-elements entries.
79 *
80 * If no "max-elements" statement is present, it defaults to "unbounded".
81 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +053082 private int maxElelements = Integer.MAX_VALUE;
Vinod Kumar S19f39c72016-02-09 20:12:31 +053083
84 /**
85 * Reference:RFC 6020.
Vinod Kumar S0c330cd2016-02-23 22:36:57 +053086 *
Vinod Kumar S19f39c72016-02-09 20:12:31 +053087 * The "min-elements" statement, which is optional, takes as an argument a
88 * non-negative integer that puts a constraint on valid list entries. A
89 * valid leaf-list or list MUST have at least min-elements entries.
90 *
91 * If no "min-elements" statement is present, it defaults to zero.
92 *
93 * The behavior of the constraint depends on the type of the leaf-list's or
94 * list's closest ancestor node in the schema tree that is not a non-
95 * presence container:
96 *
97 * o If this ancestor is a case node, the constraint is enforced if any
98 * other node from the case exists.
99 *
100 * o Otherwise, it is enforced if the ancestor node exists.
101 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530102 private int minElements = 0;
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530103
104 /**
105 * The textual reference to this leaf-list.
106 */
107 private String reference;
108
109 /**
110 * Status of the leaf-list in the YANG definition.
111 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530112 private YangStatusType status = YangStatusType.CURRENT;
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530113
114 /**
115 * Textual units.
116 */
117 private String units;
118
119 /**
120 * Data type of leaf-list.
121 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530122 private YangType<?> dataType;
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530123
124 /**
125 * Default Constructor to create a YANG leaf-list.
126 */
127 public YangLeafList() {
128 }
129
130 /**
131 * Get the leaf-list name.
132 *
133 * @return the leaf-list name.
134 */
135 public String getLeafName() {
136 return name;
137 }
138
139 /**
140 * Set the leaf-list name.
141 *
142 * @param leafListName the leaf-list name to set.
143 */
144 public void setLeafName(String leafListName) {
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530145 name = leafListName;
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530146 }
147
148 /**
149 * Get the config flag.
150 *
151 * @return the config flag.
152 */
Vidyashree Ramaf4c617c2016-02-24 12:28:22 +0530153 public Boolean isConfig() {
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530154 return isConfig;
155 }
156
157 /**
158 * Set the config flag.
159 *
160 * @param isCfg the config flag.
161 */
162 public void setConfig(boolean isCfg) {
163 isConfig = isCfg;
164 }
165
166 /**
167 * Get the description.
168 *
169 * @return the description.
170 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530171 @Override
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530172 public String getDescription() {
173 return description;
174 }
175
176 /**
177 * Set the description.
178 *
179 * @param description set the description.
180 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530181 @Override
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530182 public void setDescription(String description) {
183 this.description = description;
184 }
185
186 /**
187 * Get the max elements no.
188 *
189 * @return the max elements no.
190 */
191 public int getMaxElelements() {
192 return maxElelements;
193 }
194
195 /**
196 * Set the max elements no.
197 *
198 * @param maxElelements max elements no.
199 */
200 public void setMaxElelements(int maxElelements) {
201 this.maxElelements = maxElelements;
202 }
203
204 /**
205 * Get the min elements no.
206 *
207 * @return the min elements no.
208 */
209 public int getMinElements() {
210 return minElements;
211 }
212
213 /**
214 * Set the min elements no.
215 *
216 * @param minElements the min elements no.
217 */
218 public void setMinElements(int minElements) {
219 this.minElements = minElements;
220 }
221
222 /**
223 * Get the textual reference.
224 *
225 * @return the reference.
226 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530227 @Override
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530228 public String getReference() {
229 return reference;
230 }
231
232 /**
233 * Set the textual reference.
234 *
235 * @param reference the reference to set.
236 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530237 @Override
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530238 public void setReference(String reference) {
239 this.reference = reference;
240 }
241
242 /**
243 * Get the status.
244 *
245 * @return the status.
246 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530247 @Override
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530248 public YangStatusType getStatus() {
249 return status;
250 }
251
252 /**
253 * Set the status.
254 *
255 * @param status the status to set.
256 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530257 @Override
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530258 public void setStatus(YangStatusType status) {
259 this.status = status;
260 }
261
262 /**
263 * Get the units.
264 *
265 * @return the units.
266 */
267 public String getUnits() {
268 return units;
269 }
270
271 /**
272 * Set the units.
273 *
274 * @param units the units to set.
275 */
276 public void setUnits(String units) {
277 this.units = units;
278 }
279
280 /**
281 * Get the data type.
282 *
283 * @return the data type.
284 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530285 public YangType<?> getDataType() {
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530286 return dataType;
287 }
288
289 /**
290 * Set the data type.
291 *
292 * @param dataType the data type to set.
293 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530294 public void setDataType(YangType<?> dataType) {
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530295 this.dataType = dataType;
296 }
297
298 /**
299 * Returns the type of the parsed data.
300 *
301 * @return returns LEAF_LIST_DATA.
302 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530303 @Override
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530304 public ParsableDataType getParsableDataType() {
305 return ParsableDataType.LEAF_LIST_DATA;
306 }
307
308 /**
309 * Validate the data on entering the corresponding parse tree node.
310 *
311 * @throws DataModelException a violation of data model rules.
312 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530313 @Override
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530314 public void validateDataOnEntry() throws DataModelException {
315 // TODO auto-generated method stub, to be implemented by parser
316
317 }
318
319 /**
320 * Validate the data on exiting the corresponding parse tree node.
321 *
322 * @throws DataModelException a violation of data model rules.
323 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530324 @Override
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530325 public void validateDataOnExit() throws DataModelException {
326 // TODO auto-generated method stub, to be implemented by parser
327
328 }
329}