1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package de.uka.ipd.sdq.markov.util; |
8 | |
9 | import de.uka.ipd.sdq.markov.*; |
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.markov.MarkovPackage |
27 | * @generated |
28 | */ |
29 | public class MarkovSwitch<T> { |
30 | /** |
31 | * The cached model package |
32 | * <!-- begin-user-doc --> |
33 | * <!-- end-user-doc --> |
34 | * @generated |
35 | */ |
36 | protected static MarkovPackage modelPackage; |
37 | |
38 | /** |
39 | * Creates an instance of the switch. |
40 | * <!-- begin-user-doc --> |
41 | * <!-- end-user-doc --> |
42 | * @generated |
43 | */ |
44 | public MarkovSwitch() { |
45 | if (modelPackage == null) { |
46 | modelPackage = MarkovPackage.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 MarkovPackage.STATE: { |
91 | State state = (State)theEObject; |
92 | T result = caseState(state); |
93 | if (result == null) result = caseEntity(state); |
94 | if (result == null) result = defaultCase(theEObject); |
95 | return result; |
96 | } |
97 | case MarkovPackage.TRANSITION: { |
98 | Transition transition = (Transition)theEObject; |
99 | T result = caseTransition(transition); |
100 | if (result == null) result = caseEntity(transition); |
101 | if (result == null) result = defaultCase(theEObject); |
102 | return result; |
103 | } |
104 | case MarkovPackage.MARKOV_CHAIN: { |
105 | MarkovChain markovChain = (MarkovChain)theEObject; |
106 | T result = caseMarkovChain(markovChain); |
107 | if (result == null) result = caseEntity(markovChain); |
108 | if (result == null) result = defaultCase(theEObject); |
109 | return result; |
110 | } |
111 | case MarkovPackage.ENTITY: { |
112 | Entity entity = (Entity)theEObject; |
113 | T result = caseEntity(entity); |
114 | if (result == null) result = defaultCase(theEObject); |
115 | return result; |
116 | } |
117 | case MarkovPackage.LABEL: { |
118 | Label label = (Label)theEObject; |
119 | T result = caseLabel(label); |
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>State</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>State</em>'. |
135 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
136 | * @generated |
137 | */ |
138 | public T caseState(State object) { |
139 | return null; |
140 | } |
141 | |
142 | /** |
143 | * Returns the result of interpreting the object as an instance of '<em>Transition</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>Transition</em>'. |
150 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
151 | * @generated |
152 | */ |
153 | public T caseTransition(Transition object) { |
154 | return null; |
155 | } |
156 | |
157 | /** |
158 | * Returns the result of interpreting the object as an instance of '<em>Chain</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>Chain</em>'. |
165 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
166 | * @generated |
167 | */ |
168 | public T caseMarkovChain(MarkovChain object) { |
169 | return null; |
170 | } |
171 | |
172 | /** |
173 | * Returns the result of interpreting the object as an instance of '<em>Entity</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>Entity</em>'. |
180 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
181 | * @generated |
182 | */ |
183 | public T caseEntity(Entity object) { |
184 | return null; |
185 | } |
186 | |
187 | /** |
188 | * Returns the result of interpreting the object as an instance of '<em>Label</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>Label</em>'. |
195 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
196 | * @generated |
197 | */ |
198 | public T caseLabel(Label object) { |
199 | return null; |
200 | } |
201 | |
202 | /** |
203 | * Returns the result of interpreting the object as an instance of '<em>EObject</em>'. |
204 | * <!-- begin-user-doc --> |
205 | * This implementation returns null; |
206 | * returning a non-null result will terminate the switch, but this is the last case anyway. |
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>EObject</em>'. |
210 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) |
211 | * @generated |
212 | */ |
213 | public T defaultCase(EObject object) { |
214 | return null; |
215 | } |
216 | |
217 | } //MarkovSwitch |