1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package de.uka.ipd.sdq.spa.expression.util; |
8 | |
9 | import de.uka.ipd.sdq.spa.expression.*; |
10 | |
11 | import java.util.List; |
12 | |
13 | import org.eclipse.emf.ecore.EClass; |
14 | import org.eclipse.emf.ecore.EObject; |
15 | |
16 | /** |
17 | * <!-- begin-user-doc --> |
18 | * The <b>Switch</b> for the model's inheritance hierarchy. |
19 | * It supports the call {@link #doSwitch(EObject) doSwitch(object)} |
20 | * to invoke the <code>caseXXX</code> method for each class of the model, |
21 | * starting with the actual class of the object |
22 | * and proceeding up the inheritance hierarchy |
23 | * until a non-null result is returned, |
24 | * which is the result of the switch. |
25 | * <!-- end-user-doc --> |
26 | * @see de.uka.ipd.sdq.spa.expression.ExpressionPackage |
27 | * @generated |
28 | */ |
29 | public class ExpressionSwitch<T> { |
30 | /** |
31 | * The cached model package |
32 | * <!-- begin-user-doc --> |
33 | * <!-- end-user-doc --> |
34 | * @generated |
35 | */ |
36 | protected static ExpressionPackage modelPackage; |
37 | |
38 | /** |
39 | * Creates an instance of the switch. |
40 | * <!-- begin-user-doc --> |
41 | * <!-- end-user-doc --> |
42 | * @generated |
43 | */ |
44 | public ExpressionSwitch() { |
45 | if (modelPackage == null) { |
46 | modelPackage = ExpressionPackage.eINSTANCE; |
47 | } |
48 | } |
49 | |
50 | /** |
51 | * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. |
52 | * <!-- begin-user-doc --> |
53 | * <!-- end-user-doc --> |
54 | * @return the first non-null result returned by a <code>caseXXX</code> call. |
55 | * @generated |
56 | */ |
57 | public T doSwitch(EObject theEObject) { |
58 | return doSwitch(theEObject.eClass(), theEObject); |
59 | } |
60 | |
61 | /** |
62 | * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. |
63 | * <!-- begin-user-doc --> |
64 | * <!-- end-user-doc --> |
65 | * @return the first non-null result returned by a <code>caseXXX</code> call. |
66 | * @generated |
67 | */ |
68 | protected T doSwitch(EClass theEClass, EObject theEObject) { |
69 | if (theEClass.eContainer() == modelPackage) { |
70 | return doSwitch(theEClass.getClassifierID(), theEObject); |
71 | } |
72 | else { |
73 | List<EClass> eSuperTypes = theEClass.getESuperTypes(); |
74 | return |
75 | eSuperTypes.isEmpty() ? |
76 | defaultCase(theEObject) : |
77 | doSwitch(eSuperTypes.get(0), theEObject); |
78 | } |
79 | } |
80 | |
81 | /** |
82 | * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. |
83 | * <!-- begin-user-doc --> |
84 | * <!-- end-user-doc --> |
85 | * @return the first non-null result returned by a <code>caseXXX</code> call. |
86 | * @generated |
87 | */ |
88 | protected T doSwitch(int classifierID, EObject theEObject) { |
89 | switch (classifierID) { |
90 | case ExpressionPackage.TERMINAL: { |
91 | Terminal terminal = (Terminal)theEObject; |
92 | T result = caseTerminal(terminal); |
93 | if (result == null) result = caseExpression(terminal); |
94 | if (result == null) result = defaultCase(theEObject); |
95 | return result; |
96 | } |
97 | case ExpressionPackage.EXPRESSION: { |
98 | Expression expression = (Expression)theEObject; |
99 | T result = caseExpression(expression); |
100 | if (result == null) result = defaultCase(theEObject); |
101 | return result; |
102 | } |
103 | case ExpressionPackage.SYMBOL: { |
104 | Symbol symbol = (Symbol)theEObject; |
105 | T result = caseSymbol(symbol); |
106 | if (result == null) result = caseTerminal(symbol); |
107 | if (result == null) result = caseExpression(symbol); |
108 | if (result == null) result = defaultCase(theEObject); |
109 | return result; |
110 | } |
111 | case ExpressionPackage.SEQUENCE: { |
112 | Sequence sequence = (Sequence)theEObject; |
113 | T result = caseSequence(sequence); |
114 | if (result == null) result = caseOperation(sequence); |
115 | if (result == null) result = caseExpression(sequence); |
116 | if (result == null) result = defaultCase(theEObject); |
117 | return result; |
118 | } |
119 | case ExpressionPackage.OPERATION: { |
120 | Operation operation = (Operation)theEObject; |
121 | T result = caseOperation(operation); |
122 | if (result == null) result = caseExpression(operation); |
123 | if (result == null) result = defaultCase(theEObject); |
124 | return result; |
125 | } |
126 | case ExpressionPackage.RELEASE: { |
127 | Release release = (Release)theEObject; |
128 | T result = caseRelease(release); |
129 | if (result == null) result = caseTerminal(release); |
130 | if (result == null) result = caseExpression(release); |
131 | if (result == null) result = defaultCase(theEObject); |
132 | return result; |
133 | } |
134 | case ExpressionPackage.PARALLEL: { |
135 | Parallel parallel = (Parallel)theEObject; |
136 | T result = caseParallel(parallel); |
137 | if (result == null) result = caseOperation(parallel); |
138 | if (result == null) result = caseExpression(parallel); |
139 | if (result == null) result = defaultCase(theEObject); |
140 | return result; |
141 | } |
142 | case ExpressionPackage.OPTION: { |
143 | Option option = (Option)theEObject; |
144 | T result = caseOption(option); |
145 | if (result == null) result = defaultCase(theEObject); |
146 | return result; |
147 | } |
148 | case ExpressionPackage.LOOP: { |
149 | Loop loop = (Loop)theEObject; |
150 | T result = caseLoop(loop); |
151 | if (result == null) result = caseOperation(loop); |
152 | if (result == null) result = caseExpression(loop); |
153 | if (result == null) result = defaultCase(theEObject); |
154 | return result; |
155 | } |
156 | case ExpressionPackage.ALTERNATIVE: { |
157 | Alternative alternative = (Alternative)theEObject; |
158 | T result = caseAlternative(alternative); |
159 | if (result == null) result = caseOperation(alternative); |
160 | if (result == null) result = caseExpression(alternative); |
161 | if (result == null) result = defaultCase(theEObject); |
162 | return result; |
163 | } |
164 | case ExpressionPackage.ACQUIRE: { |
165 | Acquire acquire = (Acquire)theEObject; |
166 | T result = caseAcquire(acquire); |
167 | if (result == null) result = caseTerminal(acquire); |
168 | if (result == null) result = caseExpression(acquire); |
169 | if (result == null) result = defaultCase(theEObject); |
170 | return result; |
171 | } |
172 | default: return defaultCase(theEObject); |
173 | } |
174 | } |
175 | |
176 | /** |
177 | * Returns the result of interpretting the object as an instance of '<em>Terminal</em>'. |
178 | * <!-- begin-user-doc --> |
179 | * This implementation returns null; |
180 | * returning a non-null result will terminate the switch. |
181 | * <!-- end-user-doc --> |
182 | * @param object the target of the switch. |
183 | * @return the result of interpretting the object as an instance of '<em>Terminal</em>'. |
184 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
185 | * @generated |
186 | */ |
187 | public T caseTerminal(Terminal object) { |
188 | return null; |
189 | } |
190 | |
191 | /** |
192 | * Returns the result of interpretting the object as an instance of '<em>Expression</em>'. |
193 | * <!-- begin-user-doc --> |
194 | * This implementation returns null; |
195 | * returning a non-null result will terminate the switch. |
196 | * <!-- end-user-doc --> |
197 | * @param object the target of the switch. |
198 | * @return the result of interpretting the object as an instance of '<em>Expression</em>'. |
199 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
200 | * @generated |
201 | */ |
202 | public T caseExpression(Expression object) { |
203 | return null; |
204 | } |
205 | |
206 | /** |
207 | * Returns the result of interpretting the object as an instance of '<em>Symbol</em>'. |
208 | * <!-- begin-user-doc --> |
209 | * This implementation returns null; |
210 | * returning a non-null result will terminate the switch. |
211 | * <!-- end-user-doc --> |
212 | * @param object the target of the switch. |
213 | * @return the result of interpretting the object as an instance of '<em>Symbol</em>'. |
214 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
215 | * @generated |
216 | */ |
217 | public T caseSymbol(Symbol object) { |
218 | return null; |
219 | } |
220 | |
221 | /** |
222 | * Returns the result of interpretting the object as an instance of '<em>Sequence</em>'. |
223 | * <!-- begin-user-doc --> |
224 | * This implementation returns null; |
225 | * returning a non-null result will terminate the switch. |
226 | * <!-- end-user-doc --> |
227 | * @param object the target of the switch. |
228 | * @return the result of interpretting the object as an instance of '<em>Sequence</em>'. |
229 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
230 | * @generated |
231 | */ |
232 | public T caseSequence(Sequence object) { |
233 | return null; |
234 | } |
235 | |
236 | /** |
237 | * Returns the result of interpretting the object as an instance of '<em>Operation</em>'. |
238 | * <!-- begin-user-doc --> |
239 | * This implementation returns null; |
240 | * returning a non-null result will terminate the switch. |
241 | * <!-- end-user-doc --> |
242 | * @param object the target of the switch. |
243 | * @return the result of interpretting the object as an instance of '<em>Operation</em>'. |
244 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
245 | * @generated |
246 | */ |
247 | public T caseOperation(Operation object) { |
248 | return null; |
249 | } |
250 | |
251 | /** |
252 | * Returns the result of interpretting the object as an instance of '<em>Release</em>'. |
253 | * <!-- begin-user-doc --> |
254 | * This implementation returns null; |
255 | * returning a non-null result will terminate the switch. |
256 | * <!-- end-user-doc --> |
257 | * @param object the target of the switch. |
258 | * @return the result of interpretting the object as an instance of '<em>Release</em>'. |
259 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
260 | * @generated |
261 | */ |
262 | public T caseRelease(Release object) { |
263 | return null; |
264 | } |
265 | |
266 | /** |
267 | * Returns the result of interpretting the object as an instance of '<em>Parallel</em>'. |
268 | * <!-- begin-user-doc --> |
269 | * This implementation returns null; |
270 | * returning a non-null result will terminate the switch. |
271 | * <!-- end-user-doc --> |
272 | * @param object the target of the switch. |
273 | * @return the result of interpretting the object as an instance of '<em>Parallel</em>'. |
274 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
275 | * @generated |
276 | */ |
277 | public T caseParallel(Parallel object) { |
278 | return null; |
279 | } |
280 | |
281 | /** |
282 | * Returns the result of interpretting the object as an instance of '<em>Option</em>'. |
283 | * <!-- begin-user-doc --> |
284 | * This implementation returns null; |
285 | * returning a non-null result will terminate the switch. |
286 | * <!-- end-user-doc --> |
287 | * @param object the target of the switch. |
288 | * @return the result of interpretting the object as an instance of '<em>Option</em>'. |
289 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
290 | * @generated |
291 | */ |
292 | public T caseOption(Option object) { |
293 | return null; |
294 | } |
295 | |
296 | /** |
297 | * Returns the result of interpretting the object as an instance of '<em>Loop</em>'. |
298 | * <!-- begin-user-doc --> |
299 | * This implementation returns null; |
300 | * returning a non-null result will terminate the switch. |
301 | * <!-- end-user-doc --> |
302 | * @param object the target of the switch. |
303 | * @return the result of interpretting the object as an instance of '<em>Loop</em>'. |
304 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
305 | * @generated |
306 | */ |
307 | public T caseLoop(Loop object) { |
308 | return null; |
309 | } |
310 | |
311 | /** |
312 | * Returns the result of interpretting the object as an instance of '<em>Alternative</em>'. |
313 | * <!-- begin-user-doc --> |
314 | * This implementation returns null; |
315 | * returning a non-null result will terminate the switch. |
316 | * <!-- end-user-doc --> |
317 | * @param object the target of the switch. |
318 | * @return the result of interpretting the object as an instance of '<em>Alternative</em>'. |
319 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
320 | * @generated |
321 | */ |
322 | public T caseAlternative(Alternative object) { |
323 | return null; |
324 | } |
325 | |
326 | /** |
327 | * Returns the result of interpretting the object as an instance of '<em>Acquire</em>'. |
328 | * <!-- begin-user-doc --> |
329 | * This implementation returns null; |
330 | * returning a non-null result will terminate the switch. |
331 | * <!-- end-user-doc --> |
332 | * @param object the target of the switch. |
333 | * @return the result of interpretting the object as an instance of '<em>Acquire</em>'. |
334 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
335 | * @generated |
336 | */ |
337 | public T caseAcquire(Acquire object) { |
338 | return null; |
339 | } |
340 | |
341 | /** |
342 | * Returns the result of interpretting the object as an instance of '<em>EObject</em>'. |
343 | * <!-- begin-user-doc --> |
344 | * This implementation returns null; |
345 | * returning a non-null result will terminate the switch, but this is the last case anyway. |
346 | * <!-- end-user-doc --> |
347 | * @param object the target of the switch. |
348 | * @return the result of interpretting the object as an instance of '<em>EObject</em>'. |
349 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) |
350 | * @generated |
351 | */ |
352 | public T defaultCase(EObject object) { |
353 | return null; |
354 | } |
355 | |
356 | } //ExpressionSwitch |