blob: bcfa70c36b46a868e79cdf721ea8df13db229205 [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;
Bharat saraswal594bc6d2016-02-22 22:15:21 +053024import org.onosproject.yangutils.translator.CachedFileHandle;
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053025
26/*-
27 * Reference RFC 6020.
28 *
29 * The "case" statement is used to define branches of the choice. It takes as an
30 * argument an identifier, followed by a block of sub-statements that holds
31 * detailed case information.
32 *
33 * The identifier is used to identify the case node in the schema tree. A case
34 * node does not exist in the data tree.
35 *
36 * Within a "case" statement, the "anyxml", "choice", "container", "leaf",
37 * "list", "leaf-list", and "uses" statements can be used to define child nodes
38 * to the case node. The identifiers of all these child nodes MUST be unique
39 * within all cases in a choice. For example, the following is illegal:
40 *
41 * choice interface-type { // This example is illegal YANG
42 * case a {
43 * leaf ethernet { ... }
44 * }
45 * case b {
46 * container ethernet { ...}
47 * }
48 * }
49 *
50 * As a shorthand, the "case" statement can be omitted if the branch
51 * contains a single "anyxml", "container", "leaf", "list", or
52 * "leaf-list" statement. In this case, the identifier of the case node
53 * is the same as the identifier in the branch statement. The following
54 * example:
55 *
56 * choice interface-type {
57 * container ethernet { ... }
58 * }
59 *
60 * is equivalent to:
61 *
62 * choice interface-type {
63 * case ethernet {
64 * container ethernet { ... }
65 * }
66 * }
67 *
68 * The case identifier MUST be unique within a choice.
69 *
70 * The case's sub-statements
71 *
72 * +--------------+---------+-------------+------------------+
73 * | substatement | section | cardinality |data model mapping|
74 * +--------------+---------+-------------+------------------+
75 * | anyxml | 7.10 | 0..n |-not supported |
76 * | choice | 7.9 | 0..n |-child nodes |
77 * | container | 7.5 | 0..n |-child nodes |
78 * | description | 7.19.3 | 0..1 |-string |
79 * | if-feature | 7.18.2 | 0..n |-TODO |
80 * | leaf | 7.6 | 0..n |-YangLeaf |
81 * | leaf-list | 7.7 | 0..n |-YangLeafList |
82 * | list | 7.8 | 0..n |-child nodes |
83 * | reference | 7.19.4 | 0..1 |-string |
84 * | status | 7.19.2 | 0..1 |-YangStatus |
85 * | uses | 7.12 | 0..n |-child node |
86 * | when | 7.19.5 | 0..1 |-TODO |
87 * +--------------+---------+-------------+------------------+
88 */
89/**
90 * Data model node to maintain information defined in YANG case.
91 */
Bharat saraswal870c56f2016-02-20 21:57:16 +053092public class YangCase extends YangNode implements YangLeavesHolder, YangCommonInfo, Parsable {
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053093
94 /**
95 * Case name.
96 */
97 private String name;
98
99 // TODO: default field identification for the case
100
101 /**
102 * Description of container.
103 */
104 private String description;
105
106 /**
107 * List of leaves.
108 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530109 private List<YangLeaf<?>> listOfLeaf;
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530110
111 /**
112 * List of leaf lists.
113 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530114 private List<YangLeafList<?>> listOfLeafList;
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530115
116 /**
117 * Reference of the module.
118 */
119 private String reference;
120
121 /**
122 * Status of the node.
123 */
124 private YangStatusType status;
125
126 /**
127 * Create a choice node.
128 */
129 public YangCase() {
130 super(YangNodeType.CASE_NODE);
131 }
132
133 /* (non-Javadoc)
134 * @see org.onosproject.yangutils.datamodel.YangNode#getName()
135 */
136 @Override
137 public String getName() {
138 return name;
139 }
140
141 /* (non-Javadoc)
142 * @see org.onosproject.yangutils.datamodel.YangNode#setName(java.lang.String)
143 */
144 @Override
145 public void setName(String name) {
146 this.name = name;
147 }
148
149 /**
150 * Get the description.
151 *
152 * @return the description.
153 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530154 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530155 public String getDescription() {
156 return description;
157 }
158
159 /**
160 * Set the description.
161 *
162 * @param description set the description.
163 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530164 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530165 public void setDescription(String description) {
166 this.description = description;
167 }
168
169 /**
170 * Get the list of leaves.
171 *
172 * @return the list of leaves.
173 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530174 @Override
175 public List<YangLeaf<?>> getListOfLeaf() {
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530176 return listOfLeaf;
177 }
178
179 /**
180 * Set the list of leaves.
181 *
182 * @param leafsList the list of leaf to set.
183 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530184 private void setListOfLeaf(List<YangLeaf<?>> leafsList) {
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530185 listOfLeaf = leafsList;
186 }
187
188 /**
189 * Add a leaf.
190 *
191 * @param leaf the leaf to be added.
192 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530193 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530194 public void addLeaf(YangLeaf<?> leaf) {
195 if (getListOfLeaf() == null) {
Bharat saraswal870c56f2016-02-20 21:57:16 +0530196 setListOfLeaf(new LinkedList<YangLeaf<?>>());
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530197 }
198
199 getListOfLeaf().add(leaf);
200 }
201
202 /**
203 * Get the list of leaf-list.
204 *
205 * @return the list of leaf-list.
206 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530207 @Override
208 public List<YangLeafList<?>> getListOfLeafList() {
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530209 return listOfLeafList;
210 }
211
212 /**
213 * Set the list of leaf-list.
214 *
215 * @param listOfLeafList the list of leaf-list to set.
216 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530217 private void setListOfLeafList(List<YangLeafList<?>> listOfLeafList) {
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530218 this.listOfLeafList = listOfLeafList;
219 }
220
221 /**
222 * Add a leaf-list.
223 *
224 * @param leafList the leaf-list to be added.
225 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530226 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530227 public void addLeafList(YangLeafList<?> leafList) {
228 if (getListOfLeafList() == null) {
Bharat saraswal870c56f2016-02-20 21:57:16 +0530229 setListOfLeafList(new LinkedList<YangLeafList<?>>());
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530230 }
231
232 getListOfLeafList().add(leafList);
233 }
234
235 /**
236 * Get the textual reference.
237 *
238 * @return the reference.
239 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530240 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530241 public String getReference() {
242 return reference;
243 }
244
245 /**
246 * Set the textual reference.
247 *
248 * @param reference the reference to set.
249 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530250 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530251 public void setReference(String reference) {
252 this.reference = reference;
253 }
254
255 /**
256 * Get the status.
257 *
258 * @return the status.
259 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530260 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530261 public YangStatusType getStatus() {
262 return status;
263 }
264
265 /**
266 * Set the status.
267 *
268 * @param status the status to set.
269 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530270 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530271 public void setStatus(YangStatusType status) {
272 this.status = status;
273 }
274
275 /**
276 * Returns the type of the data.
277 *
278 * @return returns CASE_DATA
279 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530280 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530281 public ParsableDataType getParsableDataType() {
282 return ParsableDataType.CASE_DATA;
283 }
284
285 /**
286 * Validate the data on entering the corresponding parse tree node.
287 *
288 * @throws DataModelException a violation of data model rules.
289 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530290 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530291 public void validateDataOnEntry() throws DataModelException {
292 // TODO auto-generated method stub, to be implemented by parser
293 }
294
295 /**
296 * Validate the data on exiting the corresponding parse tree node.
297 *
298 * @throws DataModelException a violation of data model rules.
299 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530300 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530301 public void validateDataOnExit() throws DataModelException {
302 // TODO auto-generated method stub, to be implemented by parser
303 }
304
305 /* (non-Javadoc)
306 * @see org.onosproject.yangutils.datamodel.YangNode#getPackage()
307 */
308 @Override
309 public String getPackage() {
310 // TODO Auto-generated method stub
311 return null;
312 }
313
314 /* (non-Javadoc)
315 * @see org.onosproject.yangutils.datamodel.YangNode#setPackage(java.lang.String)
316 */
317 @Override
318 public void setPackage(String pkg) {
319 // TODO Auto-generated method stub
320
321 }
322
323 /* (non-Javadoc)
324 * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry()
325 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530326 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530327 public void generateJavaCodeEntry() {
328 // TODO Auto-generated method stub
329
330 }
331
332 /* (non-Javadoc)
333 * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit()
334 */
Bharat saraswal870c56f2016-02-20 21:57:16 +0530335 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530336 public void generateJavaCodeExit() {
337 // TODO Auto-generated method stub
338
339 }
Bharat saraswal594bc6d2016-02-22 22:15:21 +0530340
341 @Override
342 public CachedFileHandle getFileHandle() {
343 // TODO Auto-generated method stub
344 return null;
345 }
346
347 @Override
348 public void setFileHandle(CachedFileHandle fileHandle) {
349 // TODO Auto-generated method stub
350
351 }
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530352}