1 | /** |
2 | * Copyright 2006, SDQ Group, University Karlsruhe (TH) |
3 | * |
4 | * $Id$ |
5 | */ |
6 | package de.uka.ipd.sdq.context.computed_allocation.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_allocation.ComputedAllocation; |
14 | import de.uka.ipd.sdq.context.computed_allocation.ComputedAllocationContext; |
15 | import de.uka.ipd.sdq.context.computed_allocation.ComputedAllocationPackage; |
16 | import de.uka.ipd.sdq.context.computed_allocation.ResourceDemand; |
17 | import de.uka.ipd.sdq.identifier.Identifier; |
18 | import de.uka.ipd.sdq.pcm.core.entity.Entity; |
19 | import de.uka.ipd.sdq.pcm.core.entity.NamedElement; |
20 | |
21 | /** |
22 | * <!-- begin-user-doc --> |
23 | * The <b>Switch</b> for the model's inheritance hierarchy. |
24 | * It supports the call {@link #doSwitch(EObject) doSwitch(object)} |
25 | * to invoke the <code>caseXXX</code> method for each class of the model, |
26 | * starting with the actual class of the object |
27 | * and proceeding up the inheritance hierarchy |
28 | * until a non-null result is returned, |
29 | * which is the result of the switch. |
30 | * <!-- end-user-doc --> |
31 | * @see de.uka.ipd.sdq.context.computed_allocation.ComputedAllocationPackage |
32 | * @generated |
33 | */ |
34 | public class ComputedAllocationSwitch<T> { |
35 | /** |
36 | * <!-- begin-user-doc --> |
37 | * <!-- end-user-doc --> |
38 | * @generated |
39 | */ |
40 | public static final String copyright = "Copyright 2006, SDQ Group, University Karlsruhe (TH)"; |
41 | |
42 | /** |
43 | * The cached model package |
44 | * <!-- begin-user-doc --> |
45 | * <!-- end-user-doc --> |
46 | * @generated |
47 | */ |
48 | protected static ComputedAllocationPackage modelPackage; |
49 | |
50 | /** |
51 | * Creates an instance of the switch. |
52 | * <!-- begin-user-doc --> |
53 | * <!-- end-user-doc --> |
54 | * @generated |
55 | */ |
56 | public ComputedAllocationSwitch() { |
57 | if (modelPackage == null) { |
58 | modelPackage = ComputedAllocationPackage.eINSTANCE; |
59 | } |
60 | } |
61 | |
62 | /** |
63 | * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. |
64 | * <!-- begin-user-doc --> |
65 | * <!-- end-user-doc --> |
66 | * @return the first non-null result returned by a <code>caseXXX</code> call. |
67 | * @generated |
68 | */ |
69 | public T doSwitch(EObject theEObject) { |
70 | return doSwitch(theEObject.eClass(), theEObject); |
71 | } |
72 | |
73 | /** |
74 | * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. |
75 | * <!-- begin-user-doc --> |
76 | * <!-- end-user-doc --> |
77 | * @return the first non-null result returned by a <code>caseXXX</code> call. |
78 | * @generated |
79 | */ |
80 | protected T doSwitch(EClass theEClass, EObject theEObject) { |
81 | if (theEClass.eContainer() == modelPackage) { |
82 | return doSwitch(theEClass.getClassifierID(), theEObject); |
83 | } |
84 | else { |
85 | List<EClass> eSuperTypes = theEClass.getESuperTypes(); |
86 | return |
87 | eSuperTypes.isEmpty() ? |
88 | defaultCase(theEObject) : |
89 | doSwitch(eSuperTypes.get(0), theEObject); |
90 | } |
91 | } |
92 | |
93 | /** |
94 | * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. |
95 | * <!-- begin-user-doc --> |
96 | * <!-- end-user-doc --> |
97 | * @return the first non-null result returned by a <code>caseXXX</code> call. |
98 | * @generated |
99 | */ |
100 | protected T doSwitch(int classifierID, EObject theEObject) { |
101 | switch (classifierID) { |
102 | case ComputedAllocationPackage.COMPUTED_ALLOCATION_CONTEXT: { |
103 | ComputedAllocationContext computedAllocationContext = (ComputedAllocationContext)theEObject; |
104 | T result = caseComputedAllocationContext(computedAllocationContext); |
105 | if (result == null) result = caseEntity(computedAllocationContext); |
106 | if (result == null) result = caseIdentifier(computedAllocationContext); |
107 | if (result == null) result = caseNamedElement(computedAllocationContext); |
108 | if (result == null) result = defaultCase(theEObject); |
109 | return result; |
110 | } |
111 | case ComputedAllocationPackage.RESOURCE_DEMAND: { |
112 | ResourceDemand resourceDemand = (ResourceDemand)theEObject; |
113 | T result = caseResourceDemand(resourceDemand); |
114 | if (result == null) result = defaultCase(theEObject); |
115 | return result; |
116 | } |
117 | case ComputedAllocationPackage.COMPUTED_ALLOCATION: { |
118 | ComputedAllocation computedAllocation = (ComputedAllocation)theEObject; |
119 | T result = caseComputedAllocation(computedAllocation); |
120 | if (result == null) result = defaultCase(theEObject); |
121 | return result; |
122 | } |
123 | default: return defaultCase(theEObject); |
124 | } |
125 | } |
126 | |
127 | /** |
128 | * Returns the result of interpreting the object as an instance of '<em>Context</em>'. |
129 | * <!-- begin-user-doc --> |
130 | * This implementation returns null; |
131 | * returning a non-null result will terminate the switch. |
132 | * <!-- end-user-doc --> |
133 | * @param object the target of the switch. |
134 | * @return the result of interpreting the object as an instance of '<em>Context</em>'. |
135 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
136 | * @generated |
137 | */ |
138 | public T caseComputedAllocationContext(ComputedAllocationContext object) { |
139 | return null; |
140 | } |
141 | |
142 | /** |
143 | * Returns the result of interpreting the object as an instance of '<em>Resource Demand</em>'. |
144 | * <!-- begin-user-doc --> |
145 | * This implementation returns null; |
146 | * returning a non-null result will terminate the switch. |
147 | * <!-- end-user-doc --> |
148 | * @param object the target of the switch. |
149 | * @return the result of interpreting the object as an instance of '<em>Resource Demand</em>'. |
150 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
151 | * @generated |
152 | */ |
153 | public T caseResourceDemand(ResourceDemand object) { |
154 | return null; |
155 | } |
156 | |
157 | /** |
158 | * Returns the result of interpreting the object as an instance of '<em>Computed Allocation</em>'. |
159 | * <!-- begin-user-doc --> |
160 | * This implementation returns null; |
161 | * returning a non-null result will terminate the switch. |
162 | * <!-- end-user-doc --> |
163 | * @param object the target of the switch. |
164 | * @return the result of interpreting the object as an instance of '<em>Computed Allocation</em>'. |
165 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
166 | * @generated |
167 | */ |
168 | public T caseComputedAllocation(ComputedAllocation object) { |
169 | return null; |
170 | } |
171 | |
172 | /** |
173 | * Returns the result of interpreting the object as an instance of '<em>Identifier</em>'. |
174 | * <!-- begin-user-doc --> |
175 | * This implementation returns null; |
176 | * returning a non-null result will terminate the switch. |
177 | * <!-- end-user-doc --> |
178 | * @param object the target of the switch. |
179 | * @return the result of interpreting the object as an instance of '<em>Identifier</em>'. |
180 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
181 | * @generated |
182 | */ |
183 | public T caseIdentifier(Identifier object) { |
184 | return null; |
185 | } |
186 | |
187 | /** |
188 | * Returns the result of interpreting the object as an instance of '<em>Named Element</em>'. |
189 | * <!-- begin-user-doc --> |
190 | * This implementation returns null; |
191 | * returning a non-null result will terminate the switch. |
192 | * <!-- end-user-doc --> |
193 | * @param object the target of the switch. |
194 | * @return the result of interpreting the object as an instance of '<em>Named Element</em>'. |
195 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
196 | * @generated |
197 | */ |
198 | public T caseNamedElement(NamedElement object) { |
199 | return null; |
200 | } |
201 | |
202 | /** |
203 | * Returns the result of interpreting the object as an instance of '<em>Entity</em>'. |
204 | * <!-- begin-user-doc --> |
205 | * This implementation returns null; |
206 | * returning a non-null result will terminate the switch. |
207 | * <!-- end-user-doc --> |
208 | * @param object the target of the switch. |
209 | * @return the result of interpreting the object as an instance of '<em>Entity</em>'. |
210 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
211 | * @generated |
212 | */ |
213 | public T caseEntity(Entity object) { |
214 | return null; |
215 | } |
216 | |
217 | /** |
218 | * Returns the result of interpreting the object as an instance of '<em>EObject</em>'. |
219 | * <!-- begin-user-doc --> |
220 | * This implementation returns null; |
221 | * returning a non-null result will terminate the switch, but this is the last case anyway. |
222 | * <!-- end-user-doc --> |
223 | * @param object the target of the switch. |
224 | * @return the result of interpreting the object as an instance of '<em>EObject</em>'. |
225 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) |
226 | * @generated |
227 | */ |
228 | public T defaultCase(EObject object) { |
229 | return null; |
230 | } |
231 | |
232 | } //ComputedAllocationSwitch |