| 1 | /** |
| 2 | * Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany |
| 3 | * |
| 4 | * $Id$ |
| 5 | */ |
| 6 | package de.uka.ipd.sdq.pcm.allocation.util; |
| 7 | |
| 8 | import java.util.List; |
| 9 | |
| 10 | import org.eclipse.emf.ecore.EClass; |
| 11 | import org.eclipse.emf.ecore.EObject; |
| 12 | |
| 13 | import de.uka.ipd.sdq.identifier.Identifier; |
| 14 | import de.uka.ipd.sdq.pcm.allocation.*; |
| 15 | import de.uka.ipd.sdq.pcm.allocation.Allocation; |
| 16 | import de.uka.ipd.sdq.pcm.allocation.AllocationContext; |
| 17 | import de.uka.ipd.sdq.pcm.allocation.AllocationPackage; |
| 18 | import de.uka.ipd.sdq.pcm.core.entity.Entity; |
| 19 | import de.uka.ipd.sdq.pcm.core.entity.NamedElement; |
| 20 | |
| 21 | /** |
| 22 | * <!-- begin-user-doc --> |
| 23 | * The <b>Switch</b> for the model's inheritance hierarchy. |
| 24 | * It supports the call {@link #doSwitch(EObject) doSwitch(object)} |
| 25 | * to invoke the <code>caseXXX</code> method for each class of the model, |
| 26 | * starting with the actual class of the object |
| 27 | * and proceeding up the inheritance hierarchy |
| 28 | * until a non-null result is returned, |
| 29 | * which is the result of the switch. |
| 30 | * <!-- end-user-doc --> |
| 31 | * @see de.uka.ipd.sdq.pcm.allocation.AllocationPackage |
| 32 | * @generated |
| 33 | */ |
| 34 | public class AllocationSwitch<T> { |
| 35 | /** |
| 36 | * <!-- begin-user-doc --> |
| 37 | * <!-- end-user-doc --> |
| 38 | * @generated |
| 39 | */ |
| 40 | public static final String copyright = "Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany"; |
| 41 | |
| 42 | /** |
| 43 | * The cached model package |
| 44 | * <!-- begin-user-doc --> |
| 45 | * <!-- end-user-doc --> |
| 46 | * @generated |
| 47 | */ |
| 48 | protected static AllocationPackage modelPackage; |
| 49 | |
| 50 | /** |
| 51 | * Creates an instance of the switch. |
| 52 | * <!-- begin-user-doc --> |
| 53 | * <!-- end-user-doc --> |
| 54 | * @generated |
| 55 | */ |
| 56 | public AllocationSwitch() { |
| 57 | if (modelPackage == null) { |
| 58 | modelPackage = AllocationPackage.eINSTANCE; |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. |
| 64 | * <!-- begin-user-doc --> |
| 65 | * <!-- end-user-doc --> |
| 66 | * @return the first non-null result returned by a <code>caseXXX</code> call. |
| 67 | * @generated |
| 68 | */ |
| 69 | public T doSwitch(EObject theEObject) { |
| 70 | return doSwitch(theEObject.eClass(), theEObject); |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. |
| 75 | * <!-- begin-user-doc --> |
| 76 | * <!-- end-user-doc --> |
| 77 | * @return the first non-null result returned by a <code>caseXXX</code> call. |
| 78 | * @generated |
| 79 | */ |
| 80 | protected T doSwitch(EClass theEClass, EObject theEObject) { |
| 81 | if (theEClass.eContainer() == modelPackage) { |
| 82 | return doSwitch(theEClass.getClassifierID(), theEObject); |
| 83 | } |
| 84 | else { |
| 85 | List<EClass> eSuperTypes = theEClass.getESuperTypes(); |
| 86 | return |
| 87 | eSuperTypes.isEmpty() ? |
| 88 | defaultCase(theEObject) : |
| 89 | doSwitch(eSuperTypes.get(0), theEObject); |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. |
| 95 | * <!-- begin-user-doc --> |
| 96 | * <!-- end-user-doc --> |
| 97 | * @return the first non-null result returned by a <code>caseXXX</code> call. |
| 98 | * @generated |
| 99 | */ |
| 100 | protected T doSwitch(int classifierID, EObject theEObject) { |
| 101 | switch (classifierID) { |
| 102 | case AllocationPackage.ALLOCATION_CONTEXT: { |
| 103 | AllocationContext allocationContext = (AllocationContext)theEObject; |
| 104 | T result = caseAllocationContext(allocationContext); |
| 105 | if (result == null) result = caseEntity(allocationContext); |
| 106 | if (result == null) result = caseIdentifier(allocationContext); |
| 107 | if (result == null) result = caseNamedElement(allocationContext); |
| 108 | if (result == null) result = defaultCase(theEObject); |
| 109 | return result; |
| 110 | } |
| 111 | case AllocationPackage.ALLOCATION: { |
| 112 | Allocation allocation = (Allocation)theEObject; |
| 113 | T result = caseAllocation(allocation); |
| 114 | if (result == null) result = caseEntity(allocation); |
| 115 | if (result == null) result = caseIdentifier(allocation); |
| 116 | if (result == null) result = caseNamedElement(allocation); |
| 117 | if (result == null) result = defaultCase(theEObject); |
| 118 | return result; |
| 119 | } |
| 120 | default: return defaultCase(theEObject); |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * Returns the result of interpreting the object as an instance of '<em>Context</em>'. |
| 126 | * <!-- begin-user-doc --> |
| 127 | * This implementation returns null; |
| 128 | * returning a non-null result will terminate the switch. |
| 129 | * <!-- end-user-doc --> |
| 130 | * @param object the target of the switch. |
| 131 | * @return the result of interpreting the object as an instance of '<em>Context</em>'. |
| 132 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| 133 | * @generated |
| 134 | */ |
| 135 | public T caseAllocationContext(AllocationContext object) { |
| 136 | return null; |
| 137 | } |
| 138 | |
| 139 | /** |
| 140 | * Returns the result of interpreting the object as an instance of '<em>Allocation</em>'. |
| 141 | * <!-- begin-user-doc --> |
| 142 | * This implementation returns null; |
| 143 | * returning a non-null result will terminate the switch. |
| 144 | * <!-- end-user-doc --> |
| 145 | * @param object the target of the switch. |
| 146 | * @return the result of interpreting the object as an instance of '<em>Allocation</em>'. |
| 147 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| 148 | * @generated |
| 149 | */ |
| 150 | public T caseAllocation(Allocation object) { |
| 151 | return null; |
| 152 | } |
| 153 | |
| 154 | /** |
| 155 | * Returns the result of interpreting the object as an instance of '<em>Identifier</em>'. |
| 156 | * <!-- begin-user-doc --> |
| 157 | * This implementation returns null; |
| 158 | * returning a non-null result will terminate the switch. |
| 159 | * <!-- end-user-doc --> |
| 160 | * @param object the target of the switch. |
| 161 | * @return the result of interpreting the object as an instance of '<em>Identifier</em>'. |
| 162 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| 163 | * @generated |
| 164 | */ |
| 165 | public T caseIdentifier(Identifier object) { |
| 166 | return null; |
| 167 | } |
| 168 | |
| 169 | /** |
| 170 | * Returns the result of interpreting the object as an instance of '<em>Named Element</em>'. |
| 171 | * <!-- begin-user-doc --> |
| 172 | * This implementation returns null; |
| 173 | * returning a non-null result will terminate the switch. |
| 174 | * <!-- end-user-doc --> |
| 175 | * @param object the target of the switch. |
| 176 | * @return the result of interpreting the object as an instance of '<em>Named Element</em>'. |
| 177 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| 178 | * @generated |
| 179 | */ |
| 180 | public T caseNamedElement(NamedElement object) { |
| 181 | return null; |
| 182 | } |
| 183 | |
| 184 | /** |
| 185 | * Returns the result of interpreting the object as an instance of '<em>Entity</em>'. |
| 186 | * <!-- begin-user-doc --> |
| 187 | * This implementation returns null; |
| 188 | * returning a non-null result will terminate the switch. |
| 189 | * <!-- end-user-doc --> |
| 190 | * @param object the target of the switch. |
| 191 | * @return the result of interpreting the object as an instance of '<em>Entity</em>'. |
| 192 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| 193 | * @generated |
| 194 | */ |
| 195 | public T caseEntity(Entity object) { |
| 196 | return null; |
| 197 | } |
| 198 | |
| 199 | /** |
| 200 | * Returns the result of interpreting the object as an instance of '<em>EObject</em>'. |
| 201 | * <!-- begin-user-doc --> |
| 202 | * This implementation returns null; |
| 203 | * returning a non-null result will terminate the switch, but this is the last case anyway. |
| 204 | * <!-- end-user-doc --> |
| 205 | * @param object the target of the switch. |
| 206 | * @return the result of interpreting the object as an instance of '<em>EObject</em>'. |
| 207 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) |
| 208 | * @generated |
| 209 | */ |
| 210 | public T defaultCase(EObject object) { |
| 211 | return null; |
| 212 | } |
| 213 | |
| 214 | } //AllocationSwitch |