| 1 | /** |
| 2 | * Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany |
| 3 | * |
| 4 | * $Id$ |
| 5 | */ |
| 6 | package de.uka.ipd.sdq.pcm.util; |
| 7 | |
| 8 | import de.uka.ipd.sdq.pcm.*; |
| 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.DummyClass; |
| 15 | import de.uka.ipd.sdq.pcm.PcmPackage; |
| 16 | |
| 17 | /** |
| 18 | * <!-- begin-user-doc --> |
| 19 | * The <b>Switch</b> for the model's inheritance hierarchy. |
| 20 | * It supports the call {@link #doSwitch(EObject) doSwitch(object)} |
| 21 | * to invoke the <code>caseXXX</code> method for each class of the model, |
| 22 | * starting with the actual class of the object |
| 23 | * and proceeding up the inheritance hierarchy |
| 24 | * until a non-null result is returned, |
| 25 | * which is the result of the switch. |
| 26 | * <!-- end-user-doc --> |
| 27 | * @see de.uka.ipd.sdq.pcm.PcmPackage |
| 28 | * @generated |
| 29 | */ |
| 30 | public class PcmSwitch<T> { |
| 31 | /** |
| 32 | * <!-- begin-user-doc --> |
| 33 | * <!-- end-user-doc --> |
| 34 | * @generated |
| 35 | */ |
| 36 | public static final String copyright = "Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany"; |
| 37 | |
| 38 | /** |
| 39 | * The cached model package |
| 40 | * <!-- begin-user-doc --> |
| 41 | * <!-- end-user-doc --> |
| 42 | * @generated |
| 43 | */ |
| 44 | protected static PcmPackage modelPackage; |
| 45 | |
| 46 | /** |
| 47 | * Creates an instance of the switch. |
| 48 | * <!-- begin-user-doc --> |
| 49 | * <!-- end-user-doc --> |
| 50 | * @generated |
| 51 | */ |
| 52 | public PcmSwitch() { |
| 53 | if (modelPackage == null) { |
| 54 | modelPackage = PcmPackage.eINSTANCE; |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. |
| 60 | * <!-- begin-user-doc --> |
| 61 | * <!-- end-user-doc --> |
| 62 | * @return the first non-null result returned by a <code>caseXXX</code> call. |
| 63 | * @generated |
| 64 | */ |
| 65 | public T doSwitch(EObject theEObject) { |
| 66 | return doSwitch(theEObject.eClass(), theEObject); |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. |
| 71 | * <!-- begin-user-doc --> |
| 72 | * <!-- end-user-doc --> |
| 73 | * @return the first non-null result returned by a <code>caseXXX</code> call. |
| 74 | * @generated |
| 75 | */ |
| 76 | protected T doSwitch(EClass theEClass, EObject theEObject) { |
| 77 | if (theEClass.eContainer() == modelPackage) { |
| 78 | return doSwitch(theEClass.getClassifierID(), theEObject); |
| 79 | } |
| 80 | else { |
| 81 | List<EClass> eSuperTypes = theEClass.getESuperTypes(); |
| 82 | return |
| 83 | eSuperTypes.isEmpty() ? |
| 84 | defaultCase(theEObject) : |
| 85 | doSwitch(eSuperTypes.get(0), theEObject); |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. |
| 91 | * <!-- begin-user-doc --> |
| 92 | * <!-- end-user-doc --> |
| 93 | * @return the first non-null result returned by a <code>caseXXX</code> call. |
| 94 | * @generated |
| 95 | */ |
| 96 | protected T doSwitch(int classifierID, EObject theEObject) { |
| 97 | switch (classifierID) { |
| 98 | case PcmPackage.DUMMY_CLASS: { |
| 99 | DummyClass dummyClass = (DummyClass)theEObject; |
| 100 | T result = caseDummyClass(dummyClass); |
| 101 | if (result == null) result = defaultCase(theEObject); |
| 102 | return result; |
| 103 | } |
| 104 | default: return defaultCase(theEObject); |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * Returns the result of interpreting the object as an instance of '<em>Dummy Class</em>'. |
| 110 | * <!-- begin-user-doc --> |
| 111 | * This implementation returns null; |
| 112 | * returning a non-null result will terminate the switch. |
| 113 | * <!-- end-user-doc --> |
| 114 | * @param object the target of the switch. |
| 115 | * @return the result of interpreting the object as an instance of '<em>Dummy Class</em>'. |
| 116 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| 117 | * @generated |
| 118 | */ |
| 119 | public T caseDummyClass(DummyClass object) { |
| 120 | return null; |
| 121 | } |
| 122 | |
| 123 | /** |
| 124 | * Returns the result of interpreting the object as an instance of '<em>EObject</em>'. |
| 125 | * <!-- begin-user-doc --> |
| 126 | * This implementation returns null; |
| 127 | * returning a non-null result will terminate the switch, but this is the last case anyway. |
| 128 | * <!-- end-user-doc --> |
| 129 | * @param object the target of the switch. |
| 130 | * @return the result of interpreting the object as an instance of '<em>EObject</em>'. |
| 131 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) |
| 132 | * @generated |
| 133 | */ |
| 134 | public T defaultCase(EObject object) { |
| 135 | return null; |
| 136 | } |
| 137 | |
| 138 | } //PcmSwitch |