| 1 | /** |
| 2 | * <copyright> |
| 3 | * </copyright> |
| 4 | * |
| 5 | * $Id$ |
| 6 | */ |
| 7 | package de.uka.ipd.sdq.spa.util; |
| 8 | |
| 9 | import de.uka.ipd.sdq.spa.*; |
| 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.spa.SpaPackage |
| 27 | * @generated |
| 28 | */ |
| 29 | public class SpaSwitch<T> { |
| 30 | /** |
| 31 | * The cached model package |
| 32 | * <!-- begin-user-doc --> |
| 33 | * <!-- end-user-doc --> |
| 34 | * @generated |
| 35 | */ |
| 36 | protected static SpaPackage modelPackage; |
| 37 | |
| 38 | /** |
| 39 | * Creates an instance of the switch. |
| 40 | * <!-- begin-user-doc --> |
| 41 | * <!-- end-user-doc --> |
| 42 | * @generated |
| 43 | */ |
| 44 | public SpaSwitch() { |
| 45 | if (modelPackage == null) { |
| 46 | modelPackage = SpaPackage.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 SpaPackage.PROCESS_BEHAVIOUR: { |
| 91 | ProcessBehaviour processBehaviour = (ProcessBehaviour)theEObject; |
| 92 | T result = caseProcessBehaviour(processBehaviour); |
| 93 | if (result == null) result = defaultCase(theEObject); |
| 94 | return result; |
| 95 | } |
| 96 | case SpaPackage.SPA_MODEL: { |
| 97 | SPAModel spaModel = (SPAModel)theEObject; |
| 98 | T result = caseSPAModel(spaModel); |
| 99 | if (result == null) result = defaultCase(theEObject); |
| 100 | return result; |
| 101 | } |
| 102 | default: return defaultCase(theEObject); |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | /** |
| 107 | * Returns the result of interpretting the object as an instance of '<em>Process Behaviour</em>'. |
| 108 | * <!-- begin-user-doc --> |
| 109 | * This implementation returns null; |
| 110 | * returning a non-null result will terminate the switch. |
| 111 | * <!-- end-user-doc --> |
| 112 | * @param object the target of the switch. |
| 113 | * @return the result of interpretting the object as an instance of '<em>Process Behaviour</em>'. |
| 114 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| 115 | * @generated |
| 116 | */ |
| 117 | public T caseProcessBehaviour(ProcessBehaviour object) { |
| 118 | return null; |
| 119 | } |
| 120 | |
| 121 | /** |
| 122 | * Returns the result of interpretting the object as an instance of '<em>SPA Model</em>'. |
| 123 | * <!-- begin-user-doc --> |
| 124 | * This implementation returns null; |
| 125 | * returning a non-null result will terminate the switch. |
| 126 | * <!-- end-user-doc --> |
| 127 | * @param object the target of the switch. |
| 128 | * @return the result of interpretting the object as an instance of '<em>SPA Model</em>'. |
| 129 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| 130 | * @generated |
| 131 | */ |
| 132 | public T caseSPAModel(SPAModel object) { |
| 133 | return null; |
| 134 | } |
| 135 | |
| 136 | /** |
| 137 | * Returns the result of interpretting the object as an instance of '<em>EObject</em>'. |
| 138 | * <!-- begin-user-doc --> |
| 139 | * This implementation returns null; |
| 140 | * returning a non-null result will terminate the switch, but this is the last case anyway. |
| 141 | * <!-- end-user-doc --> |
| 142 | * @param object the target of the switch. |
| 143 | * @return the result of interpretting the object as an instance of '<em>EObject</em>'. |
| 144 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) |
| 145 | * @generated |
| 146 | */ |
| 147 | public T defaultCase(EObject object) { |
| 148 | return null; |
| 149 | } |
| 150 | |
| 151 | } //SpaSwitch |