| 1 | /** |
| 2 | * <copyright> |
| 3 | * </copyright> |
| 4 | * |
| 5 | * $Id$ |
| 6 | */ |
| 7 | package de.uka.ipd.sdq.units.util; |
| 8 | |
| 9 | import de.uka.ipd.sdq.units.*; |
| 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.units.UnitsPackage |
| 27 | * @generated |
| 28 | */ |
| 29 | public class UnitsSwitch<T> { |
| 30 | /** |
| 31 | * <!-- begin-user-doc --> |
| 32 | * <!-- end-user-doc --> |
| 33 | * @generated |
| 34 | */ |
| 35 | public static final String copyright = "Copyright 2007-2009, SDQ, IPD, U Karlsruhe"; |
| 36 | /** |
| 37 | * The cached model package |
| 38 | * <!-- begin-user-doc --> |
| 39 | * <!-- end-user-doc --> |
| 40 | * @generated |
| 41 | */ |
| 42 | protected static UnitsPackage modelPackage; |
| 43 | |
| 44 | /** |
| 45 | * Creates an instance of the switch. |
| 46 | * <!-- begin-user-doc --> |
| 47 | * <!-- end-user-doc --> |
| 48 | * @generated |
| 49 | */ |
| 50 | public UnitsSwitch() { |
| 51 | if (modelPackage == null) { |
| 52 | modelPackage = UnitsPackage.eINSTANCE; |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. |
| 58 | * <!-- begin-user-doc --> |
| 59 | * <!-- end-user-doc --> |
| 60 | * @return the first non-null result returned by a <code>caseXXX</code> call. |
| 61 | * @generated |
| 62 | */ |
| 63 | public T doSwitch(EObject theEObject) { |
| 64 | return doSwitch(theEObject.eClass(), theEObject); |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. |
| 69 | * <!-- begin-user-doc --> |
| 70 | * <!-- end-user-doc --> |
| 71 | * @return the first non-null result returned by a <code>caseXXX</code> call. |
| 72 | * @generated |
| 73 | */ |
| 74 | protected T doSwitch(EClass theEClass, EObject theEObject) { |
| 75 | if (theEClass.eContainer() == modelPackage) { |
| 76 | return doSwitch(theEClass.getClassifierID(), theEObject); |
| 77 | } |
| 78 | else { |
| 79 | List<EClass> eSuperTypes = theEClass.getESuperTypes(); |
| 80 | return |
| 81 | eSuperTypes.isEmpty() ? |
| 82 | defaultCase(theEObject) : |
| 83 | doSwitch(eSuperTypes.get(0), theEObject); |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | /** |
| 88 | * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. |
| 89 | * <!-- begin-user-doc --> |
| 90 | * <!-- end-user-doc --> |
| 91 | * @return the first non-null result returned by a <code>caseXXX</code> call. |
| 92 | * @generated |
| 93 | */ |
| 94 | protected T doSwitch(int classifierID, EObject theEObject) { |
| 95 | switch (classifierID) { |
| 96 | case UnitsPackage.UNIT_CARRYING_ELEMENT: { |
| 97 | UnitCarryingElement unitCarryingElement = (UnitCarryingElement)theEObject; |
| 98 | T result = caseUnitCarryingElement(unitCarryingElement); |
| 99 | if (result == null) result = defaultCase(theEObject); |
| 100 | return result; |
| 101 | } |
| 102 | case UnitsPackage.UNIT: { |
| 103 | Unit unit = (Unit)theEObject; |
| 104 | T result = caseUnit(unit); |
| 105 | if (result == null) result = defaultCase(theEObject); |
| 106 | return result; |
| 107 | } |
| 108 | case UnitsPackage.BASE_UNIT: { |
| 109 | BaseUnit baseUnit = (BaseUnit)theEObject; |
| 110 | T result = caseBaseUnit(baseUnit); |
| 111 | if (result == null) result = defaultCase(theEObject); |
| 112 | return result; |
| 113 | } |
| 114 | case UnitsPackage.UNIT_REPOSITORY: { |
| 115 | UnitRepository unitRepository = (UnitRepository)theEObject; |
| 116 | T result = caseUnitRepository(unitRepository); |
| 117 | if (result == null) result = defaultCase(theEObject); |
| 118 | return result; |
| 119 | } |
| 120 | case UnitsPackage.UNIT_MULTIPLICATION: { |
| 121 | UnitMultiplication unitMultiplication = (UnitMultiplication)theEObject; |
| 122 | T result = caseUnitMultiplication(unitMultiplication); |
| 123 | if (result == null) result = caseUnit(unitMultiplication); |
| 124 | if (result == null) result = defaultCase(theEObject); |
| 125 | return result; |
| 126 | } |
| 127 | case UnitsPackage.UNIT_POWER: { |
| 128 | UnitPower unitPower = (UnitPower)theEObject; |
| 129 | T result = caseUnitPower(unitPower); |
| 130 | if (result == null) result = caseUnit(unitPower); |
| 131 | if (result == null) result = defaultCase(theEObject); |
| 132 | return result; |
| 133 | } |
| 134 | case UnitsPackage.UNIT_LITERAL: { |
| 135 | UnitLiteral unitLiteral = (UnitLiteral)theEObject; |
| 136 | T result = caseUnitLiteral(unitLiteral); |
| 137 | if (result == null) result = caseUnit(unitLiteral); |
| 138 | if (result == null) result = defaultCase(theEObject); |
| 139 | return result; |
| 140 | } |
| 141 | default: return defaultCase(theEObject); |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | /** |
| 146 | * Returns the result of interpreting the object as an instance of '<em>Unit Carrying Element</em>'. |
| 147 | * <!-- begin-user-doc --> |
| 148 | * This implementation returns null; |
| 149 | * returning a non-null result will terminate the switch. |
| 150 | * <!-- end-user-doc --> |
| 151 | * @param object the target of the switch. |
| 152 | * @return the result of interpreting the object as an instance of '<em>Unit Carrying Element</em>'. |
| 153 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| 154 | * @generated |
| 155 | */ |
| 156 | public T caseUnitCarryingElement(UnitCarryingElement object) { |
| 157 | return null; |
| 158 | } |
| 159 | |
| 160 | /** |
| 161 | * Returns the result of interpreting the object as an instance of '<em>Unit</em>'. |
| 162 | * <!-- begin-user-doc --> |
| 163 | * This implementation returns null; |
| 164 | * returning a non-null result will terminate the switch. |
| 165 | * <!-- end-user-doc --> |
| 166 | * @param object the target of the switch. |
| 167 | * @return the result of interpreting the object as an instance of '<em>Unit</em>'. |
| 168 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| 169 | * @generated |
| 170 | */ |
| 171 | public T caseUnit(Unit object) { |
| 172 | return null; |
| 173 | } |
| 174 | |
| 175 | /** |
| 176 | * Returns the result of interpreting the object as an instance of '<em>Base Unit</em>'. |
| 177 | * <!-- begin-user-doc --> |
| 178 | * This implementation returns null; |
| 179 | * returning a non-null result will terminate the switch. |
| 180 | * <!-- end-user-doc --> |
| 181 | * @param object the target of the switch. |
| 182 | * @return the result of interpreting the object as an instance of '<em>Base Unit</em>'. |
| 183 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| 184 | * @generated |
| 185 | */ |
| 186 | public T caseBaseUnit(BaseUnit object) { |
| 187 | return null; |
| 188 | } |
| 189 | |
| 190 | /** |
| 191 | * Returns the result of interpreting the object as an instance of '<em>Unit Repository</em>'. |
| 192 | * <!-- begin-user-doc --> |
| 193 | * This implementation returns null; |
| 194 | * returning a non-null result will terminate the switch. |
| 195 | * <!-- end-user-doc --> |
| 196 | * @param object the target of the switch. |
| 197 | * @return the result of interpreting the object as an instance of '<em>Unit Repository</em>'. |
| 198 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| 199 | * @generated |
| 200 | */ |
| 201 | public T caseUnitRepository(UnitRepository object) { |
| 202 | return null; |
| 203 | } |
| 204 | |
| 205 | /** |
| 206 | * Returns the result of interpreting the object as an instance of '<em>Unit Multiplication</em>'. |
| 207 | * <!-- begin-user-doc --> |
| 208 | * This implementation returns null; |
| 209 | * returning a non-null result will terminate the switch. |
| 210 | * <!-- end-user-doc --> |
| 211 | * @param object the target of the switch. |
| 212 | * @return the result of interpreting the object as an instance of '<em>Unit Multiplication</em>'. |
| 213 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| 214 | * @generated |
| 215 | */ |
| 216 | public T caseUnitMultiplication(UnitMultiplication object) { |
| 217 | return null; |
| 218 | } |
| 219 | |
| 220 | /** |
| 221 | * Returns the result of interpreting the object as an instance of '<em>Unit Power</em>'. |
| 222 | * <!-- begin-user-doc --> |
| 223 | * This implementation returns null; |
| 224 | * returning a non-null result will terminate the switch. |
| 225 | * <!-- end-user-doc --> |
| 226 | * @param object the target of the switch. |
| 227 | * @return the result of interpreting the object as an instance of '<em>Unit Power</em>'. |
| 228 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| 229 | * @generated |
| 230 | */ |
| 231 | public T caseUnitPower(UnitPower object) { |
| 232 | return null; |
| 233 | } |
| 234 | |
| 235 | /** |
| 236 | * Returns the result of interpreting the object as an instance of '<em>Unit Literal</em>'. |
| 237 | * <!-- begin-user-doc --> |
| 238 | * This implementation returns null; |
| 239 | * returning a non-null result will terminate the switch. |
| 240 | * <!-- end-user-doc --> |
| 241 | * @param object the target of the switch. |
| 242 | * @return the result of interpreting the object as an instance of '<em>Unit Literal</em>'. |
| 243 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| 244 | * @generated |
| 245 | */ |
| 246 | public T caseUnitLiteral(UnitLiteral object) { |
| 247 | return null; |
| 248 | } |
| 249 | |
| 250 | /** |
| 251 | * Returns the result of interpreting the object as an instance of '<em>EObject</em>'. |
| 252 | * <!-- begin-user-doc --> |
| 253 | * This implementation returns null; |
| 254 | * returning a non-null result will terminate the switch, but this is the last case anyway. |
| 255 | * <!-- end-user-doc --> |
| 256 | * @param object the target of the switch. |
| 257 | * @return the result of interpreting the object as an instance of '<em>EObject</em>'. |
| 258 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) |
| 259 | * @generated |
| 260 | */ |
| 261 | public T defaultCase(EObject object) { |
| 262 | return null; |
| 263 | } |
| 264 | |
| 265 | } //UnitsSwitch |