| 1 | /** |
| 2 | * Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany |
| 3 | * |
| 4 | * $Id$ |
| 5 | */ |
| 6 | package de.uka.ipd.sdq.pcm.parameter.util; |
| 7 | |
| 8 | import de.uka.ipd.sdq.pcm.parameter.*; |
| 9 | import java.util.List; |
| 10 | |
| 11 | import org.eclipse.emf.ecore.EClass; |
| 12 | import org.eclipse.emf.ecore.EObject; |
| 13 | |
| 14 | import de.uka.ipd.sdq.pcm.parameter.CharacterisedVariable; |
| 15 | import de.uka.ipd.sdq.pcm.parameter.ParameterPackage; |
| 16 | import de.uka.ipd.sdq.pcm.parameter.VariableCharacterisation; |
| 17 | import de.uka.ipd.sdq.pcm.parameter.VariableUsage; |
| 18 | import de.uka.ipd.sdq.stoex.Atom; |
| 19 | import de.uka.ipd.sdq.stoex.BooleanExpression; |
| 20 | import de.uka.ipd.sdq.stoex.Comparison; |
| 21 | import de.uka.ipd.sdq.stoex.Expression; |
| 22 | import de.uka.ipd.sdq.stoex.IfElse; |
| 23 | import de.uka.ipd.sdq.stoex.Power; |
| 24 | import de.uka.ipd.sdq.stoex.Product; |
| 25 | import de.uka.ipd.sdq.stoex.Term; |
| 26 | import de.uka.ipd.sdq.stoex.Unary; |
| 27 | import de.uka.ipd.sdq.stoex.Variable; |
| 28 | |
| 29 | /** |
| 30 | * <!-- begin-user-doc --> |
| 31 | * The <b>Switch</b> for the model's inheritance hierarchy. |
| 32 | * It supports the call {@link #doSwitch(EObject) doSwitch(object)} |
| 33 | * to invoke the <code>caseXXX</code> method for each class of the model, |
| 34 | * starting with the actual class of the object |
| 35 | * and proceeding up the inheritance hierarchy |
| 36 | * until a non-null result is returned, |
| 37 | * which is the result of the switch. |
| 38 | * <!-- end-user-doc --> |
| 39 | * @see de.uka.ipd.sdq.pcm.parameter.ParameterPackage |
| 40 | * @generated |
| 41 | */ |
| 42 | public class ParameterSwitch<T> { |
| 43 | /** |
| 44 | * <!-- begin-user-doc --> |
| 45 | * <!-- end-user-doc --> |
| 46 | * @generated |
| 47 | */ |
| 48 | public static final String copyright = "Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany"; |
| 49 | |
| 50 | /** |
| 51 | * The cached model package |
| 52 | * <!-- begin-user-doc --> |
| 53 | * <!-- end-user-doc --> |
| 54 | * @generated |
| 55 | */ |
| 56 | protected static ParameterPackage modelPackage; |
| 57 | |
| 58 | /** |
| 59 | * Creates an instance of the switch. |
| 60 | * <!-- begin-user-doc --> |
| 61 | * <!-- end-user-doc --> |
| 62 | * @generated |
| 63 | */ |
| 64 | public ParameterSwitch() { |
| 65 | if (modelPackage == null) { |
| 66 | modelPackage = ParameterPackage.eINSTANCE; |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. |
| 72 | * <!-- begin-user-doc --> |
| 73 | * <!-- end-user-doc --> |
| 74 | * @return the first non-null result returned by a <code>caseXXX</code> call. |
| 75 | * @generated |
| 76 | */ |
| 77 | public T doSwitch(EObject theEObject) { |
| 78 | return doSwitch(theEObject.eClass(), theEObject); |
| 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(EClass theEClass, EObject theEObject) { |
| 89 | if (theEClass.eContainer() == modelPackage) { |
| 90 | return doSwitch(theEClass.getClassifierID(), theEObject); |
| 91 | } |
| 92 | else { |
| 93 | List<EClass> eSuperTypes = theEClass.getESuperTypes(); |
| 94 | return |
| 95 | eSuperTypes.isEmpty() ? |
| 96 | defaultCase(theEObject) : |
| 97 | doSwitch(eSuperTypes.get(0), theEObject); |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. |
| 103 | * <!-- begin-user-doc --> |
| 104 | * <!-- end-user-doc --> |
| 105 | * @return the first non-null result returned by a <code>caseXXX</code> call. |
| 106 | * @generated |
| 107 | */ |
| 108 | protected T doSwitch(int classifierID, EObject theEObject) { |
| 109 | switch (classifierID) { |
| 110 | case ParameterPackage.VARIABLE_USAGE: { |
| 111 | VariableUsage variableUsage = (VariableUsage)theEObject; |
| 112 | T result = caseVariableUsage(variableUsage); |
| 113 | if (result == null) result = defaultCase(theEObject); |
| 114 | return result; |
| 115 | } |
| 116 | case ParameterPackage.VARIABLE_CHARACTERISATION: { |
| 117 | VariableCharacterisation variableCharacterisation = (VariableCharacterisation)theEObject; |
| 118 | T result = caseVariableCharacterisation(variableCharacterisation); |
| 119 | if (result == null) result = defaultCase(theEObject); |
| 120 | return result; |
| 121 | } |
| 122 | case ParameterPackage.CHARACTERISED_VARIABLE: { |
| 123 | CharacterisedVariable characterisedVariable = (CharacterisedVariable)theEObject; |
| 124 | T result = caseCharacterisedVariable(characterisedVariable); |
| 125 | if (result == null) result = caseVariable(characterisedVariable); |
| 126 | if (result == null) result = caseAtom(characterisedVariable); |
| 127 | if (result == null) result = caseUnary(characterisedVariable); |
| 128 | if (result == null) result = casePower(characterisedVariable); |
| 129 | if (result == null) result = caseProduct(characterisedVariable); |
| 130 | if (result == null) result = caseTerm(characterisedVariable); |
| 131 | if (result == null) result = caseComparison(characterisedVariable); |
| 132 | if (result == null) result = caseBooleanExpression(characterisedVariable); |
| 133 | if (result == null) result = caseIfElse(characterisedVariable); |
| 134 | if (result == null) result = caseExpression(characterisedVariable); |
| 135 | if (result == null) result = defaultCase(theEObject); |
| 136 | return result; |
| 137 | } |
| 138 | default: return defaultCase(theEObject); |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | /** |
| 143 | * Returns the result of interpreting the object as an instance of '<em>Variable Characterisation</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>Variable Characterisation</em>'. |
| 150 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| 151 | * @generated |
| 152 | */ |
| 153 | public T caseVariableCharacterisation(VariableCharacterisation object) { |
| 154 | return null; |
| 155 | } |
| 156 | |
| 157 | /** |
| 158 | * Returns the result of interpreting the object as an instance of '<em>Characterised Variable</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>Characterised Variable</em>'. |
| 165 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| 166 | * @generated |
| 167 | */ |
| 168 | public T caseCharacterisedVariable(CharacterisedVariable object) { |
| 169 | return null; |
| 170 | } |
| 171 | |
| 172 | /** |
| 173 | * Returns the result of interpreting the object as an instance of '<em>Variable Usage</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>Variable Usage</em>'. |
| 180 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| 181 | * @generated |
| 182 | */ |
| 183 | public T caseVariableUsage(VariableUsage object) { |
| 184 | return null; |
| 185 | } |
| 186 | |
| 187 | /** |
| 188 | * Returns the result of interpreting the object as an instance of '<em>Expression</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>Expression</em>'. |
| 195 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| 196 | * @generated |
| 197 | */ |
| 198 | public T caseExpression(Expression object) { |
| 199 | return null; |
| 200 | } |
| 201 | |
| 202 | /** |
| 203 | * Returns the result of interpreting the object as an instance of '<em>If Else</em>'. |
| 204 | * <!-- begin-user-doc --> |
| 205 | * This implementation returns null; |
| 206 | * returning a non-null result will terminate the switch. |
| 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>If Else</em>'. |
| 210 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| 211 | * @generated |
| 212 | */ |
| 213 | public T caseIfElse(IfElse object) { |
| 214 | return null; |
| 215 | } |
| 216 | |
| 217 | /** |
| 218 | * Returns the result of interpreting the object as an instance of '<em>Boolean Expression</em>'. |
| 219 | * <!-- begin-user-doc --> |
| 220 | * This implementation returns null; |
| 221 | * returning a non-null result will terminate the switch. |
| 222 | * <!-- end-user-doc --> |
| 223 | * @param object the target of the switch. |
| 224 | * @return the result of interpreting the object as an instance of '<em>Boolean Expression</em>'. |
| 225 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| 226 | * @generated |
| 227 | */ |
| 228 | public T caseBooleanExpression(BooleanExpression object) { |
| 229 | return null; |
| 230 | } |
| 231 | |
| 232 | /** |
| 233 | * Returns the result of interpreting the object as an instance of '<em>Comparison</em>'. |
| 234 | * <!-- begin-user-doc --> |
| 235 | * This implementation returns null; |
| 236 | * returning a non-null result will terminate the switch. |
| 237 | * <!-- end-user-doc --> |
| 238 | * @param object the target of the switch. |
| 239 | * @return the result of interpreting the object as an instance of '<em>Comparison</em>'. |
| 240 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| 241 | * @generated |
| 242 | */ |
| 243 | public T caseComparison(Comparison object) { |
| 244 | return null; |
| 245 | } |
| 246 | |
| 247 | /** |
| 248 | * Returns the result of interpreting the object as an instance of '<em>Term</em>'. |
| 249 | * <!-- begin-user-doc --> |
| 250 | * This implementation returns null; |
| 251 | * returning a non-null result will terminate the switch. |
| 252 | * <!-- end-user-doc --> |
| 253 | * @param object the target of the switch. |
| 254 | * @return the result of interpreting the object as an instance of '<em>Term</em>'. |
| 255 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| 256 | * @generated |
| 257 | */ |
| 258 | public T caseTerm(Term object) { |
| 259 | return null; |
| 260 | } |
| 261 | |
| 262 | /** |
| 263 | * Returns the result of interpreting the object as an instance of '<em>Product</em>'. |
| 264 | * <!-- begin-user-doc --> |
| 265 | * This implementation returns null; |
| 266 | * returning a non-null result will terminate the switch. |
| 267 | * <!-- end-user-doc --> |
| 268 | * @param object the target of the switch. |
| 269 | * @return the result of interpreting the object as an instance of '<em>Product</em>'. |
| 270 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| 271 | * @generated |
| 272 | */ |
| 273 | public T caseProduct(Product object) { |
| 274 | return null; |
| 275 | } |
| 276 | |
| 277 | /** |
| 278 | * Returns the result of interpreting the object as an instance of '<em>Power</em>'. |
| 279 | * <!-- begin-user-doc --> |
| 280 | * This implementation returns null; |
| 281 | * returning a non-null result will terminate the switch. |
| 282 | * <!-- end-user-doc --> |
| 283 | * @param object the target of the switch. |
| 284 | * @return the result of interpreting the object as an instance of '<em>Power</em>'. |
| 285 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| 286 | * @generated |
| 287 | */ |
| 288 | public T casePower(Power object) { |
| 289 | return null; |
| 290 | } |
| 291 | |
| 292 | /** |
| 293 | * Returns the result of interpreting the object as an instance of '<em>Unary</em>'. |
| 294 | * <!-- begin-user-doc --> |
| 295 | * This implementation returns null; |
| 296 | * returning a non-null result will terminate the switch. |
| 297 | * <!-- end-user-doc --> |
| 298 | * @param object the target of the switch. |
| 299 | * @return the result of interpreting the object as an instance of '<em>Unary</em>'. |
| 300 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| 301 | * @generated |
| 302 | */ |
| 303 | public T caseUnary(Unary object) { |
| 304 | return null; |
| 305 | } |
| 306 | |
| 307 | /** |
| 308 | * Returns the result of interpreting the object as an instance of '<em>Atom</em>'. |
| 309 | * <!-- begin-user-doc --> |
| 310 | * This implementation returns null; |
| 311 | * returning a non-null result will terminate the switch. |
| 312 | * <!-- end-user-doc --> |
| 313 | * @param object the target of the switch. |
| 314 | * @return the result of interpreting the object as an instance of '<em>Atom</em>'. |
| 315 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| 316 | * @generated |
| 317 | */ |
| 318 | public T caseAtom(Atom object) { |
| 319 | return null; |
| 320 | } |
| 321 | |
| 322 | /** |
| 323 | * Returns the result of interpreting the object as an instance of '<em>Variable</em>'. |
| 324 | * <!-- begin-user-doc --> |
| 325 | * This implementation returns null; |
| 326 | * returning a non-null result will terminate the switch. |
| 327 | * <!-- end-user-doc --> |
| 328 | * @param object the target of the switch. |
| 329 | * @return the result of interpreting the object as an instance of '<em>Variable</em>'. |
| 330 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| 331 | * @generated |
| 332 | */ |
| 333 | public T caseVariable(Variable object) { |
| 334 | return null; |
| 335 | } |
| 336 | |
| 337 | /** |
| 338 | * Returns the result of interpreting the object as an instance of '<em>EObject</em>'. |
| 339 | * <!-- begin-user-doc --> |
| 340 | * This implementation returns null; |
| 341 | * returning a non-null result will terminate the switch, but this is the last case anyway. |
| 342 | * <!-- end-user-doc --> |
| 343 | * @param object the target of the switch. |
| 344 | * @return the result of interpreting the object as an instance of '<em>EObject</em>'. |
| 345 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) |
| 346 | * @generated |
| 347 | */ |
| 348 | public T defaultCase(EObject object) { |
| 349 | return null; |
| 350 | } |
| 351 | |
| 352 | } //ParameterSwitch |