001    /**
002     * <copyright>
003     * </copyright>
004     *
005     * $Id$
006     */
007    package com.hammurapi.flow.util;
008    
009    import com.hammurapi.config.Factory;
010    import com.hammurapi.config.Named;
011    import com.hammurapi.config.NamedObjectDefinition;
012    import com.hammurapi.config.ObjectDefinition;
013    import com.hammurapi.config.PropertySource;
014    
015    import com.hammurapi.flow.*;
016    
017    import com.hammurapi.party.CommonObject;
018    import java.util.List;
019    
020    import org.eclipse.emf.ecore.EClass;
021    import org.eclipse.emf.ecore.EObject;
022    
023    /**
024     * <!-- begin-user-doc -->
025     * The <b>Switch</b> for the model's inheritance hierarchy.
026     * It supports the call {@link #doSwitch(EObject) doSwitch(object)}
027     * to invoke the <code>caseXXX</code> method for each class of the model,
028     * starting with the actual class of the object
029     * and proceeding up the inheritance hierarchy
030     * until a non-null result is returned,
031     * which is the result of the switch.
032     * <!-- end-user-doc -->
033     * @see com.hammurapi.flow.FlowPackage
034     * @generated
035     */
036    public class FlowSwitch<T> {
037            /**
038             * The cached model package
039             * <!-- begin-user-doc -->
040             * <!-- end-user-doc -->
041             * @generated
042             */
043            protected static FlowPackage modelPackage;
044    
045            /**
046             * Creates an instance of the switch.
047             * <!-- begin-user-doc -->
048             * <!-- end-user-doc -->
049             * @generated
050             */
051            public FlowSwitch() {
052                    if (modelPackage == null) {
053                            modelPackage = FlowPackage.eINSTANCE;
054                    }
055            }
056    
057            /**
058             * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
059             * <!-- begin-user-doc -->
060             * <!-- end-user-doc -->
061             * @return the first non-null result returned by a <code>caseXXX</code> call.
062             * @generated
063             */
064            public T doSwitch(EObject theEObject) {
065                    return doSwitch(theEObject.eClass(), theEObject);
066            }
067    
068            /**
069             * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
070             * <!-- begin-user-doc -->
071             * <!-- end-user-doc -->
072             * @return the first non-null result returned by a <code>caseXXX</code> call.
073             * @generated
074             */
075            protected T doSwitch(EClass theEClass, EObject theEObject) {
076                    if (theEClass.eContainer() == modelPackage) {
077                            return doSwitch(theEClass.getClassifierID(), theEObject);
078                    }
079                    else {
080                            List<EClass> eSuperTypes = theEClass.getESuperTypes();
081                            return
082                                    eSuperTypes.isEmpty() ?
083                                            defaultCase(theEObject) :
084                                            doSwitch(eSuperTypes.get(0), theEObject);
085                    }
086            }
087    
088            /**
089             * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
090             * <!-- begin-user-doc -->
091             * <!-- end-user-doc -->
092             * @return the first non-null result returned by a <code>caseXXX</code> call.
093             * @generated
094             */
095            protected T doSwitch(int classifierID, EObject theEObject) {
096                    switch (classifierID) {
097                            case FlowPackage.FLOW_ELEMENT: {
098                                    FlowElement flowElement = (FlowElement)theEObject;
099                                    T result = caseFlowElement(flowElement);
100                                    if (result == null) result = caseNamedObjectDefinition(flowElement);
101                                    if (result == null) result = caseNamed(flowElement);
102                                    if (result == null) result = caseObjectDefinition(flowElement);
103                                    if (result == null) result = caseFactory(flowElement);
104                                    if (result == null) result = casePropertySource(flowElement);
105                                    if (result == null) result = caseCommonObject(flowElement);
106                                    if (result == null) result = defaultCase(theEObject);
107                                    return result;
108                            }
109                            case FlowPackage.NODE: {
110                                    Node node = (Node)theEObject;
111                                    T result = caseNode(node);
112                                    if (result == null) result = caseFlowElement(node);
113                                    if (result == null) result = caseNamedObjectDefinition(node);
114                                    if (result == null) result = caseNamed(node);
115                                    if (result == null) result = caseObjectDefinition(node);
116                                    if (result == null) result = caseFactory(node);
117                                    if (result == null) result = casePropertySource(node);
118                                    if (result == null) result = caseCommonObject(node);
119                                    if (result == null) result = defaultCase(theEObject);
120                                    return result;
121                            }
122                            case FlowPackage.FLOW: {
123                                    Flow flow = (Flow)theEObject;
124                                    T result = caseFlow(flow);
125                                    if (result == null) result = caseNode(flow);
126                                    if (result == null) result = caseFlowElement(flow);
127                                    if (result == null) result = caseNamedObjectDefinition(flow);
128                                    if (result == null) result = caseNamed(flow);
129                                    if (result == null) result = caseObjectDefinition(flow);
130                                    if (result == null) result = caseFactory(flow);
131                                    if (result == null) result = casePropertySource(flow);
132                                    if (result == null) result = caseCommonObject(flow);
133                                    if (result == null) result = defaultCase(theEObject);
134                                    return result;
135                            }
136                            case FlowPackage.PIN: {
137                                    Pin pin = (Pin)theEObject;
138                                    T result = casePin(pin);
139                                    if (result == null) result = defaultCase(theEObject);
140                                    return result;
141                            }
142                            case FlowPackage.TRANSITION: {
143                                    Transition transition = (Transition)theEObject;
144                                    T result = caseTransition(transition);
145                                    if (result == null) result = caseFlowElement(transition);
146                                    if (result == null) result = caseNamedObjectDefinition(transition);
147                                    if (result == null) result = caseNamed(transition);
148                                    if (result == null) result = caseObjectDefinition(transition);
149                                    if (result == null) result = caseFactory(transition);
150                                    if (result == null) result = casePropertySource(transition);
151                                    if (result == null) result = caseCommonObject(transition);
152                                    if (result == null) result = defaultCase(theEObject);
153                                    return result;
154                            }
155                            default: return defaultCase(theEObject);
156                    }
157            }
158    
159            /**
160             * Returns the result of interpreting the object as an instance of '<em>Element</em>'.
161             * <!-- begin-user-doc -->
162             * This implementation returns null;
163             * returning a non-null result will terminate the switch.
164             * <!-- end-user-doc -->
165             * @param object the target of the switch.
166             * @return the result of interpreting the object as an instance of '<em>Element</em>'.
167             * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
168             * @generated
169             */
170            public T caseFlowElement(FlowElement object) {
171                    return null;
172            }
173    
174            /**
175             * Returns the result of interpreting the object as an instance of '<em>Node</em>'.
176             * <!-- begin-user-doc -->
177             * This implementation returns null;
178             * returning a non-null result will terminate the switch.
179             * <!-- end-user-doc -->
180             * @param object the target of the switch.
181             * @return the result of interpreting the object as an instance of '<em>Node</em>'.
182             * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
183             * @generated
184             */
185            public T caseNode(Node object) {
186                    return null;
187            }
188    
189            /**
190             * Returns the result of interpreting the object as an instance of '<em>Flow</em>'.
191             * <!-- begin-user-doc -->
192             * This implementation returns null;
193             * returning a non-null result will terminate the switch.
194             * <!-- end-user-doc -->
195             * @param object the target of the switch.
196             * @return the result of interpreting the object as an instance of '<em>Flow</em>'.
197             * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
198             * @generated
199             */
200            public T caseFlow(Flow object) {
201                    return null;
202            }
203    
204            /**
205             * Returns the result of interpreting the object as an instance of '<em>Pin</em>'.
206             * <!-- begin-user-doc -->
207             * This implementation returns null;
208             * returning a non-null result will terminate the switch.
209             * <!-- end-user-doc -->
210             * @param object the target of the switch.
211             * @return the result of interpreting the object as an instance of '<em>Pin</em>'.
212             * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
213             * @generated
214             */
215            public T casePin(Pin object) {
216                    return null;
217            }
218    
219            /**
220             * Returns the result of interpreting the object as an instance of '<em>Transition</em>'.
221             * <!-- begin-user-doc -->
222             * This implementation returns null;
223             * returning a non-null result will terminate the switch.
224             * <!-- end-user-doc -->
225             * @param object the target of the switch.
226             * @return the result of interpreting the object as an instance of '<em>Transition</em>'.
227             * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
228             * @generated
229             */
230            public T caseTransition(Transition object) {
231                    return null;
232            }
233    
234            /**
235             * Returns the result of interpreting the object as an instance of '<em>Common Object</em>'.
236             * <!-- begin-user-doc -->
237             * This implementation returns null;
238             * returning a non-null result will terminate the switch.
239             * <!-- end-user-doc -->
240             * @param object the target of the switch.
241             * @return the result of interpreting the object as an instance of '<em>Common Object</em>'.
242             * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
243             * @generated
244             */
245            public T caseCommonObject(CommonObject object) {
246                    return null;
247            }
248    
249            /**
250             * Returns the result of interpreting the object as an instance of '<em>Factory</em>'.
251             * <!-- begin-user-doc -->
252             * This implementation returns null;
253             * returning a non-null result will terminate the switch.
254             * <!-- end-user-doc -->
255             * @param object the target of the switch.
256             * @return the result of interpreting the object as an instance of '<em>Factory</em>'.
257             * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
258             * @generated
259             */
260            public T caseFactory(Factory object) {
261                    return null;
262            }
263    
264            /**
265             * Returns the result of interpreting the object as an instance of '<em>Named</em>'.
266             * <!-- begin-user-doc -->
267             * This implementation returns null;
268             * returning a non-null result will terminate the switch.
269             * <!-- end-user-doc -->
270             * @param object the target of the switch.
271             * @return the result of interpreting the object as an instance of '<em>Named</em>'.
272             * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
273             * @generated
274             */
275            public T caseNamed(Named object) {
276                    return null;
277            }
278    
279            /**
280             * Returns the result of interpreting the object as an instance of '<em>Property Source</em>'.
281             * <!-- begin-user-doc -->
282             * This implementation returns null;
283             * returning a non-null result will terminate the switch.
284             * <!-- end-user-doc -->
285             * @param object the target of the switch.
286             * @return the result of interpreting the object as an instance of '<em>Property Source</em>'.
287             * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
288             * @generated
289             */
290            public T casePropertySource(PropertySource object) {
291                    return null;
292            }
293    
294            /**
295             * Returns the result of interpreting the object as an instance of '<em>Object Definition</em>'.
296             * <!-- begin-user-doc -->
297             * This implementation returns null;
298             * returning a non-null result will terminate the switch.
299             * <!-- end-user-doc -->
300             * @param object the target of the switch.
301             * @return the result of interpreting the object as an instance of '<em>Object Definition</em>'.
302             * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
303             * @generated
304             */
305            public T caseObjectDefinition(ObjectDefinition object) {
306                    return null;
307            }
308    
309            /**
310             * Returns the result of interpreting the object as an instance of '<em>Named Object Definition</em>'.
311             * <!-- begin-user-doc -->
312             * This implementation returns null;
313             * returning a non-null result will terminate the switch.
314             * <!-- end-user-doc -->
315             * @param object the target of the switch.
316             * @return the result of interpreting the object as an instance of '<em>Named Object Definition</em>'.
317             * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
318             * @generated
319             */
320            public T caseNamedObjectDefinition(NamedObjectDefinition object) {
321                    return null;
322            }
323    
324            /**
325             * Returns the result of interpreting the object as an instance of '<em>EObject</em>'.
326             * <!-- begin-user-doc -->
327             * This implementation returns null;
328             * returning a non-null result will terminate the switch, but this is the last case anyway.
329             * <!-- end-user-doc -->
330             * @param object the target of the switch.
331             * @return the result of interpreting the object as an instance of '<em>EObject</em>'.
332             * @see #doSwitch(org.eclipse.emf.ecore.EObject)
333             * @generated
334             */
335            public T defaultCase(EObject object) {
336                    return null;
337            }
338    
339    } //FlowSwitch