1 | /** |
2 | * Copyright 2006, SDQ Group, University Karlsruhe (TH) |
3 | * |
4 | * $Id$ |
5 | */ |
6 | package de.uka.ipd.sdq.context.computed_usage.util; |
7 | |
8 | import java.util.List; |
9 | |
10 | import org.eclipse.emf.ecore.EClass; |
11 | import org.eclipse.emf.ecore.EObject; |
12 | |
13 | import de.uka.ipd.sdq.context.computed_usage.BranchProbability; |
14 | import de.uka.ipd.sdq.context.computed_usage.ComputedUsage; |
15 | import de.uka.ipd.sdq.context.computed_usage.ComputedUsageContext; |
16 | import de.uka.ipd.sdq.context.computed_usage.ComputedUsagePackage; |
17 | import de.uka.ipd.sdq.context.computed_usage.ExternalCallInput; |
18 | import de.uka.ipd.sdq.context.computed_usage.ExternalCallOutput; |
19 | import de.uka.ipd.sdq.context.computed_usage.Input; |
20 | import de.uka.ipd.sdq.context.computed_usage.LoopIteration; |
21 | import de.uka.ipd.sdq.context.computed_usage.Output; |
22 | import de.uka.ipd.sdq.identifier.Identifier; |
23 | import de.uka.ipd.sdq.pcm.core.entity.Entity; |
24 | import de.uka.ipd.sdq.pcm.core.entity.NamedElement; |
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 de.uka.ipd.sdq.context.computed_usage.ComputedUsagePackage |
37 | * @generated |
38 | */ |
39 | public class ComputedUsageSwitch<T> { |
40 | /** |
41 | * <!-- begin-user-doc --> |
42 | * <!-- end-user-doc --> |
43 | * @generated |
44 | */ |
45 | public static final String copyright = "Copyright 2006, SDQ Group, University Karlsruhe (TH)"; |
46 | |
47 | /** |
48 | * The cached model package |
49 | * <!-- begin-user-doc --> |
50 | * <!-- end-user-doc --> |
51 | * @generated |
52 | */ |
53 | protected static ComputedUsagePackage modelPackage; |
54 | |
55 | /** |
56 | * Creates an instance of the switch. |
57 | * <!-- begin-user-doc --> |
58 | * <!-- end-user-doc --> |
59 | * @generated |
60 | */ |
61 | public ComputedUsageSwitch() { |
62 | if (modelPackage == null) { |
63 | modelPackage = ComputedUsagePackage.eINSTANCE; |
64 | } |
65 | } |
66 | |
67 | /** |
68 | * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. |
69 | * <!-- begin-user-doc --> |
70 | * <!-- end-user-doc --> |
71 | * @return the first non-null result returned by a <code>caseXXX</code> call. |
72 | * @generated |
73 | */ |
74 | public T doSwitch(EObject theEObject) { |
75 | return doSwitch(theEObject.eClass(), theEObject); |
76 | } |
77 | |
78 | /** |
79 | * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. |
80 | * <!-- begin-user-doc --> |
81 | * <!-- end-user-doc --> |
82 | * @return the first non-null result returned by a <code>caseXXX</code> call. |
83 | * @generated |
84 | */ |
85 | protected T doSwitch(EClass theEClass, EObject theEObject) { |
86 | if (theEClass.eContainer() == modelPackage) { |
87 | return doSwitch(theEClass.getClassifierID(), theEObject); |
88 | } |
89 | else { |
90 | List<EClass> eSuperTypes = theEClass.getESuperTypes(); |
91 | return |
92 | eSuperTypes.isEmpty() ? |
93 | defaultCase(theEObject) : |
94 | doSwitch(eSuperTypes.get(0), theEObject); |
95 | } |
96 | } |
97 | |
98 | /** |
99 | * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. |
100 | * <!-- begin-user-doc --> |
101 | * <!-- end-user-doc --> |
102 | * @return the first non-null result returned by a <code>caseXXX</code> call. |
103 | * @generated |
104 | */ |
105 | protected T doSwitch(int classifierID, EObject theEObject) { |
106 | switch (classifierID) { |
107 | case ComputedUsagePackage.COMPUTED_USAGE_CONTEXT: { |
108 | ComputedUsageContext computedUsageContext = (ComputedUsageContext)theEObject; |
109 | T result = caseComputedUsageContext(computedUsageContext); |
110 | if (result == null) result = caseEntity(computedUsageContext); |
111 | if (result == null) result = caseIdentifier(computedUsageContext); |
112 | if (result == null) result = caseNamedElement(computedUsageContext); |
113 | if (result == null) result = defaultCase(theEObject); |
114 | return result; |
115 | } |
116 | case ComputedUsagePackage.BRANCH_PROBABILITY: { |
117 | BranchProbability branchProbability = (BranchProbability)theEObject; |
118 | T result = caseBranchProbability(branchProbability); |
119 | if (result == null) result = defaultCase(theEObject); |
120 | return result; |
121 | } |
122 | case ComputedUsagePackage.LOOP_ITERATION: { |
123 | LoopIteration loopIteration = (LoopIteration)theEObject; |
124 | T result = caseLoopIteration(loopIteration); |
125 | if (result == null) result = defaultCase(theEObject); |
126 | return result; |
127 | } |
128 | case ComputedUsagePackage.INPUT: { |
129 | Input input = (Input)theEObject; |
130 | T result = caseInput(input); |
131 | if (result == null) result = defaultCase(theEObject); |
132 | return result; |
133 | } |
134 | case ComputedUsagePackage.EXTERNAL_CALL_OUTPUT: { |
135 | ExternalCallOutput externalCallOutput = (ExternalCallOutput)theEObject; |
136 | T result = caseExternalCallOutput(externalCallOutput); |
137 | if (result == null) result = defaultCase(theEObject); |
138 | return result; |
139 | } |
140 | case ComputedUsagePackage.EXTERNAL_CALL_INPUT: { |
141 | ExternalCallInput externalCallInput = (ExternalCallInput)theEObject; |
142 | T result = caseExternalCallInput(externalCallInput); |
143 | if (result == null) result = defaultCase(theEObject); |
144 | return result; |
145 | } |
146 | case ComputedUsagePackage.OUTPUT: { |
147 | Output output = (Output)theEObject; |
148 | T result = caseOutput(output); |
149 | if (result == null) result = defaultCase(theEObject); |
150 | return result; |
151 | } |
152 | case ComputedUsagePackage.COMPUTED_USAGE: { |
153 | ComputedUsage computedUsage = (ComputedUsage)theEObject; |
154 | T result = caseComputedUsage(computedUsage); |
155 | if (result == null) result = defaultCase(theEObject); |
156 | return result; |
157 | } |
158 | default: return defaultCase(theEObject); |
159 | } |
160 | } |
161 | |
162 | /** |
163 | * Returns the result of interpreting the object as an instance of '<em>Context</em>'. |
164 | * <!-- begin-user-doc --> |
165 | * This implementation returns null; |
166 | * returning a non-null result will terminate the switch. |
167 | * <!-- end-user-doc --> |
168 | * @param object the target of the switch. |
169 | * @return the result of interpreting the object as an instance of '<em>Context</em>'. |
170 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
171 | * @generated |
172 | */ |
173 | public T caseComputedUsageContext(ComputedUsageContext object) { |
174 | return null; |
175 | } |
176 | |
177 | /** |
178 | * Returns the result of interpreting the object as an instance of '<em>Branch Probability</em>'. |
179 | * <!-- begin-user-doc --> |
180 | * This implementation returns null; |
181 | * returning a non-null result will terminate the switch. |
182 | * <!-- end-user-doc --> |
183 | * @param object the target of the switch. |
184 | * @return the result of interpreting the object as an instance of '<em>Branch Probability</em>'. |
185 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
186 | * @generated |
187 | */ |
188 | public T caseBranchProbability(BranchProbability object) { |
189 | return null; |
190 | } |
191 | |
192 | /** |
193 | * Returns the result of interpreting the object as an instance of '<em>Loop Iteration</em>'. |
194 | * <!-- begin-user-doc --> |
195 | * This implementation returns null; |
196 | * returning a non-null result will terminate the switch. |
197 | * <!-- end-user-doc --> |
198 | * @param object the target of the switch. |
199 | * @return the result of interpreting the object as an instance of '<em>Loop Iteration</em>'. |
200 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
201 | * @generated |
202 | */ |
203 | public T caseLoopIteration(LoopIteration object) { |
204 | return null; |
205 | } |
206 | |
207 | /** |
208 | * Returns the result of interpreting the object as an instance of '<em>Input</em>'. |
209 | * <!-- begin-user-doc --> |
210 | * This implementation returns null; |
211 | * returning a non-null result will terminate the switch. |
212 | * <!-- end-user-doc --> |
213 | * @param object the target of the switch. |
214 | * @return the result of interpreting the object as an instance of '<em>Input</em>'. |
215 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
216 | * @generated |
217 | */ |
218 | public T caseInput(Input object) { |
219 | return null; |
220 | } |
221 | |
222 | /** |
223 | * Returns the result of interpreting the object as an instance of '<em>External Call Output</em>'. |
224 | * <!-- begin-user-doc --> |
225 | * This implementation returns null; |
226 | * returning a non-null result will terminate the switch. |
227 | * <!-- end-user-doc --> |
228 | * @param object the target of the switch. |
229 | * @return the result of interpreting the object as an instance of '<em>External Call Output</em>'. |
230 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
231 | * @generated |
232 | */ |
233 | public T caseExternalCallOutput(ExternalCallOutput object) { |
234 | return null; |
235 | } |
236 | |
237 | /** |
238 | * Returns the result of interpreting the object as an instance of '<em>External Call Input</em>'. |
239 | * <!-- begin-user-doc --> |
240 | * This implementation returns null; |
241 | * returning a non-null result will terminate the switch. |
242 | * <!-- end-user-doc --> |
243 | * @param object the target of the switch. |
244 | * @return the result of interpreting the object as an instance of '<em>External Call Input</em>'. |
245 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
246 | * @generated |
247 | */ |
248 | public T caseExternalCallInput(ExternalCallInput object) { |
249 | return null; |
250 | } |
251 | |
252 | /** |
253 | * Returns the result of interpreting the object as an instance of '<em>Output</em>'. |
254 | * <!-- begin-user-doc --> |
255 | * This implementation returns null; |
256 | * returning a non-null result will terminate the switch. |
257 | * <!-- end-user-doc --> |
258 | * @param object the target of the switch. |
259 | * @return the result of interpreting the object as an instance of '<em>Output</em>'. |
260 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
261 | * @generated |
262 | */ |
263 | public T caseOutput(Output object) { |
264 | return null; |
265 | } |
266 | |
267 | /** |
268 | * Returns the result of interpreting the object as an instance of '<em>Computed Usage</em>'. |
269 | * <!-- begin-user-doc --> |
270 | * This implementation returns null; |
271 | * returning a non-null result will terminate the switch. |
272 | * <!-- end-user-doc --> |
273 | * @param object the target of the switch. |
274 | * @return the result of interpreting the object as an instance of '<em>Computed Usage</em>'. |
275 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
276 | * @generated |
277 | */ |
278 | public T caseComputedUsage(ComputedUsage object) { |
279 | return null; |
280 | } |
281 | |
282 | /** |
283 | * Returns the result of interpreting the object as an instance of '<em>Identifier</em>'. |
284 | * <!-- begin-user-doc --> |
285 | * This implementation returns null; |
286 | * returning a non-null result will terminate the switch. |
287 | * <!-- end-user-doc --> |
288 | * @param object the target of the switch. |
289 | * @return the result of interpreting the object as an instance of '<em>Identifier</em>'. |
290 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
291 | * @generated |
292 | */ |
293 | public T caseIdentifier(Identifier object) { |
294 | return null; |
295 | } |
296 | |
297 | /** |
298 | * Returns the result of interpreting the object as an instance of '<em>Named Element</em>'. |
299 | * <!-- begin-user-doc --> |
300 | * This implementation returns null; |
301 | * returning a non-null result will terminate the switch. |
302 | * <!-- end-user-doc --> |
303 | * @param object the target of the switch. |
304 | * @return the result of interpreting the object as an instance of '<em>Named Element</em>'. |
305 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
306 | * @generated |
307 | */ |
308 | public T caseNamedElement(NamedElement object) { |
309 | return null; |
310 | } |
311 | |
312 | /** |
313 | * Returns the result of interpreting the object as an instance of '<em>Entity</em>'. |
314 | * <!-- begin-user-doc --> |
315 | * This implementation returns null; |
316 | * returning a non-null result will terminate the switch. |
317 | * <!-- end-user-doc --> |
318 | * @param object the target of the switch. |
319 | * @return the result of interpreting the object as an instance of '<em>Entity</em>'. |
320 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
321 | * @generated |
322 | */ |
323 | public T caseEntity(Entity object) { |
324 | return null; |
325 | } |
326 | |
327 | /** |
328 | * Returns the result of interpreting the object as an instance of '<em>EObject</em>'. |
329 | * <!-- begin-user-doc --> |
330 | * This implementation returns null; |
331 | * returning a non-null result will terminate the switch, but this is the last case anyway. |
332 | * <!-- end-user-doc --> |
333 | * @param object the target of the switch. |
334 | * @return the result of interpreting the object as an instance of '<em>EObject</em>'. |
335 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) |
336 | * @generated |
337 | */ |
338 | public T defaultCase(EObject object) { |
339 | return null; |
340 | } |
341 | |
342 | } //ComputedUsageSwitch |