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