blob: 686360eb0e8fda283ae58d56d5c1b20ae8611cab [file] [log] [blame]
Vinod Kumar S38046502016-03-23 15:30:27 +05301/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Vinod Kumar S38046502016-03-23 15:30:27 +05303 *
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.utils;
17
18import org.onosproject.yangutils.datamodel.YangAugment;
19import org.onosproject.yangutils.datamodel.YangCase;
20import org.onosproject.yangutils.datamodel.YangChoice;
21import org.onosproject.yangutils.datamodel.YangContainer;
22import org.onosproject.yangutils.datamodel.YangGrouping;
Vinod Kumar Sd4deb062016-04-15 18:08:57 +053023import org.onosproject.yangutils.datamodel.YangLeaf;
Vinod Kumar S38046502016-03-23 15:30:27 +053024import org.onosproject.yangutils.datamodel.YangList;
25import org.onosproject.yangutils.datamodel.YangModule;
26import org.onosproject.yangutils.datamodel.YangSubModule;
27import org.onosproject.yangutils.datamodel.YangTypeDef;
Gaurav Agrawal338735b2016-04-18 18:53:11 +053028import org.onosproject.yangutils.datamodel.YangUnion;
Vinod Kumar S38046502016-03-23 15:30:27 +053029import org.onosproject.yangutils.datamodel.YangUses;
Vidyashree Rama506cbe12016-03-28 11:59:27 +053030import org.onosproject.yangutils.datamodel.YangNotification;
Vidyashree Rama6a72b792016-03-29 12:00:42 +053031import org.onosproject.yangutils.datamodel.YangRpc;
32import org.onosproject.yangutils.datamodel.YangInput;
33import org.onosproject.yangutils.datamodel.YangOutput;
Vinod Kumar S38046502016-03-23 15:30:27 +053034import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaAugment;
35import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaCase;
36import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaChoice;
37import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaContainer;
Bharat saraswald72411a2016-04-19 01:00:16 +053038import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaEnumeration;
Vinod Kumar S38046502016-03-23 15:30:27 +053039import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaGrouping;
Vinod Kumar Sd4deb062016-04-15 18:08:57 +053040import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaLeaf;
Vinod Kumar S38046502016-03-23 15:30:27 +053041import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaList;
42import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule;
43import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaSubModule;
44import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaTypeDef;
Gaurav Agrawal338735b2016-04-18 18:53:11 +053045import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaUnion;
Vinod Kumar S38046502016-03-23 15:30:27 +053046import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaUses;
Vidyashree Rama506cbe12016-03-28 11:59:27 +053047import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaNotification;
Vidyashree Rama6a72b792016-03-29 12:00:42 +053048import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaRpc;
49import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaInput;
50import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaOutput;
Bharat saraswal6ef0b762016-04-05 12:45:45 +053051import org.onosproject.yangutils.translator.exception.TranslatorException;
Vinod Kumar S38046502016-03-23 15:30:27 +053052
53/**
Bharat saraswald9822e92016-04-05 15:13:44 +053054 *Represents factory to create data model objects based on the target file type.
Vinod Kumar S38046502016-03-23 15:30:27 +053055 */
56public final class YangDataModelFactory {
57
58 /**
Gaurav Agrawal338735b2016-04-18 18:53:11 +053059 * Creates a YANG data model factory object.
Vinod Kumar S38046502016-03-23 15:30:27 +053060 */
61 private YangDataModelFactory() {
62 }
63
64 /**
65 * Based on the target language generate the inherited data model node.
66 *
67 * @param targetLanguage target language in which YANG mapping needs to be
Vidyashree Rama506cbe12016-03-28 11:59:27 +053068 * generated
69 * @return the corresponding inherited node based on the target language
Vinod Kumar S38046502016-03-23 15:30:27 +053070 */
71 public static YangModule getYangModuleNode(GeneratedLanguage targetLanguage) {
72 switch (targetLanguage) {
73 case JAVA_GENERATION: {
74 return new YangJavaModule();
75 }
76 default: {
Bharat saraswal6ef0b762016-04-05 12:45:45 +053077 throw new TranslatorException("Only YANG to Java is supported.");
Vinod Kumar S38046502016-03-23 15:30:27 +053078 }
79 }
80 }
81
82 /**
Bharat saraswald9822e92016-04-05 15:13:44 +053083 * Returns based on the target language generate the inherited data model node.
Vinod Kumar S38046502016-03-23 15:30:27 +053084 *
85 * @param targetLanguage target language in which YANG mapping needs to be
Vidyashree Rama506cbe12016-03-28 11:59:27 +053086 * generated
87 * @return the corresponding inherited node based on the target language
Vinod Kumar S38046502016-03-23 15:30:27 +053088 */
89 public static YangAugment getYangAugmentNode(GeneratedLanguage targetLanguage) {
90 switch (targetLanguage) {
91 case JAVA_GENERATION: {
92 return new YangJavaAugment();
93 }
94 default: {
Bharat saraswal6ef0b762016-04-05 12:45:45 +053095 throw new TranslatorException("Only YANG to Java is supported.");
Vinod Kumar S38046502016-03-23 15:30:27 +053096 }
97 }
98 }
99
100 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530101 * Returns based on the target language generate the inherited data model node.
Vinod Kumar S38046502016-03-23 15:30:27 +0530102 *
103 * @param targetLanguage target language in which YANG mapping needs to be
Vidyashree Rama506cbe12016-03-28 11:59:27 +0530104 * generated
105 * @return the corresponding inherited node based on the target language
Vinod Kumar S38046502016-03-23 15:30:27 +0530106 */
107 public static YangCase getYangCaseNode(GeneratedLanguage targetLanguage) {
108 switch (targetLanguage) {
109 case JAVA_GENERATION: {
110 return new YangJavaCase();
111 }
112 default: {
Bharat saraswal6ef0b762016-04-05 12:45:45 +0530113 throw new TranslatorException("Only YANG to Java is supported.");
Vinod Kumar S38046502016-03-23 15:30:27 +0530114 }
115 }
116 }
117
118 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530119 * Returns based on the target language generate the inherited data model node.
Vinod Kumar S38046502016-03-23 15:30:27 +0530120 *
121 * @param targetLanguage target language in which YANG mapping needs to be
Vidyashree Rama506cbe12016-03-28 11:59:27 +0530122 * generated
123 * @return the corresponding inherited node based on the target language
Vinod Kumar S38046502016-03-23 15:30:27 +0530124 */
125 public static YangChoice getYangChoiceNode(GeneratedLanguage targetLanguage) {
126 switch (targetLanguage) {
127 case JAVA_GENERATION: {
128 return new YangJavaChoice();
129 }
130 default: {
Bharat saraswal6ef0b762016-04-05 12:45:45 +0530131 throw new TranslatorException("Only YANG to Java is supported.");
Vinod Kumar S38046502016-03-23 15:30:27 +0530132 }
133 }
134 }
135
136 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530137 * Returns based on the target language generate the inherited data model node.
Vinod Kumar S38046502016-03-23 15:30:27 +0530138 *
139 * @param targetLanguage target language in which YANG mapping needs to be
Vidyashree Rama506cbe12016-03-28 11:59:27 +0530140 * generated
141 * @return the corresponding inherited node based on the target language
Vinod Kumar S38046502016-03-23 15:30:27 +0530142 */
143 public static YangContainer getYangContainerNode(GeneratedLanguage targetLanguage) {
144 switch (targetLanguage) {
145 case JAVA_GENERATION: {
146 return new YangJavaContainer();
147 }
148 default: {
Bharat saraswal6ef0b762016-04-05 12:45:45 +0530149 throw new TranslatorException("Only YANG to Java is supported.");
Vinod Kumar S38046502016-03-23 15:30:27 +0530150 }
151 }
152 }
153
154 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530155 * Returns based on the target language generate the inherited data model node.
Vinod Kumar S38046502016-03-23 15:30:27 +0530156 *
157 * @param targetLanguage target language in which YANG mapping needs to be
Vidyashree Rama506cbe12016-03-28 11:59:27 +0530158 * generated
159 * @return the corresponding inherited node based on the target language
Vinod Kumar S38046502016-03-23 15:30:27 +0530160 */
161 public static YangGrouping getYangGroupingNode(GeneratedLanguage targetLanguage) {
162 switch (targetLanguage) {
163 case JAVA_GENERATION: {
164 return new YangJavaGrouping();
165 }
166 default: {
Bharat saraswal6ef0b762016-04-05 12:45:45 +0530167 throw new TranslatorException("Only YANG to Java is supported.");
Vinod Kumar S38046502016-03-23 15:30:27 +0530168 }
169 }
170 }
171
172 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530173 * Returns based on the target language generate the inherited data model node.
Vinod Kumar S38046502016-03-23 15:30:27 +0530174 *
175 * @param targetLanguage target language in which YANG mapping needs to be
Vidyashree Rama506cbe12016-03-28 11:59:27 +0530176 * generated
177 * @return the corresponding inherited node based on the target language
Vinod Kumar S38046502016-03-23 15:30:27 +0530178 */
179 public static YangList getYangListNode(GeneratedLanguage targetLanguage) {
180 switch (targetLanguage) {
181 case JAVA_GENERATION: {
182 return new YangJavaList();
183 }
184 default: {
Bharat saraswal6ef0b762016-04-05 12:45:45 +0530185 throw new TranslatorException("Only YANG to Java is supported.");
Vinod Kumar S38046502016-03-23 15:30:27 +0530186 }
187 }
188 }
189
190 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530191 * Returns based on the target language generate the inherited data model node.
Vinod Kumar S38046502016-03-23 15:30:27 +0530192 *
193 * @param targetLanguage target language in which YANG mapping needs to be
Vidyashree Rama506cbe12016-03-28 11:59:27 +0530194 * generated
195 * @return the corresponding inherited node based on the target language
Vinod Kumar S38046502016-03-23 15:30:27 +0530196 */
197 public static YangSubModule getYangSubModuleNode(GeneratedLanguage targetLanguage) {
198 switch (targetLanguage) {
199 case JAVA_GENERATION: {
200 return new YangJavaSubModule();
201 }
202 default: {
Bharat saraswal6ef0b762016-04-05 12:45:45 +0530203 throw new TranslatorException("Only YANG to Java is supported.");
Vinod Kumar S38046502016-03-23 15:30:27 +0530204 }
205 }
206 }
207
208 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530209 * Returns based on the target language generate the inherited data model node.
Vinod Kumar S38046502016-03-23 15:30:27 +0530210 *
211 * @param targetLanguage target language in which YANG mapping needs to be
Vidyashree Rama506cbe12016-03-28 11:59:27 +0530212 * generated
213 * @return the corresponding inherited node based on the target language
Vinod Kumar S38046502016-03-23 15:30:27 +0530214 */
215 public static YangTypeDef getYangTypeDefNode(GeneratedLanguage targetLanguage) {
216 switch (targetLanguage) {
217 case JAVA_GENERATION: {
218 return new YangJavaTypeDef();
219 }
220 default: {
Bharat saraswal6ef0b762016-04-05 12:45:45 +0530221 throw new TranslatorException("Only YANG to Java is supported.");
Vinod Kumar S38046502016-03-23 15:30:27 +0530222 }
223 }
224 }
225
226 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530227 * Returns based on the target language generate the inherited data model node.
Vinod Kumar S38046502016-03-23 15:30:27 +0530228 *
229 * @param targetLanguage target language in which YANG mapping needs to be
Gaurav Agrawal338735b2016-04-18 18:53:11 +0530230 * generated
231 * @return the corresponding inherited node based on the target language
232 */
233 public static YangUnion getYangUnionNode(GeneratedLanguage targetLanguage) {
234 switch (targetLanguage) {
235 case JAVA_GENERATION: {
236 return new YangJavaUnion();
237 }
238 default: {
239 throw new TranslatorException("Only YANG to Java is supported.");
240 }
241 }
242 }
243
244 /**
245 * Returns based on the target language generate the inherited data model node.
246 *
247 * @param targetLanguage target language in which YANG mapping needs to be
248 * generated
Vidyashree Rama506cbe12016-03-28 11:59:27 +0530249 * @return the corresponding inherited node based on the target language
Vinod Kumar S38046502016-03-23 15:30:27 +0530250 */
251 public static YangUses getYangUsesNode(GeneratedLanguage targetLanguage) {
252 switch (targetLanguage) {
253 case JAVA_GENERATION: {
254 return new YangJavaUses();
255 }
256 default: {
Bharat saraswal6ef0b762016-04-05 12:45:45 +0530257 throw new TranslatorException("Only YANG to Java is supported.");
Vinod Kumar S38046502016-03-23 15:30:27 +0530258 }
259 }
260 }
Vidyashree Rama506cbe12016-03-28 11:59:27 +0530261
262 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530263 * Returns based on the target language generate the inherited data model node.
Vidyashree Rama506cbe12016-03-28 11:59:27 +0530264 *
265 * @param targetLanguage target language in which YANG mapping needs to be
266 * generated
267 * @return the corresponding inherited node based on the target language
268 */
269 public static YangNotification getYangNotificationNode(GeneratedLanguage targetLanguage) {
270 switch (targetLanguage) {
271 case JAVA_GENERATION: {
272 return new YangJavaNotification();
273 }
274 default: {
Bharat saraswal6ef0b762016-04-05 12:45:45 +0530275 throw new TranslatorException("Only YANG to Java is supported.");
Vidyashree Rama506cbe12016-03-28 11:59:27 +0530276 }
277 }
278 }
Vidyashree Rama6a72b792016-03-29 12:00:42 +0530279
280 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530281 * Returns based on the target language generate the inherited data model node.
Vidyashree Rama6a72b792016-03-29 12:00:42 +0530282 *
283 * @param targetLanguage target language in which YANG mapping needs to be
284 * generated
285 * @return the corresponding inherited node based on the target language
286 */
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530287 public static YangLeaf getYangLeaf(GeneratedLanguage targetLanguage) {
288 switch (targetLanguage) {
289 case JAVA_GENERATION: {
290 return new YangJavaLeaf();
291 }
292 default: {
293 throw new RuntimeException("Only YANG to Java is supported.");
294 }
295 }
296 }
297 /**
298 * Returns based on the target language generate the inherited data model node.
299 *
300 * @param targetLanguage target language in which YANG mapping needs to be
301 * generated
302 * @return the corresponding inherited node based on the target language
303 */
Vidyashree Rama6a72b792016-03-29 12:00:42 +0530304 public static YangRpc getYangRpcNode(GeneratedLanguage targetLanguage) {
305 switch (targetLanguage) {
306 case JAVA_GENERATION: {
307 return new YangJavaRpc();
308 }
309 default: {
Bharat saraswal6ef0b762016-04-05 12:45:45 +0530310 throw new TranslatorException("Only YANG to Java is supported.");
Vidyashree Rama6a72b792016-03-29 12:00:42 +0530311 }
312 }
313 }
314
315 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530316 * Returns based on the target language generate the inherited data model node.
Vidyashree Rama6a72b792016-03-29 12:00:42 +0530317 *
318 * @param targetLanguage target language in which YANG mapping needs to be
319 * generated
320 * @return the corresponding inherited node based on the target language
321 */
322 public static YangInput getYangInputNode(GeneratedLanguage targetLanguage) {
323 switch (targetLanguage) {
324 case JAVA_GENERATION: {
325 return new YangJavaInput();
326 }
327 default: {
Bharat saraswal6ef0b762016-04-05 12:45:45 +0530328 throw new TranslatorException("Only YANG to Java is supported.");
Vidyashree Rama6a72b792016-03-29 12:00:42 +0530329 }
330 }
331 }
332
333 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530334 * Returns based on the target language generate the inherited data model node.
Vidyashree Rama6a72b792016-03-29 12:00:42 +0530335 *
336 * @param targetLanguage target language in which YANG mapping needs to be
337 * generated
338 * @return the corresponding inherited node based on the target language
339 */
340 public static YangOutput getYangOutputNode(GeneratedLanguage targetLanguage) {
341 switch (targetLanguage) {
342 case JAVA_GENERATION: {
343 return new YangJavaOutput();
344 }
345 default: {
Bharat saraswal6ef0b762016-04-05 12:45:45 +0530346 throw new TranslatorException("Only YANG to Java is supported.");
Vidyashree Rama6a72b792016-03-29 12:00:42 +0530347 }
348 }
349 }
Bharat saraswald72411a2016-04-19 01:00:16 +0530350
351 /**
352 * Returns based on the target language generate the inherited data model node.
353 *
354 * @param targetLanguage target language in which YANG mapping needs to be
355 * generated
356 * @return the corresponding inherited node based on the target language
357 */
358 public static YangJavaEnumeration getYangEnumerationNode(GeneratedLanguage targetLanguage) {
359 switch (targetLanguage) {
360 case JAVA_GENERATION: {
361 return new YangJavaEnumeration();
362 }
363 default: {
364 throw new TranslatorException("Only YANG to Java is supported.");
365 }
366 }
367 }
Vinod Kumar S38046502016-03-23 15:30:27 +0530368}