1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package copyException.util; |
8 | |
9 | import copyException.CopyExceptionPackage; |
10 | import copyException.DeletionException; |
11 | import copyException.Import; |
12 | import copyException.Model; |
13 | import copyException.ReferenceException; |
14 | import copyException.ReplacementException; |
15 | |
16 | import java.util.List; |
17 | |
18 | import org.eclipse.emf.ecore.EClass; |
19 | import org.eclipse.emf.ecore.EObject; |
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 copyException.CopyExceptionPackage |
32 | * @generated |
33 | */ |
34 | public class CopyExceptionSwitch<T> { |
35 | /** |
36 | * The cached model package |
37 | * <!-- begin-user-doc --> |
38 | * <!-- end-user-doc --> |
39 | * @generated |
40 | */ |
41 | protected static CopyExceptionPackage modelPackage; |
42 | |
43 | /** |
44 | * Creates an instance of the switch. |
45 | * <!-- begin-user-doc --> |
46 | * <!-- end-user-doc --> |
47 | * @generated |
48 | */ |
49 | public CopyExceptionSwitch() { |
50 | if (modelPackage == null) { |
51 | modelPackage = CopyExceptionPackage.eINSTANCE; |
52 | } |
53 | } |
54 | |
55 | /** |
56 | * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. |
57 | * <!-- begin-user-doc --> |
58 | * <!-- end-user-doc --> |
59 | * @return the first non-null result returned by a <code>caseXXX</code> call. |
60 | * @generated |
61 | */ |
62 | public T doSwitch(EObject theEObject) { |
63 | return doSwitch(theEObject.eClass(), theEObject); |
64 | } |
65 | |
66 | /** |
67 | * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. |
68 | * <!-- begin-user-doc --> |
69 | * <!-- end-user-doc --> |
70 | * @return the first non-null result returned by a <code>caseXXX</code> call. |
71 | * @generated |
72 | */ |
73 | protected T doSwitch(EClass theEClass, EObject theEObject) { |
74 | if (theEClass.eContainer() == modelPackage) { |
75 | return doSwitch(theEClass.getClassifierID(), theEObject); |
76 | } |
77 | else { |
78 | List<EClass> eSuperTypes = theEClass.getESuperTypes(); |
79 | return |
80 | eSuperTypes.isEmpty() ? |
81 | defaultCase(theEObject) : |
82 | doSwitch(eSuperTypes.get(0), theEObject); |
83 | } |
84 | } |
85 | |
86 | /** |
87 | * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. |
88 | * <!-- begin-user-doc --> |
89 | * <!-- end-user-doc --> |
90 | * @return the first non-null result returned by a <code>caseXXX</code> call. |
91 | * @generated |
92 | */ |
93 | protected T doSwitch(int classifierID, EObject theEObject) { |
94 | switch (classifierID) { |
95 | case CopyExceptionPackage.MODEL: { |
96 | Model model = (Model)theEObject; |
97 | T result = caseModel(model); |
98 | if (result == null) result = defaultCase(theEObject); |
99 | return result; |
100 | } |
101 | case CopyExceptionPackage.IMPORT: { |
102 | Import import_ = (Import)theEObject; |
103 | T result = caseImport(import_); |
104 | if (result == null) result = defaultCase(theEObject); |
105 | return result; |
106 | } |
107 | case CopyExceptionPackage.EXCEPTION: { |
108 | copyException.Exception exception = (copyException.Exception)theEObject; |
109 | T result = caseException(exception); |
110 | if (result == null) result = defaultCase(theEObject); |
111 | return result; |
112 | } |
113 | case CopyExceptionPackage.DELETION_EXCEPTION: { |
114 | DeletionException deletionException = (DeletionException)theEObject; |
115 | T result = caseDeletionException(deletionException); |
116 | if (result == null) result = caseException(deletionException); |
117 | if (result == null) result = defaultCase(theEObject); |
118 | return result; |
119 | } |
120 | case CopyExceptionPackage.REPLACEMENT_EXCEPTION: { |
121 | ReplacementException replacementException = (ReplacementException)theEObject; |
122 | T result = caseReplacementException(replacementException); |
123 | if (result == null) result = caseException(replacementException); |
124 | if (result == null) result = defaultCase(theEObject); |
125 | return result; |
126 | } |
127 | case CopyExceptionPackage.REFERENCE_EXCEPTION: { |
128 | ReferenceException referenceException = (ReferenceException)theEObject; |
129 | T result = caseReferenceException(referenceException); |
130 | if (result == null) result = caseException(referenceException); |
131 | if (result == null) result = defaultCase(theEObject); |
132 | return result; |
133 | } |
134 | default: return defaultCase(theEObject); |
135 | } |
136 | } |
137 | |
138 | /** |
139 | * Returns the result of interpreting the object as an instance of '<em>Model</em>'. |
140 | * <!-- begin-user-doc --> |
141 | * This implementation returns null; |
142 | * returning a non-null result will terminate the switch. |
143 | * <!-- end-user-doc --> |
144 | * @param object the target of the switch. |
145 | * @return the result of interpreting the object as an instance of '<em>Model</em>'. |
146 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
147 | * @generated |
148 | */ |
149 | public T caseModel(Model object) { |
150 | return null; |
151 | } |
152 | |
153 | /** |
154 | * Returns the result of interpreting the object as an instance of '<em>Import</em>'. |
155 | * <!-- begin-user-doc --> |
156 | * This implementation returns null; |
157 | * returning a non-null result will terminate the switch. |
158 | * <!-- end-user-doc --> |
159 | * @param object the target of the switch. |
160 | * @return the result of interpreting the object as an instance of '<em>Import</em>'. |
161 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
162 | * @generated |
163 | */ |
164 | public T caseImport(Import object) { |
165 | return null; |
166 | } |
167 | |
168 | /** |
169 | * Returns the result of interpreting the object as an instance of '<em>Exception</em>'. |
170 | * <!-- begin-user-doc --> |
171 | * This implementation returns null; |
172 | * returning a non-null result will terminate the switch. |
173 | * <!-- end-user-doc --> |
174 | * @param object the target of the switch. |
175 | * @return the result of interpreting the object as an instance of '<em>Exception</em>'. |
176 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
177 | * @generated |
178 | */ |
179 | public T caseException(copyException.Exception object) { |
180 | return null; |
181 | } |
182 | |
183 | /** |
184 | * Returns the result of interpreting the object as an instance of '<em>Deletion Exception</em>'. |
185 | * <!-- begin-user-doc --> |
186 | * This implementation returns null; |
187 | * returning a non-null result will terminate the switch. |
188 | * <!-- end-user-doc --> |
189 | * @param object the target of the switch. |
190 | * @return the result of interpreting the object as an instance of '<em>Deletion Exception</em>'. |
191 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
192 | * @generated |
193 | */ |
194 | public T caseDeletionException(DeletionException object) { |
195 | return null; |
196 | } |
197 | |
198 | /** |
199 | * Returns the result of interpreting the object as an instance of '<em>Replacement Exception</em>'. |
200 | * <!-- begin-user-doc --> |
201 | * This implementation returns null; |
202 | * returning a non-null result will terminate the switch. |
203 | * <!-- end-user-doc --> |
204 | * @param object the target of the switch. |
205 | * @return the result of interpreting the object as an instance of '<em>Replacement Exception</em>'. |
206 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
207 | * @generated |
208 | */ |
209 | public T caseReplacementException(ReplacementException object) { |
210 | return null; |
211 | } |
212 | |
213 | /** |
214 | * Returns the result of interpreting the object as an instance of '<em>Reference Exception</em>'. |
215 | * <!-- begin-user-doc --> |
216 | * This implementation returns null; |
217 | * returning a non-null result will terminate the switch. |
218 | * <!-- end-user-doc --> |
219 | * @param object the target of the switch. |
220 | * @return the result of interpreting the object as an instance of '<em>Reference Exception</em>'. |
221 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
222 | * @generated |
223 | */ |
224 | public T caseReferenceException(ReferenceException object) { |
225 | return null; |
226 | } |
227 | |
228 | /** |
229 | * Returns the result of interpreting the object as an instance of '<em>EObject</em>'. |
230 | * <!-- begin-user-doc --> |
231 | * This implementation returns null; |
232 | * returning a non-null result will terminate the switch, but this is the last case anyway. |
233 | * <!-- end-user-doc --> |
234 | * @param object the target of the switch. |
235 | * @return the result of interpreting the object as an instance of '<em>EObject</em>'. |
236 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) |
237 | * @generated |
238 | */ |
239 | public T defaultCase(EObject object) { |
240 | return null; |
241 | } |
242 | |
243 | } //CopyExceptionSwitch |