1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package QVTBase.util; |
8 | |
9 | import EMOF.Element; |
10 | import EMOF.MultiplicityElement; |
11 | import EMOF.NamedElement; |
12 | import EMOF.Operation; |
13 | import EMOF.Parameter; |
14 | import EMOF.Type; |
15 | import EMOF.TypedElement; |
16 | |
17 | import EssentialOCL.Variable; |
18 | |
19 | import QVTBase.*; |
20 | |
21 | import java.util.List; |
22 | |
23 | import org.eclipse.emf.ecore.EClass; |
24 | import org.eclipse.emf.ecore.EObject; |
25 | |
26 | /** |
27 | * <!-- begin-user-doc --> |
28 | * The <b>Switch</b> for the model's inheritance hierarchy. |
29 | * It supports the call {@link #doSwitch(EObject) doSwitch(object)} |
30 | * to invoke the <code>caseXXX</code> method for each class of the model, |
31 | * starting with the actual class of the object |
32 | * and proceeding up the inheritance hierarchy |
33 | * until a non-null result is returned, |
34 | * which is the result of the switch. |
35 | * <!-- end-user-doc --> |
36 | * @see QVTBase.QVTBasePackage |
37 | * @generated |
38 | */ |
39 | public class QVTBaseSwitch<T> { |
40 | /** |
41 | * The cached model package |
42 | * <!-- begin-user-doc --> |
43 | * <!-- end-user-doc --> |
44 | * @generated |
45 | */ |
46 | protected static QVTBasePackage modelPackage; |
47 | |
48 | /** |
49 | * Creates an instance of the switch. |
50 | * <!-- begin-user-doc --> |
51 | * <!-- end-user-doc --> |
52 | * @generated |
53 | */ |
54 | public QVTBaseSwitch() { |
55 | if (modelPackage == null) { |
56 | modelPackage = QVTBasePackage.eINSTANCE; |
57 | } |
58 | } |
59 | |
60 | /** |
61 | * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. |
62 | * <!-- begin-user-doc --> |
63 | * <!-- end-user-doc --> |
64 | * @return the first non-null result returned by a <code>caseXXX</code> call. |
65 | * @generated |
66 | */ |
67 | public T doSwitch(EObject theEObject) { |
68 | return doSwitch(theEObject.eClass(), theEObject); |
69 | } |
70 | |
71 | /** |
72 | * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. |
73 | * <!-- begin-user-doc --> |
74 | * <!-- end-user-doc --> |
75 | * @return the first non-null result returned by a <code>caseXXX</code> call. |
76 | * @generated |
77 | */ |
78 | protected T doSwitch(EClass theEClass, EObject theEObject) { |
79 | if (theEClass.eContainer() == modelPackage) { |
80 | return doSwitch(theEClass.getClassifierID(), theEObject); |
81 | } |
82 | else { |
83 | List<EClass> eSuperTypes = theEClass.getESuperTypes(); |
84 | return |
85 | eSuperTypes.isEmpty() ? |
86 | defaultCase(theEObject) : |
87 | doSwitch(eSuperTypes.get(0), theEObject); |
88 | } |
89 | } |
90 | |
91 | /** |
92 | * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. |
93 | * <!-- begin-user-doc --> |
94 | * <!-- end-user-doc --> |
95 | * @return the first non-null result returned by a <code>caseXXX</code> call. |
96 | * @generated |
97 | */ |
98 | protected T doSwitch(int classifierID, EObject theEObject) { |
99 | switch (classifierID) { |
100 | case QVTBasePackage.DOMAIN: { |
101 | Domain domain = (Domain)theEObject; |
102 | T result = caseDomain(domain); |
103 | if (result == null) result = caseNamedElement(domain); |
104 | if (result == null) result = caseElement(domain); |
105 | if (result == null) result = caseObject(domain); |
106 | if (result == null) result = defaultCase(theEObject); |
107 | return result; |
108 | } |
109 | case QVTBasePackage.FUNCTION: { |
110 | Function function = (Function)theEObject; |
111 | T result = caseFunction(function); |
112 | if (result == null) result = caseOperation(function); |
113 | if (result == null) result = caseTypedElement(function); |
114 | if (result == null) result = caseMultiplicityElement(function); |
115 | if (result == null) result = caseNamedElement(function); |
116 | if (result == null) result = caseElement(function); |
117 | if (result == null) result = caseObject(function); |
118 | if (result == null) result = defaultCase(theEObject); |
119 | return result; |
120 | } |
121 | case QVTBasePackage.FUNCTION_PARAMETER: { |
122 | FunctionParameter functionParameter = (FunctionParameter)theEObject; |
123 | T result = caseFunctionParameter(functionParameter); |
124 | if (result == null) result = caseVariable(functionParameter); |
125 | if (result == null) result = caseParameter(functionParameter); |
126 | if (result == null) result = caseTypedElement(functionParameter); |
127 | if (result == null) result = caseMultiplicityElement(functionParameter); |
128 | if (result == null) result = caseNamedElement(functionParameter); |
129 | if (result == null) result = caseElement(functionParameter); |
130 | if (result == null) result = caseObject(functionParameter); |
131 | if (result == null) result = defaultCase(theEObject); |
132 | return result; |
133 | } |
134 | case QVTBasePackage.PATTERN: { |
135 | Pattern pattern = (Pattern)theEObject; |
136 | T result = casePattern(pattern); |
137 | if (result == null) result = caseElement(pattern); |
138 | if (result == null) result = caseObject(pattern); |
139 | if (result == null) result = defaultCase(theEObject); |
140 | return result; |
141 | } |
142 | case QVTBasePackage.PREDICATE: { |
143 | Predicate predicate = (Predicate)theEObject; |
144 | T result = casePredicate(predicate); |
145 | if (result == null) result = caseElement(predicate); |
146 | if (result == null) result = caseObject(predicate); |
147 | if (result == null) result = defaultCase(theEObject); |
148 | return result; |
149 | } |
150 | case QVTBasePackage.RULE: { |
151 | Rule rule = (Rule)theEObject; |
152 | T result = caseRule(rule); |
153 | if (result == null) result = caseNamedElement(rule); |
154 | if (result == null) result = caseElement(rule); |
155 | if (result == null) result = caseObject(rule); |
156 | if (result == null) result = defaultCase(theEObject); |
157 | return result; |
158 | } |
159 | case QVTBasePackage.TRANSFORMATION: { |
160 | Transformation transformation = (Transformation)theEObject; |
161 | T result = caseTransformation(transformation); |
162 | if (result == null) result = caseClass(transformation); |
163 | if (result == null) result = casePackage(transformation); |
164 | if (result == null) result = caseType(transformation); |
165 | if (result == null) result = caseNamedElement(transformation); |
166 | if (result == null) result = caseElement(transformation); |
167 | if (result == null) result = caseObject(transformation); |
168 | if (result == null) result = defaultCase(theEObject); |
169 | return result; |
170 | } |
171 | case QVTBasePackage.TYPED_MODEL: { |
172 | TypedModel typedModel = (TypedModel)theEObject; |
173 | T result = caseTypedModel(typedModel); |
174 | if (result == null) result = caseNamedElement(typedModel); |
175 | if (result == null) result = caseElement(typedModel); |
176 | if (result == null) result = caseObject(typedModel); |
177 | if (result == null) result = defaultCase(theEObject); |
178 | return result; |
179 | } |
180 | default: return defaultCase(theEObject); |
181 | } |
182 | } |
183 | |
184 | /** |
185 | * Returns the result of interpreting the object as an instance of '<em>Domain</em>'. |
186 | * <!-- begin-user-doc --> |
187 | * This implementation returns null; |
188 | * returning a non-null result will terminate the switch. |
189 | * <!-- end-user-doc --> |
190 | * @param object the target of the switch. |
191 | * @return the result of interpreting the object as an instance of '<em>Domain</em>'. |
192 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
193 | * @generated |
194 | */ |
195 | public T caseDomain(Domain object) { |
196 | return null; |
197 | } |
198 | |
199 | /** |
200 | * Returns the result of interpreting the object as an instance of '<em>Function</em>'. |
201 | * <!-- begin-user-doc --> |
202 | * This implementation returns null; |
203 | * returning a non-null result will terminate the switch. |
204 | * <!-- end-user-doc --> |
205 | * @param object the target of the switch. |
206 | * @return the result of interpreting the object as an instance of '<em>Function</em>'. |
207 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
208 | * @generated |
209 | */ |
210 | public T caseFunction(Function object) { |
211 | return null; |
212 | } |
213 | |
214 | /** |
215 | * Returns the result of interpreting the object as an instance of '<em>Function Parameter</em>'. |
216 | * <!-- begin-user-doc --> |
217 | * This implementation returns null; |
218 | * returning a non-null result will terminate the switch. |
219 | * <!-- end-user-doc --> |
220 | * @param object the target of the switch. |
221 | * @return the result of interpreting the object as an instance of '<em>Function Parameter</em>'. |
222 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
223 | * @generated |
224 | */ |
225 | public T caseFunctionParameter(FunctionParameter object) { |
226 | return null; |
227 | } |
228 | |
229 | /** |
230 | * Returns the result of interpreting the object as an instance of '<em>Pattern</em>'. |
231 | * <!-- begin-user-doc --> |
232 | * This implementation returns null; |
233 | * returning a non-null result will terminate the switch. |
234 | * <!-- end-user-doc --> |
235 | * @param object the target of the switch. |
236 | * @return the result of interpreting the object as an instance of '<em>Pattern</em>'. |
237 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
238 | * @generated |
239 | */ |
240 | public T casePattern(Pattern object) { |
241 | return null; |
242 | } |
243 | |
244 | /** |
245 | * Returns the result of interpreting the object as an instance of '<em>Predicate</em>'. |
246 | * <!-- begin-user-doc --> |
247 | * This implementation returns null; |
248 | * returning a non-null result will terminate the switch. |
249 | * <!-- end-user-doc --> |
250 | * @param object the target of the switch. |
251 | * @return the result of interpreting the object as an instance of '<em>Predicate</em>'. |
252 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
253 | * @generated |
254 | */ |
255 | public T casePredicate(Predicate object) { |
256 | return null; |
257 | } |
258 | |
259 | /** |
260 | * Returns the result of interpreting the object as an instance of '<em>Rule</em>'. |
261 | * <!-- begin-user-doc --> |
262 | * This implementation returns null; |
263 | * returning a non-null result will terminate the switch. |
264 | * <!-- end-user-doc --> |
265 | * @param object the target of the switch. |
266 | * @return the result of interpreting the object as an instance of '<em>Rule</em>'. |
267 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
268 | * @generated |
269 | */ |
270 | public T caseRule(Rule object) { |
271 | return null; |
272 | } |
273 | |
274 | /** |
275 | * Returns the result of interpreting the object as an instance of '<em>Transformation</em>'. |
276 | * <!-- begin-user-doc --> |
277 | * This implementation returns null; |
278 | * returning a non-null result will terminate the switch. |
279 | * <!-- end-user-doc --> |
280 | * @param object the target of the switch. |
281 | * @return the result of interpreting the object as an instance of '<em>Transformation</em>'. |
282 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
283 | * @generated |
284 | */ |
285 | public T caseTransformation(Transformation object) { |
286 | return null; |
287 | } |
288 | |
289 | /** |
290 | * Returns the result of interpreting the object as an instance of '<em>Typed Model</em>'. |
291 | * <!-- begin-user-doc --> |
292 | * This implementation returns null; |
293 | * returning a non-null result will terminate the switch. |
294 | * <!-- end-user-doc --> |
295 | * @param object the target of the switch. |
296 | * @return the result of interpreting the object as an instance of '<em>Typed Model</em>'. |
297 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
298 | * @generated |
299 | */ |
300 | public T caseTypedModel(TypedModel object) { |
301 | return null; |
302 | } |
303 | |
304 | /** |
305 | * Returns the result of interpreting the object as an instance of '<em>Object</em>'. |
306 | * <!-- begin-user-doc --> |
307 | * This implementation returns null; |
308 | * returning a non-null result will terminate the switch. |
309 | * <!-- end-user-doc --> |
310 | * @param object the target of the switch. |
311 | * @return the result of interpreting the object as an instance of '<em>Object</em>'. |
312 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
313 | * @generated |
314 | */ |
315 | public T caseObject(EMOF.Object object) { |
316 | return null; |
317 | } |
318 | |
319 | /** |
320 | * Returns the result of interpreting the object as an instance of '<em>Element</em>'. |
321 | * <!-- begin-user-doc --> |
322 | * This implementation returns null; |
323 | * returning a non-null result will terminate the switch. |
324 | * <!-- end-user-doc --> |
325 | * @param object the target of the switch. |
326 | * @return the result of interpreting the object as an instance of '<em>Element</em>'. |
327 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
328 | * @generated |
329 | */ |
330 | public T caseElement(Element object) { |
331 | return null; |
332 | } |
333 | |
334 | /** |
335 | * Returns the result of interpreting the object as an instance of '<em>Named Element</em>'. |
336 | * <!-- begin-user-doc --> |
337 | * This implementation returns null; |
338 | * returning a non-null result will terminate the switch. |
339 | * <!-- end-user-doc --> |
340 | * @param object the target of the switch. |
341 | * @return the result of interpreting the object as an instance of '<em>Named Element</em>'. |
342 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
343 | * @generated |
344 | */ |
345 | public T caseNamedElement(NamedElement object) { |
346 | return null; |
347 | } |
348 | |
349 | /** |
350 | * Returns the result of interpreting the object as an instance of '<em>Typed Element</em>'. |
351 | * <!-- begin-user-doc --> |
352 | * This implementation returns null; |
353 | * returning a non-null result will terminate the switch. |
354 | * <!-- end-user-doc --> |
355 | * @param object the target of the switch. |
356 | * @return the result of interpreting the object as an instance of '<em>Typed Element</em>'. |
357 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
358 | * @generated |
359 | */ |
360 | public T caseTypedElement(TypedElement object) { |
361 | return null; |
362 | } |
363 | |
364 | /** |
365 | * Returns the result of interpreting the object as an instance of '<em>Multiplicity Element</em>'. |
366 | * <!-- begin-user-doc --> |
367 | * This implementation returns null; |
368 | * returning a non-null result will terminate the switch. |
369 | * <!-- end-user-doc --> |
370 | * @param object the target of the switch. |
371 | * @return the result of interpreting the object as an instance of '<em>Multiplicity Element</em>'. |
372 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
373 | * @generated |
374 | */ |
375 | public T caseMultiplicityElement(MultiplicityElement object) { |
376 | return null; |
377 | } |
378 | |
379 | /** |
380 | * Returns the result of interpreting the object as an instance of '<em>Operation</em>'. |
381 | * <!-- begin-user-doc --> |
382 | * This implementation returns null; |
383 | * returning a non-null result will terminate the switch. |
384 | * <!-- end-user-doc --> |
385 | * @param object the target of the switch. |
386 | * @return the result of interpreting the object as an instance of '<em>Operation</em>'. |
387 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
388 | * @generated |
389 | */ |
390 | public T caseOperation(Operation object) { |
391 | return null; |
392 | } |
393 | |
394 | /** |
395 | * Returns the result of interpreting the object as an instance of '<em>Variable</em>'. |
396 | * <!-- begin-user-doc --> |
397 | * This implementation returns null; |
398 | * returning a non-null result will terminate the switch. |
399 | * <!-- end-user-doc --> |
400 | * @param object the target of the switch. |
401 | * @return the result of interpreting the object as an instance of '<em>Variable</em>'. |
402 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
403 | * @generated |
404 | */ |
405 | public T caseVariable(Variable object) { |
406 | return null; |
407 | } |
408 | |
409 | /** |
410 | * Returns the result of interpreting the object as an instance of '<em>Parameter</em>'. |
411 | * <!-- begin-user-doc --> |
412 | * This implementation returns null; |
413 | * returning a non-null result will terminate the switch. |
414 | * <!-- end-user-doc --> |
415 | * @param object the target of the switch. |
416 | * @return the result of interpreting the object as an instance of '<em>Parameter</em>'. |
417 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
418 | * @generated |
419 | */ |
420 | public T caseParameter(Parameter object) { |
421 | return null; |
422 | } |
423 | |
424 | /** |
425 | * Returns the result of interpreting the object as an instance of '<em>Type</em>'. |
426 | * <!-- begin-user-doc --> |
427 | * This implementation returns null; |
428 | * returning a non-null result will terminate the switch. |
429 | * <!-- end-user-doc --> |
430 | * @param object the target of the switch. |
431 | * @return the result of interpreting the object as an instance of '<em>Type</em>'. |
432 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
433 | * @generated |
434 | */ |
435 | public T caseType(Type object) { |
436 | return null; |
437 | } |
438 | |
439 | /** |
440 | * Returns the result of interpreting the object as an instance of '<em>Class</em>'. |
441 | * <!-- begin-user-doc --> |
442 | * This implementation returns null; |
443 | * returning a non-null result will terminate the switch. |
444 | * <!-- end-user-doc --> |
445 | * @param object the target of the switch. |
446 | * @return the result of interpreting the object as an instance of '<em>Class</em>'. |
447 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
448 | * @generated |
449 | */ |
450 | public T caseClass(EMOF.Class object) { |
451 | return null; |
452 | } |
453 | |
454 | /** |
455 | * Returns the result of interpreting the object as an instance of '<em>Package</em>'. |
456 | * <!-- begin-user-doc --> |
457 | * This implementation returns null; |
458 | * returning a non-null result will terminate the switch. |
459 | * <!-- end-user-doc --> |
460 | * @param object the target of the switch. |
461 | * @return the result of interpreting the object as an instance of '<em>Package</em>'. |
462 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
463 | * @generated |
464 | */ |
465 | public T casePackage(EMOF.Package object) { |
466 | return null; |
467 | } |
468 | |
469 | /** |
470 | * Returns the result of interpreting the object as an instance of '<em>EObject</em>'. |
471 | * <!-- begin-user-doc --> |
472 | * This implementation returns null; |
473 | * returning a non-null result will terminate the switch, but this is the last case anyway. |
474 | * <!-- end-user-doc --> |
475 | * @param object the target of the switch. |
476 | * @return the result of interpreting the object as an instance of '<em>EObject</em>'. |
477 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) |
478 | * @generated |
479 | */ |
480 | public T defaultCase(EObject object) { |
481 | return null; |
482 | } |
483 | |
484 | } //QVTBaseSwitch |