blob: 8dc0123f0d4eedaa376cfc832174a69632916f85 [file] [log] [blame]
Vinod Kumar S5a39e012016-02-16 01:37:16 +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 */
16package org.onosproject.yangutils.datamodel;
17
18import java.util.LinkedList;
19import java.util.List;
20
21import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
22import org.onosproject.yangutils.parser.Parsable;
23import org.onosproject.yangutils.parser.ParsableDataType;
Bharat saraswal5e3c45c2016-02-22 22:15:21 +053024import org.onosproject.yangutils.translator.CachedFileHandle;
Vinod Kumar S5a39e012016-02-16 01:37:16 +053025
26/*-
27 * Reference RFC 6020.
28 *
29 * The "grouping" statement is used to define a reusable block of nodes,
30 * which may be used locally in the module, in modules that include it,
31 * and by other modules that import from it. It takes one argument,
32 * which is an identifier, followed by a block of sub-statements that
33 * holds detailed grouping information.
34 *
35 * The "grouping" statement is not a data definition statement and, as
36 * such, does not define any nodes in the schema tree.
37 *
38 * A grouping is like a "structure" or a "record" in conventional
39 * programming languages.
40 * Once a grouping is defined, it can be referenced in a "uses"
41 * statement. A grouping MUST NOT reference itself,
42 * neither directly nor indirectly through a chain of other groupings.
43 *
44 * If the grouping is defined at the top level of a YANG module or
45 * submodule, the grouping's identifier MUST be unique within the
46 * module.
47 *
48 * A grouping is more than just a mechanism for textual substitution,
49 * but defines a collection of nodes. Identifiers appearing inside the
50 * grouping are resolved relative to the scope in which the grouping is
51 * defined, not where it is used. Prefix mappings, type names, grouping
52 * names, and extension usage are evaluated in the hierarchy where the
53 * "grouping" statement appears. For extensions, this means that
54 * extensions are applied to the grouping node, not the uses node.
55 *
56 * The grouping's sub-statements
57 *
58 * +--------------+---------+-------------+------------------+
59 * | substatement | section | cardinality |data model mapping|
60 * +--------------+---------+-------------+------------------+
61 * | anyxml | 7.10 | 0..n |-not supported |
62 * | choice | 7.9 | 0..n |-child nodes |
63 * | container | 7.5 | 0..n |-child nodes |
64 * | description | 7.19.3 | 0..1 |-string |
65 * | grouping | 7.11 | 0..n |-child nodes |
66 * | leaf | 7.6 | 0..n |-YangLeaf |
67 * | leaf-list | 7.7 | 0..n |-YangLeafList |
68 * | list | 7.8 | 0..n |-child nodes |
69 * | reference | 7.19.4 | 0..1 |-string |
70 * | status | 7.19.2 | 0..1 |-YangStatus |
71 * | typedef | 7.3 | 0..n |-child nodes |
72 * | uses | 7.12 | 0..n |-child nodes |
73 * +--------------+---------+-------------+------------------+
74 */
75
76/**
77 * Data model node to maintain information defined in YANG grouping.
78 */
Bharat saraswal97459962016-02-20 21:57:16 +053079public class YangGrouping extends YangNode implements YangLeavesHolder, YangCommonInfo, Parsable {
Vinod Kumar S5a39e012016-02-16 01:37:16 +053080
81 /**
82 * Name of the grouping.
83 */
84 private String name;
85
86 /**
87 * Description.
88 */
89 private String description;
90
91 /**
92 * List of leaves.
93 */
Bharat saraswal97459962016-02-20 21:57:16 +053094 private List<YangLeaf<?>> listOfLeaf;
Vinod Kumar S5a39e012016-02-16 01:37:16 +053095
96 /**
97 * List of leaf lists.
98 */
Bharat saraswal97459962016-02-20 21:57:16 +053099 private List<YangLeafList<?>> listOfLeafList;
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530100
101 /**
102 * Reference of the module.
103 */
104 private String reference;
105
106 /**
107 * Status of the node.
108 */
109 private YangStatusType status;
110
111 /**
112 * Creates the grouping node.
113 */
114 public YangGrouping() {
115 super(YangNodeType.GROUPING_NODE);
116 }
117
118 /* (non-Javadoc)
119 * @see org.onosproject.yangutils.datamodel.YangNode#getName()
120 */
121 @Override
122 public String getName() {
123 return name;
124 }
125
126 /* (non-Javadoc)
127 * @see org.onosproject.yangutils.datamodel.YangNode#setName(java.lang.String)
128 */
129 @Override
130 public void setName(String name) {
131 this.name = name;
132 }
133
134 /**
135 * Get the description.
136 *
137 * @return the description.
138 */
Bharat saraswal97459962016-02-20 21:57:16 +0530139 @Override
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530140 public String getDescription() {
141 return description;
142 }
143
144 /**
145 * Set the description.
146 *
147 * @param description set the description.
148 */
Bharat saraswal97459962016-02-20 21:57:16 +0530149 @Override
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530150 public void setDescription(String description) {
151 this.description = description;
152 }
153
154 /**
155 * Get the list of leaves.
156 *
157 * @return the list of leaves.
158 */
Bharat saraswal97459962016-02-20 21:57:16 +0530159 @Override
160 public List<YangLeaf<?>> getListOfLeaf() {
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530161 return listOfLeaf;
162 }
163
164 /**
165 * Set the list of leaves.
166 *
167 * @param leafsList the list of leaf to set.
168 */
Bharat saraswal97459962016-02-20 21:57:16 +0530169 private void setListOfLeaf(List<YangLeaf<?>> leafsList) {
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530170 listOfLeaf = leafsList;
171 }
172
173 /**
174 * Add a leaf.
175 *
176 * @param leaf the leaf to be added.
177 */
Bharat saraswal97459962016-02-20 21:57:16 +0530178 @Override
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530179 public void addLeaf(YangLeaf<?> leaf) {
180 if (getListOfLeaf() == null) {
Bharat saraswal97459962016-02-20 21:57:16 +0530181 setListOfLeaf(new LinkedList<YangLeaf<?>>());
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530182 }
183
184 getListOfLeaf().add(leaf);
185 }
186
187 /**
188 * Get the list of leaf-list.
189 *
190 * @return the list of leaf-list.
191 */
Bharat saraswal97459962016-02-20 21:57:16 +0530192 @Override
193 public List<YangLeafList<?>> getListOfLeafList() {
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530194 return listOfLeafList;
195 }
196
197 /**
198 * Set the list of leaf-list.
199 *
200 * @param listOfLeafList the list of leaf-list to set.
201 */
Bharat saraswal97459962016-02-20 21:57:16 +0530202 private void setListOfLeafList(List<YangLeafList<?>> listOfLeafList) {
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530203 this.listOfLeafList = listOfLeafList;
204 }
205
206 /**
207 * Add a leaf-list.
208 *
209 * @param leafList the leaf-list to be added.
210 */
Bharat saraswal97459962016-02-20 21:57:16 +0530211 @Override
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530212 public void addLeafList(YangLeafList<?> leafList) {
213 if (getListOfLeafList() == null) {
Bharat saraswal97459962016-02-20 21:57:16 +0530214 setListOfLeafList(new LinkedList<YangLeafList<?>>());
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530215 }
216
217 getListOfLeafList().add(leafList);
218 }
219
220 /**
221 * Get the textual reference.
222 *
223 * @return the reference.
224 */
Bharat saraswal97459962016-02-20 21:57:16 +0530225 @Override
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530226 public String getReference() {
227 return reference;
228 }
229
230 /**
231 * Set the textual reference.
232 *
233 * @param reference the reference to set.
234 */
Bharat saraswal97459962016-02-20 21:57:16 +0530235 @Override
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530236 public void setReference(String reference) {
237 this.reference = reference;
238 }
239
240 /**
241 * Get the status.
242 *
243 * @return the status.
244 */
Bharat saraswal97459962016-02-20 21:57:16 +0530245 @Override
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530246 public YangStatusType getStatus() {
247 return status;
248 }
249
250 /**
251 * Set the status.
252 *
253 * @param status the status to set.
254 */
Bharat saraswal97459962016-02-20 21:57:16 +0530255 @Override
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530256 public void setStatus(YangStatusType status) {
257 this.status = status;
258 }
259
260 /**
261 * Returns the type of the data.
262 *
263 * @return returns GROUPING_DATA.
264 */
Bharat saraswal97459962016-02-20 21:57:16 +0530265 @Override
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530266 public ParsableDataType getParsableDataType() {
267 return ParsableDataType.GROUPING_DATA;
268 }
269
270 /**
271 * Validate the data on entering the corresponding parse tree node.
272 *
273 * @throws DataModelException a violation of data model rules.
274 */
Bharat saraswal97459962016-02-20 21:57:16 +0530275 @Override
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530276 public void validateDataOnEntry() throws DataModelException {
277 // TODO auto-generated method stub, to be implemented by parser
278 }
279
280 /**
281 * Validate the data on exiting the corresponding parse tree node.
282 *
283 * @throws DataModelException a violation of data model rules.
284 */
Bharat saraswal97459962016-02-20 21:57:16 +0530285 @Override
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530286 public void validateDataOnExit() throws DataModelException {
287 // TODO auto-generated method stub, to be implemented by parser
288 }
289
290 /* (non-Javadoc)
291 * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry()
292 */
Bharat saraswal97459962016-02-20 21:57:16 +0530293 @Override
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530294 public void generateJavaCodeEntry() {
295 // TODO Auto-generated method stub
296
297 }
298
299 /* (non-Javadoc)
300 * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit()
301 */
Bharat saraswal97459962016-02-20 21:57:16 +0530302 @Override
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530303 public void generateJavaCodeExit() {
304 // TODO Auto-generated method stub
305
306 }
307
308 /* (non-Javadoc)
309 * @see org.onosproject.yangutils.datamodel.YangNode#getPackage()
310 */
311 @Override
312 public String getPackage() {
313 // TODO Auto-generated method stub
314 return null;
315 }
316
317 /* (non-Javadoc)
318 * @see org.onosproject.yangutils.datamodel.YangNode#setPackage(java.lang.String)
319 */
320 @Override
321 public void setPackage(String pkg) {
322 // TODO Auto-generated method stub
323
324 }
Bharat saraswal5e3c45c2016-02-22 22:15:21 +0530325
326 @Override
327 public CachedFileHandle getFileHandle() {
328 // TODO Auto-generated method stub
329 return null;
330 }
331
332 @Override
333 public void setFileHandle(CachedFileHandle fileHandle) {
334 // TODO Auto-generated method stub
335
336 }
Vinod Kumar S5a39e012016-02-16 01:37:16 +0530337}