blob: 6edd6a6dd658d532f19ecdc018ff97ffc5650065 [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;
23import org.onosproject.yangutils.datamodel.YangList;
24import org.onosproject.yangutils.datamodel.YangModule;
25import org.onosproject.yangutils.datamodel.YangSubModule;
26import org.onosproject.yangutils.datamodel.YangTypeDef;
27import org.onosproject.yangutils.datamodel.YangUses;
Vidyashree Rama506cbe12016-03-28 11:59:27 +053028import org.onosproject.yangutils.datamodel.YangNotification;
Vidyashree Rama6a72b792016-03-29 12:00:42 +053029import org.onosproject.yangutils.datamodel.YangRpc;
30import org.onosproject.yangutils.datamodel.YangInput;
31import org.onosproject.yangutils.datamodel.YangOutput;
Vinod Kumar S38046502016-03-23 15:30:27 +053032import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaAugment;
33import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaCase;
34import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaChoice;
35import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaContainer;
36import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaGrouping;
37import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaList;
38import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule;
39import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaSubModule;
40import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaTypeDef;
41import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaUses;
Vidyashree Rama506cbe12016-03-28 11:59:27 +053042import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaNotification;
Vidyashree Rama6a72b792016-03-29 12:00:42 +053043import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaRpc;
44import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaInput;
45import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaOutput;
Bharat saraswal6ef0b762016-04-05 12:45:45 +053046import org.onosproject.yangutils.translator.exception.TranslatorException;
Vinod Kumar S38046502016-03-23 15:30:27 +053047
48/**
Bharat saraswald9822e92016-04-05 15:13:44 +053049 *Represents factory to create data model objects based on the target file type.
Vinod Kumar S38046502016-03-23 15:30:27 +053050 */
51public final class YangDataModelFactory {
52
53 /**
Bharat saraswald9822e92016-04-05 15:13:44 +053054 * Creates a YANG data model factory object.
Vinod Kumar S38046502016-03-23 15:30:27 +053055 */
56 private YangDataModelFactory() {
57 }
58
59 /**
60 * Based on the target language generate the inherited data model node.
61 *
62 * @param targetLanguage target language in which YANG mapping needs to be
Vidyashree Rama506cbe12016-03-28 11:59:27 +053063 * generated
64 * @return the corresponding inherited node based on the target language
Vinod Kumar S38046502016-03-23 15:30:27 +053065 */
66 public static YangModule getYangModuleNode(GeneratedLanguage targetLanguage) {
67 switch (targetLanguage) {
68 case JAVA_GENERATION: {
69 return new YangJavaModule();
70 }
71 default: {
Bharat saraswal6ef0b762016-04-05 12:45:45 +053072 throw new TranslatorException("Only YANG to Java is supported.");
Vinod Kumar S38046502016-03-23 15:30:27 +053073 }
74 }
75 }
76
77 /**
Bharat saraswald9822e92016-04-05 15:13:44 +053078 * Returns based on the target language generate the inherited data model node.
Vinod Kumar S38046502016-03-23 15:30:27 +053079 *
80 * @param targetLanguage target language in which YANG mapping needs to be
Vidyashree Rama506cbe12016-03-28 11:59:27 +053081 * generated
82 * @return the corresponding inherited node based on the target language
Vinod Kumar S38046502016-03-23 15:30:27 +053083 */
84 public static YangAugment getYangAugmentNode(GeneratedLanguage targetLanguage) {
85 switch (targetLanguage) {
86 case JAVA_GENERATION: {
87 return new YangJavaAugment();
88 }
89 default: {
Bharat saraswal6ef0b762016-04-05 12:45:45 +053090 throw new TranslatorException("Only YANG to Java is supported.");
Vinod Kumar S38046502016-03-23 15:30:27 +053091 }
92 }
93 }
94
95 /**
Bharat saraswald9822e92016-04-05 15:13:44 +053096 * Returns based on the target language generate the inherited data model node.
Vinod Kumar S38046502016-03-23 15:30:27 +053097 *
98 * @param targetLanguage target language in which YANG mapping needs to be
Vidyashree Rama506cbe12016-03-28 11:59:27 +053099 * generated
100 * @return the corresponding inherited node based on the target language
Vinod Kumar S38046502016-03-23 15:30:27 +0530101 */
102 public static YangCase getYangCaseNode(GeneratedLanguage targetLanguage) {
103 switch (targetLanguage) {
104 case JAVA_GENERATION: {
105 return new YangJavaCase();
106 }
107 default: {
Bharat saraswal6ef0b762016-04-05 12:45:45 +0530108 throw new TranslatorException("Only YANG to Java is supported.");
Vinod Kumar S38046502016-03-23 15:30:27 +0530109 }
110 }
111 }
112
113 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530114 * Returns based on the target language generate the inherited data model node.
Vinod Kumar S38046502016-03-23 15:30:27 +0530115 *
116 * @param targetLanguage target language in which YANG mapping needs to be
Vidyashree Rama506cbe12016-03-28 11:59:27 +0530117 * generated
118 * @return the corresponding inherited node based on the target language
Vinod Kumar S38046502016-03-23 15:30:27 +0530119 */
120 public static YangChoice getYangChoiceNode(GeneratedLanguage targetLanguage) {
121 switch (targetLanguage) {
122 case JAVA_GENERATION: {
123 return new YangJavaChoice();
124 }
125 default: {
Bharat saraswal6ef0b762016-04-05 12:45:45 +0530126 throw new TranslatorException("Only YANG to Java is supported.");
Vinod Kumar S38046502016-03-23 15:30:27 +0530127 }
128 }
129 }
130
131 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530132 * Returns based on the target language generate the inherited data model node.
Vinod Kumar S38046502016-03-23 15:30:27 +0530133 *
134 * @param targetLanguage target language in which YANG mapping needs to be
Vidyashree Rama506cbe12016-03-28 11:59:27 +0530135 * generated
136 * @return the corresponding inherited node based on the target language
Vinod Kumar S38046502016-03-23 15:30:27 +0530137 */
138 public static YangContainer getYangContainerNode(GeneratedLanguage targetLanguage) {
139 switch (targetLanguage) {
140 case JAVA_GENERATION: {
141 return new YangJavaContainer();
142 }
143 default: {
Bharat saraswal6ef0b762016-04-05 12:45:45 +0530144 throw new TranslatorException("Only YANG to Java is supported.");
Vinod Kumar S38046502016-03-23 15:30:27 +0530145 }
146 }
147 }
148
149 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530150 * Returns based on the target language generate the inherited data model node.
Vinod Kumar S38046502016-03-23 15:30:27 +0530151 *
152 * @param targetLanguage target language in which YANG mapping needs to be
Vidyashree Rama506cbe12016-03-28 11:59:27 +0530153 * generated
154 * @return the corresponding inherited node based on the target language
Vinod Kumar S38046502016-03-23 15:30:27 +0530155 */
156 public static YangGrouping getYangGroupingNode(GeneratedLanguage targetLanguage) {
157 switch (targetLanguage) {
158 case JAVA_GENERATION: {
159 return new YangJavaGrouping();
160 }
161 default: {
Bharat saraswal6ef0b762016-04-05 12:45:45 +0530162 throw new TranslatorException("Only YANG to Java is supported.");
Vinod Kumar S38046502016-03-23 15:30:27 +0530163 }
164 }
165 }
166
167 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530168 * Returns based on the target language generate the inherited data model node.
Vinod Kumar S38046502016-03-23 15:30:27 +0530169 *
170 * @param targetLanguage target language in which YANG mapping needs to be
Vidyashree Rama506cbe12016-03-28 11:59:27 +0530171 * generated
172 * @return the corresponding inherited node based on the target language
Vinod Kumar S38046502016-03-23 15:30:27 +0530173 */
174 public static YangList getYangListNode(GeneratedLanguage targetLanguage) {
175 switch (targetLanguage) {
176 case JAVA_GENERATION: {
177 return new YangJavaList();
178 }
179 default: {
Bharat saraswal6ef0b762016-04-05 12:45:45 +0530180 throw new TranslatorException("Only YANG to Java is supported.");
Vinod Kumar S38046502016-03-23 15:30:27 +0530181 }
182 }
183 }
184
185 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530186 * Returns based on the target language generate the inherited data model node.
Vinod Kumar S38046502016-03-23 15:30:27 +0530187 *
188 * @param targetLanguage target language in which YANG mapping needs to be
Vidyashree Rama506cbe12016-03-28 11:59:27 +0530189 * generated
190 * @return the corresponding inherited node based on the target language
Vinod Kumar S38046502016-03-23 15:30:27 +0530191 */
192 public static YangSubModule getYangSubModuleNode(GeneratedLanguage targetLanguage) {
193 switch (targetLanguage) {
194 case JAVA_GENERATION: {
195 return new YangJavaSubModule();
196 }
197 default: {
Bharat saraswal6ef0b762016-04-05 12:45:45 +0530198 throw new TranslatorException("Only YANG to Java is supported.");
Vinod Kumar S38046502016-03-23 15:30:27 +0530199 }
200 }
201 }
202
203 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530204 * Returns based on the target language generate the inherited data model node.
Vinod Kumar S38046502016-03-23 15:30:27 +0530205 *
206 * @param targetLanguage target language in which YANG mapping needs to be
Vidyashree Rama506cbe12016-03-28 11:59:27 +0530207 * generated
208 * @return the corresponding inherited node based on the target language
Vinod Kumar S38046502016-03-23 15:30:27 +0530209 */
210 public static YangTypeDef getYangTypeDefNode(GeneratedLanguage targetLanguage) {
211 switch (targetLanguage) {
212 case JAVA_GENERATION: {
213 return new YangJavaTypeDef();
214 }
215 default: {
Bharat saraswal6ef0b762016-04-05 12:45:45 +0530216 throw new TranslatorException("Only YANG to Java is supported.");
Vinod Kumar S38046502016-03-23 15:30:27 +0530217 }
218 }
219 }
220
221 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530222 * Returns based on the target language generate the inherited data model node.
Vinod Kumar S38046502016-03-23 15:30:27 +0530223 *
224 * @param targetLanguage target language in which YANG mapping needs to be
Vidyashree Rama506cbe12016-03-28 11:59:27 +0530225 * generated
226 * @return the corresponding inherited node based on the target language
Vinod Kumar S38046502016-03-23 15:30:27 +0530227 */
228 public static YangUses getYangUsesNode(GeneratedLanguage targetLanguage) {
229 switch (targetLanguage) {
230 case JAVA_GENERATION: {
231 return new YangJavaUses();
232 }
233 default: {
Bharat saraswal6ef0b762016-04-05 12:45:45 +0530234 throw new TranslatorException("Only YANG to Java is supported.");
Vinod Kumar S38046502016-03-23 15:30:27 +0530235 }
236 }
237 }
Vidyashree Rama506cbe12016-03-28 11:59:27 +0530238
239 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530240 * Returns based on the target language generate the inherited data model node.
Vidyashree Rama506cbe12016-03-28 11:59:27 +0530241 *
242 * @param targetLanguage target language in which YANG mapping needs to be
243 * generated
244 * @return the corresponding inherited node based on the target language
245 */
246 public static YangNotification getYangNotificationNode(GeneratedLanguage targetLanguage) {
247 switch (targetLanguage) {
248 case JAVA_GENERATION: {
249 return new YangJavaNotification();
250 }
251 default: {
Bharat saraswal6ef0b762016-04-05 12:45:45 +0530252 throw new TranslatorException("Only YANG to Java is supported.");
Vidyashree Rama506cbe12016-03-28 11:59:27 +0530253 }
254 }
255 }
Vidyashree Rama6a72b792016-03-29 12:00:42 +0530256
257 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530258 * Returns based on the target language generate the inherited data model node.
Vidyashree Rama6a72b792016-03-29 12:00:42 +0530259 *
260 * @param targetLanguage target language in which YANG mapping needs to be
261 * generated
262 * @return the corresponding inherited node based on the target language
263 */
264 public static YangRpc getYangRpcNode(GeneratedLanguage targetLanguage) {
265 switch (targetLanguage) {
266 case JAVA_GENERATION: {
267 return new YangJavaRpc();
268 }
269 default: {
Bharat saraswal6ef0b762016-04-05 12:45:45 +0530270 throw new TranslatorException("Only YANG to Java is supported.");
Vidyashree Rama6a72b792016-03-29 12:00:42 +0530271 }
272 }
273 }
274
275 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530276 * Returns based on the target language generate the inherited data model node.
Vidyashree Rama6a72b792016-03-29 12:00:42 +0530277 *
278 * @param targetLanguage target language in which YANG mapping needs to be
279 * generated
280 * @return the corresponding inherited node based on the target language
281 */
282 public static YangInput getYangInputNode(GeneratedLanguage targetLanguage) {
283 switch (targetLanguage) {
284 case JAVA_GENERATION: {
285 return new YangJavaInput();
286 }
287 default: {
Bharat saraswal6ef0b762016-04-05 12:45:45 +0530288 throw new TranslatorException("Only YANG to Java is supported.");
Vidyashree Rama6a72b792016-03-29 12:00:42 +0530289 }
290 }
291 }
292
293 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530294 * Returns based on the target language generate the inherited data model node.
Vidyashree Rama6a72b792016-03-29 12:00:42 +0530295 *
296 * @param targetLanguage target language in which YANG mapping needs to be
297 * generated
298 * @return the corresponding inherited node based on the target language
299 */
300 public static YangOutput getYangOutputNode(GeneratedLanguage targetLanguage) {
301 switch (targetLanguage) {
302 case JAVA_GENERATION: {
303 return new YangJavaOutput();
304 }
305 default: {
Bharat saraswal6ef0b762016-04-05 12:45:45 +0530306 throw new TranslatorException("Only YANG to Java is supported.");
Vidyashree Rama6a72b792016-03-29 12:00:42 +0530307 }
308 }
309 }
Vinod Kumar S38046502016-03-23 15:30:27 +0530310}