blob: d005458edec3ca132e658182c632540df1bff084 [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.
54 *
55 * @param <T> YANG data type
56 */
57public class YangLeafList<T> implements YangCommonInfo, Parsable {
58
59 /**
60 * Name of leaf-list.
61 */
62 private String name;
63
64 /**
65 * If the leaf-list is a config parameter.
66 */
67 private boolean isConfig;
68
69 /**
70 * Description of leaf-list.
71 */
72 private String description;
73
74 /**
75 * Reference:RFC 6020.
76 * The "max-elements" statement, which is optional, takes as an argument a
77 * positive integer or the string "unbounded", which puts a constraint on
78 * valid list entries. A valid leaf-list or list always has at most
79 * max-elements entries.
80 *
81 * If no "max-elements" statement is present, it defaults to "unbounded".
82 */
83 private int maxElelements;
84
85 /**
86 * Reference:RFC 6020.
87 * 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 */
102 private int minElements;
103
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 */
112 private YangStatusType status;
113
114 /**
115 * Textual units.
116 */
117 private String units;
118
119 /**
120 * Data type of leaf-list.
121 */
122 private YangType<T> dataType;
123
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) {
145 this.name = leafListName;
146 }
147
148 /**
149 * Get the config flag.
150 *
151 * @return the config flag.
152 */
153 public boolean isConfig() {
154 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 */
171 public String getDescription() {
172 return description;
173 }
174
175 /**
176 * Set the description.
177 *
178 * @param description set the description.
179 */
180 public void setDescription(String description) {
181 this.description = description;
182 }
183
184 /**
185 * Get the max elements no.
186 *
187 * @return the max elements no.
188 */
189 public int getMaxElelements() {
190 return maxElelements;
191 }
192
193 /**
194 * Set the max elements no.
195 *
196 * @param maxElelements max elements no.
197 */
198 public void setMaxElelements(int maxElelements) {
199 this.maxElelements = maxElelements;
200 }
201
202 /**
203 * Get the min elements no.
204 *
205 * @return the min elements no.
206 */
207 public int getMinElements() {
208 return minElements;
209 }
210
211 /**
212 * Set the min elements no.
213 *
214 * @param minElements the min elements no.
215 */
216 public void setMinElements(int minElements) {
217 this.minElements = minElements;
218 }
219
220 /**
221 * Get the textual reference.
222 *
223 * @return the reference.
224 */
225 public String getReference() {
226 return reference;
227 }
228
229 /**
230 * Set the textual reference.
231 *
232 * @param reference the reference to set.
233 */
234 public void setReference(String reference) {
235 this.reference = reference;
236 }
237
238 /**
239 * Get the status.
240 *
241 * @return the status.
242 */
243 public YangStatusType getStatus() {
244 return status;
245 }
246
247 /**
248 * Set the status.
249 *
250 * @param status the status to set.
251 */
252 public void setStatus(YangStatusType status) {
253 this.status = status;
254 }
255
256 /**
257 * Get the units.
258 *
259 * @return the units.
260 */
261 public String getUnits() {
262 return units;
263 }
264
265 /**
266 * Set the units.
267 *
268 * @param units the units to set.
269 */
270 public void setUnits(String units) {
271 this.units = units;
272 }
273
274 /**
275 * Get the data type.
276 *
277 * @return the data type.
278 */
279 public YangType<T> getDataType() {
280 return dataType;
281 }
282
283 /**
284 * Set the data type.
285 *
286 * @param dataType the data type to set.
287 */
288 public void setDataType(YangType<T> dataType) {
289 this.dataType = dataType;
290 }
291
292 /**
293 * Returns the type of the parsed data.
294 *
295 * @return returns LEAF_LIST_DATA.
296 */
297 public ParsableDataType getParsableDataType() {
298 return ParsableDataType.LEAF_LIST_DATA;
299 }
300
301 /**
302 * Validate the data on entering the corresponding parse tree node.
303 *
304 * @throws DataModelException a violation of data model rules.
305 */
306 public void validateDataOnEntry() throws DataModelException {
307 // TODO auto-generated method stub, to be implemented by parser
308
309 }
310
311 /**
312 * Validate the data on exiting the corresponding parse tree node.
313 *
314 * @throws DataModelException a violation of data model rules.
315 */
316 public void validateDataOnExit() throws DataModelException {
317 // TODO auto-generated method stub, to be implemented by parser
318
319 }
320}