blob: 4e488bbec03e6badec0209c6bc3bbad60e32690b [file] [log] [blame]
Vinod Kumar S38046502016-03-23 15:30:27 +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.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;
Vinod Kumar S38046502016-03-23 15:30:27 +053046
47/**
48 * Factory to create data model objects based on the target file type.
49 */
50public final class YangDataModelFactory {
51
52 /**
53 * Utility class, hence private to prevent creating objects.
54 */
55 private YangDataModelFactory() {
56 }
57
58 /**
59 * Based on the target language generate the inherited data model node.
60 *
61 * @param targetLanguage target language in which YANG mapping needs to be
Vidyashree Rama506cbe12016-03-28 11:59:27 +053062 * generated
63 * @return the corresponding inherited node based on the target language
Vinod Kumar S38046502016-03-23 15:30:27 +053064 */
65 public static YangModule getYangModuleNode(GeneratedLanguage targetLanguage) {
66 switch (targetLanguage) {
67 case JAVA_GENERATION: {
68 return new YangJavaModule();
69 }
70 default: {
71 throw new RuntimeException("Only YANG to Java is supported.");
72 }
73 }
74 }
75
76 /**
77 * Based on the target language generate the inherited data model node.
78 *
79 * @param targetLanguage target language in which YANG mapping needs to be
Vidyashree Rama506cbe12016-03-28 11:59:27 +053080 * generated
81 * @return the corresponding inherited node based on the target language
Vinod Kumar S38046502016-03-23 15:30:27 +053082 */
83 public static YangAugment getYangAugmentNode(GeneratedLanguage targetLanguage) {
84 switch (targetLanguage) {
85 case JAVA_GENERATION: {
86 return new YangJavaAugment();
87 }
88 default: {
89 throw new RuntimeException("Only YANG to Java is supported.");
90 }
91 }
92 }
93
94 /**
95 * Based on the target language generate the inherited data model node.
96 *
97 * @param targetLanguage target language in which YANG mapping needs to be
Vidyashree Rama506cbe12016-03-28 11:59:27 +053098 * generated
99 * @return the corresponding inherited node based on the target language
Vinod Kumar S38046502016-03-23 15:30:27 +0530100 */
101 public static YangCase getYangCaseNode(GeneratedLanguage targetLanguage) {
102 switch (targetLanguage) {
103 case JAVA_GENERATION: {
104 return new YangJavaCase();
105 }
106 default: {
107 throw new RuntimeException("Only YANG to Java is supported.");
108 }
109 }
110 }
111
112 /**
113 * Based on the target language generate the inherited data model node.
114 *
115 * @param targetLanguage target language in which YANG mapping needs to be
Vidyashree Rama506cbe12016-03-28 11:59:27 +0530116 * generated
117 * @return the corresponding inherited node based on the target language
Vinod Kumar S38046502016-03-23 15:30:27 +0530118 */
119 public static YangChoice getYangChoiceNode(GeneratedLanguage targetLanguage) {
120 switch (targetLanguage) {
121 case JAVA_GENERATION: {
122 return new YangJavaChoice();
123 }
124 default: {
125 throw new RuntimeException("Only YANG to Java is supported.");
126 }
127 }
128 }
129
130 /**
131 * Based on the target language generate the inherited data model node.
132 *
133 * @param targetLanguage target language in which YANG mapping needs to be
Vidyashree Rama506cbe12016-03-28 11:59:27 +0530134 * generated
135 * @return the corresponding inherited node based on the target language
Vinod Kumar S38046502016-03-23 15:30:27 +0530136 */
137 public static YangContainer getYangContainerNode(GeneratedLanguage targetLanguage) {
138 switch (targetLanguage) {
139 case JAVA_GENERATION: {
140 return new YangJavaContainer();
141 }
142 default: {
143 throw new RuntimeException("Only YANG to Java is supported.");
144 }
145 }
146 }
147
148 /**
149 * Based on the target language generate the inherited data model node.
150 *
151 * @param targetLanguage target language in which YANG mapping needs to be
Vidyashree Rama506cbe12016-03-28 11:59:27 +0530152 * generated
153 * @return the corresponding inherited node based on the target language
Vinod Kumar S38046502016-03-23 15:30:27 +0530154 */
155 public static YangGrouping getYangGroupingNode(GeneratedLanguage targetLanguage) {
156 switch (targetLanguage) {
157 case JAVA_GENERATION: {
158 return new YangJavaGrouping();
159 }
160 default: {
161 throw new RuntimeException("Only YANG to Java is supported.");
162 }
163 }
164 }
165
166 /**
167 * Based on the target language generate the inherited data model node.
168 *
169 * @param targetLanguage target language in which YANG mapping needs to be
Vidyashree Rama506cbe12016-03-28 11:59:27 +0530170 * generated
171 * @return the corresponding inherited node based on the target language
Vinod Kumar S38046502016-03-23 15:30:27 +0530172 */
173 public static YangList getYangListNode(GeneratedLanguage targetLanguage) {
174 switch (targetLanguage) {
175 case JAVA_GENERATION: {
176 return new YangJavaList();
177 }
178 default: {
179 throw new RuntimeException("Only YANG to Java is supported.");
180 }
181 }
182 }
183
184 /**
185 * Based on the target language generate the inherited data model node.
186 *
187 * @param targetLanguage target language in which YANG mapping needs to be
Vidyashree Rama506cbe12016-03-28 11:59:27 +0530188 * generated
189 * @return the corresponding inherited node based on the target language
Vinod Kumar S38046502016-03-23 15:30:27 +0530190 */
191 public static YangSubModule getYangSubModuleNode(GeneratedLanguage targetLanguage) {
192 switch (targetLanguage) {
193 case JAVA_GENERATION: {
194 return new YangJavaSubModule();
195 }
196 default: {
197 throw new RuntimeException("Only YANG to Java is supported.");
198 }
199 }
200 }
201
202 /**
203 * Based on the target language generate the inherited data model node.
204 *
205 * @param targetLanguage target language in which YANG mapping needs to be
Vidyashree Rama506cbe12016-03-28 11:59:27 +0530206 * generated
207 * @return the corresponding inherited node based on the target language
Vinod Kumar S38046502016-03-23 15:30:27 +0530208 */
209 public static YangTypeDef getYangTypeDefNode(GeneratedLanguage targetLanguage) {
210 switch (targetLanguage) {
211 case JAVA_GENERATION: {
212 return new YangJavaTypeDef();
213 }
214 default: {
215 throw new RuntimeException("Only YANG to Java is supported.");
216 }
217 }
218 }
219
220 /**
221 * Based on the target language generate the inherited data model node.
222 *
223 * @param targetLanguage target language in which YANG mapping needs to be
Vidyashree Rama506cbe12016-03-28 11:59:27 +0530224 * generated
225 * @return the corresponding inherited node based on the target language
Vinod Kumar S38046502016-03-23 15:30:27 +0530226 */
227 public static YangUses getYangUsesNode(GeneratedLanguage targetLanguage) {
228 switch (targetLanguage) {
229 case JAVA_GENERATION: {
230 return new YangJavaUses();
231 }
232 default: {
233 throw new RuntimeException("Only YANG to Java is supported.");
234 }
235 }
236 }
Vidyashree Rama506cbe12016-03-28 11:59:27 +0530237
238 /**
239 * Based on the target language generate the inherited data model node.
240 *
241 * @param targetLanguage target language in which YANG mapping needs to be
242 * generated
243 * @return the corresponding inherited node based on the target language
244 */
245 public static YangNotification getYangNotificationNode(GeneratedLanguage targetLanguage) {
246 switch (targetLanguage) {
247 case JAVA_GENERATION: {
248 return new YangJavaNotification();
249 }
250 default: {
251 throw new RuntimeException("Only YANG to Java is supported.");
252 }
253 }
254 }
Vidyashree Rama6a72b792016-03-29 12:00:42 +0530255
256 /**
257 * Based on the target language generate the inherited data model node.
258 *
259 * @param targetLanguage target language in which YANG mapping needs to be
260 * generated
261 * @return the corresponding inherited node based on the target language
262 */
263 public static YangRpc getYangRpcNode(GeneratedLanguage targetLanguage) {
264 switch (targetLanguage) {
265 case JAVA_GENERATION: {
266 return new YangJavaRpc();
267 }
268 default: {
269 throw new RuntimeException("Only YANG to Java is supported.");
270 }
271 }
272 }
273
274 /**
275 * Based on the target language generate the inherited data model node.
276 *
277 * @param targetLanguage target language in which YANG mapping needs to be
278 * generated
279 * @return the corresponding inherited node based on the target language
280 */
281 public static YangInput getYangInputNode(GeneratedLanguage targetLanguage) {
282 switch (targetLanguage) {
283 case JAVA_GENERATION: {
284 return new YangJavaInput();
285 }
286 default: {
287 throw new RuntimeException("Only YANG to Java is supported.");
288 }
289 }
290 }
291
292 /**
293 * Based on the target language generate the inherited data model node.
294 *
295 * @param targetLanguage target language in which YANG mapping needs to be
296 * generated
297 * @return the corresponding inherited node based on the target language
298 */
299 public static YangOutput getYangOutputNode(GeneratedLanguage targetLanguage) {
300 switch (targetLanguage) {
301 case JAVA_GENERATION: {
302 return new YangJavaOutput();
303 }
304 default: {
305 throw new RuntimeException("Only YANG to Java is supported.");
306 }
307 }
308 }
Vinod Kumar S38046502016-03-23 15:30:27 +0530309}