blob: 92b3420282bb36caa19c7044d2eebf9224ea79bb [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;
Vinod Kumar S38046502016-03-23 15:30:27 +053029import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaAugment;
30import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaCase;
31import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaChoice;
32import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaContainer;
33import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaGrouping;
34import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaList;
35import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule;
36import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaSubModule;
37import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaTypeDef;
38import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaUses;
Vidyashree Rama506cbe12016-03-28 11:59:27 +053039import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaNotification;
Vinod Kumar S38046502016-03-23 15:30:27 +053040
41/**
42 * Factory to create data model objects based on the target file type.
43 */
44public final class YangDataModelFactory {
45
46 /**
47 * Utility class, hence private to prevent creating objects.
48 */
49 private YangDataModelFactory() {
50 }
51
52 /**
53 * Based on the target language generate the inherited data model node.
54 *
55 * @param targetLanguage target language in which YANG mapping needs to be
Vidyashree Rama506cbe12016-03-28 11:59:27 +053056 * generated
57 * @return the corresponding inherited node based on the target language
Vinod Kumar S38046502016-03-23 15:30:27 +053058 */
59 public static YangModule getYangModuleNode(GeneratedLanguage targetLanguage) {
60 switch (targetLanguage) {
61 case JAVA_GENERATION: {
62 return new YangJavaModule();
63 }
64 default: {
65 throw new RuntimeException("Only YANG to Java is supported.");
66 }
67 }
68 }
69
70 /**
71 * Based on the target language generate the inherited data model node.
72 *
73 * @param targetLanguage target language in which YANG mapping needs to be
Vidyashree Rama506cbe12016-03-28 11:59:27 +053074 * generated
75 * @return the corresponding inherited node based on the target language
Vinod Kumar S38046502016-03-23 15:30:27 +053076 */
77 public static YangAugment getYangAugmentNode(GeneratedLanguage targetLanguage) {
78 switch (targetLanguage) {
79 case JAVA_GENERATION: {
80 return new YangJavaAugment();
81 }
82 default: {
83 throw new RuntimeException("Only YANG to Java is supported.");
84 }
85 }
86 }
87
88 /**
89 * Based on the target language generate the inherited data model node.
90 *
91 * @param targetLanguage target language in which YANG mapping needs to be
Vidyashree Rama506cbe12016-03-28 11:59:27 +053092 * generated
93 * @return the corresponding inherited node based on the target language
Vinod Kumar S38046502016-03-23 15:30:27 +053094 */
95 public static YangCase getYangCaseNode(GeneratedLanguage targetLanguage) {
96 switch (targetLanguage) {
97 case JAVA_GENERATION: {
98 return new YangJavaCase();
99 }
100 default: {
101 throw new RuntimeException("Only YANG to Java is supported.");
102 }
103 }
104 }
105
106 /**
107 * Based on the target language generate the inherited data model node.
108 *
109 * @param targetLanguage target language in which YANG mapping needs to be
Vidyashree Rama506cbe12016-03-28 11:59:27 +0530110 * generated
111 * @return the corresponding inherited node based on the target language
Vinod Kumar S38046502016-03-23 15:30:27 +0530112 */
113 public static YangChoice getYangChoiceNode(GeneratedLanguage targetLanguage) {
114 switch (targetLanguage) {
115 case JAVA_GENERATION: {
116 return new YangJavaChoice();
117 }
118 default: {
119 throw new RuntimeException("Only YANG to Java is supported.");
120 }
121 }
122 }
123
124 /**
125 * Based on the target language generate the inherited data model node.
126 *
127 * @param targetLanguage target language in which YANG mapping needs to be
Vidyashree Rama506cbe12016-03-28 11:59:27 +0530128 * generated
129 * @return the corresponding inherited node based on the target language
Vinod Kumar S38046502016-03-23 15:30:27 +0530130 */
131 public static YangContainer getYangContainerNode(GeneratedLanguage targetLanguage) {
132 switch (targetLanguage) {
133 case JAVA_GENERATION: {
134 return new YangJavaContainer();
135 }
136 default: {
137 throw new RuntimeException("Only YANG to Java is supported.");
138 }
139 }
140 }
141
142 /**
143 * Based on the target language generate the inherited data model node.
144 *
145 * @param targetLanguage target language in which YANG mapping needs to be
Vidyashree Rama506cbe12016-03-28 11:59:27 +0530146 * generated
147 * @return the corresponding inherited node based on the target language
Vinod Kumar S38046502016-03-23 15:30:27 +0530148 */
149 public static YangGrouping getYangGroupingNode(GeneratedLanguage targetLanguage) {
150 switch (targetLanguage) {
151 case JAVA_GENERATION: {
152 return new YangJavaGrouping();
153 }
154 default: {
155 throw new RuntimeException("Only YANG to Java is supported.");
156 }
157 }
158 }
159
160 /**
161 * Based on the target language generate the inherited data model node.
162 *
163 * @param targetLanguage target language in which YANG mapping needs to be
Vidyashree Rama506cbe12016-03-28 11:59:27 +0530164 * generated
165 * @return the corresponding inherited node based on the target language
Vinod Kumar S38046502016-03-23 15:30:27 +0530166 */
167 public static YangList getYangListNode(GeneratedLanguage targetLanguage) {
168 switch (targetLanguage) {
169 case JAVA_GENERATION: {
170 return new YangJavaList();
171 }
172 default: {
173 throw new RuntimeException("Only YANG to Java is supported.");
174 }
175 }
176 }
177
178 /**
179 * Based on the target language generate the inherited data model node.
180 *
181 * @param targetLanguage target language in which YANG mapping needs to be
Vidyashree Rama506cbe12016-03-28 11:59:27 +0530182 * generated
183 * @return the corresponding inherited node based on the target language
Vinod Kumar S38046502016-03-23 15:30:27 +0530184 */
185 public static YangSubModule getYangSubModuleNode(GeneratedLanguage targetLanguage) {
186 switch (targetLanguage) {
187 case JAVA_GENERATION: {
188 return new YangJavaSubModule();
189 }
190 default: {
191 throw new RuntimeException("Only YANG to Java is supported.");
192 }
193 }
194 }
195
196 /**
197 * Based on the target language generate the inherited data model node.
198 *
199 * @param targetLanguage target language in which YANG mapping needs to be
Vidyashree Rama506cbe12016-03-28 11:59:27 +0530200 * generated
201 * @return the corresponding inherited node based on the target language
Vinod Kumar S38046502016-03-23 15:30:27 +0530202 */
203 public static YangTypeDef getYangTypeDefNode(GeneratedLanguage targetLanguage) {
204 switch (targetLanguage) {
205 case JAVA_GENERATION: {
206 return new YangJavaTypeDef();
207 }
208 default: {
209 throw new RuntimeException("Only YANG to Java is supported.");
210 }
211 }
212 }
213
214 /**
215 * Based on the target language generate the inherited data model node.
216 *
217 * @param targetLanguage target language in which YANG mapping needs to be
Vidyashree Rama506cbe12016-03-28 11:59:27 +0530218 * generated
219 * @return the corresponding inherited node based on the target language
Vinod Kumar S38046502016-03-23 15:30:27 +0530220 */
221 public static YangUses getYangUsesNode(GeneratedLanguage targetLanguage) {
222 switch (targetLanguage) {
223 case JAVA_GENERATION: {
224 return new YangJavaUses();
225 }
226 default: {
227 throw new RuntimeException("Only YANG to Java is supported.");
228 }
229 }
230 }
Vidyashree Rama506cbe12016-03-28 11:59:27 +0530231
232 /**
233 * Based on the target language generate the inherited data model node.
234 *
235 * @param targetLanguage target language in which YANG mapping needs to be
236 * generated
237 * @return the corresponding inherited node based on the target language
238 */
239 public static YangNotification getYangNotificationNode(GeneratedLanguage targetLanguage) {
240 switch (targetLanguage) {
241 case JAVA_GENERATION: {
242 return new YangJavaNotification();
243 }
244 default: {
245 throw new RuntimeException("Only YANG to Java is supported.");
246 }
247 }
248 }
Vinod Kumar S38046502016-03-23 15:30:27 +0530249}