| 1 | /** |
| 2 | * <copyright> |
| 3 | * </copyright> |
| 4 | * |
| 5 | * $Id$ |
| 6 | */ |
| 7 | package QVTTemplate.util; |
| 8 | |
| 9 | import EMOF.Element; |
| 10 | import EMOF.NamedElement; |
| 11 | import EMOF.TypedElement; |
| 12 | |
| 13 | import EssentialOCL.LiteralExp; |
| 14 | import EssentialOCL.OclExpression; |
| 15 | |
| 16 | import QVTTemplate.*; |
| 17 | |
| 18 | import java.util.List; |
| 19 | |
| 20 | import org.eclipse.emf.ecore.EClass; |
| 21 | import org.eclipse.emf.ecore.EObject; |
| 22 | |
| 23 | /** |
| 24 | * <!-- begin-user-doc --> |
| 25 | * The <b>Switch</b> for the model's inheritance hierarchy. |
| 26 | * It supports the call {@link #doSwitch(EObject) doSwitch(object)} |
| 27 | * to invoke the <code>caseXXX</code> method for each class of the model, |
| 28 | * starting with the actual class of the object |
| 29 | * and proceeding up the inheritance hierarchy |
| 30 | * until a non-null result is returned, |
| 31 | * which is the result of the switch. |
| 32 | * <!-- end-user-doc --> |
| 33 | * @see QVTTemplate.QVTTemplatePackage |
| 34 | * @generated |
| 35 | */ |
| 36 | public class QVTTemplateSwitch<T> { |
| 37 | /** |
| 38 | * The cached model package |
| 39 | * <!-- begin-user-doc --> |
| 40 | * <!-- end-user-doc --> |
| 41 | * @generated |
| 42 | */ |
| 43 | protected static QVTTemplatePackage modelPackage; |
| 44 | |
| 45 | /** |
| 46 | * Creates an instance of the switch. |
| 47 | * <!-- begin-user-doc --> |
| 48 | * <!-- end-user-doc --> |
| 49 | * @generated |
| 50 | */ |
| 51 | public QVTTemplateSwitch() { |
| 52 | if (modelPackage == null) { |
| 53 | modelPackage = QVTTemplatePackage.eINSTANCE; |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. |
| 59 | * <!-- begin-user-doc --> |
| 60 | * <!-- end-user-doc --> |
| 61 | * @return the first non-null result returned by a <code>caseXXX</code> call. |
| 62 | * @generated |
| 63 | */ |
| 64 | public T doSwitch(EObject theEObject) { |
| 65 | return doSwitch(theEObject.eClass(), theEObject); |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. |
| 70 | * <!-- begin-user-doc --> |
| 71 | * <!-- end-user-doc --> |
| 72 | * @return the first non-null result returned by a <code>caseXXX</code> call. |
| 73 | * @generated |
| 74 | */ |
| 75 | protected T doSwitch(EClass theEClass, EObject theEObject) { |
| 76 | if (theEClass.eContainer() == modelPackage) { |
| 77 | return doSwitch(theEClass.getClassifierID(), theEObject); |
| 78 | } |
| 79 | else { |
| 80 | List<EClass> eSuperTypes = theEClass.getESuperTypes(); |
| 81 | return |
| 82 | eSuperTypes.isEmpty() ? |
| 83 | defaultCase(theEObject) : |
| 84 | doSwitch(eSuperTypes.get(0), theEObject); |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. |
| 90 | * <!-- begin-user-doc --> |
| 91 | * <!-- end-user-doc --> |
| 92 | * @return the first non-null result returned by a <code>caseXXX</code> call. |
| 93 | * @generated |
| 94 | */ |
| 95 | protected T doSwitch(int classifierID, EObject theEObject) { |
| 96 | switch (classifierID) { |
| 97 | case QVTTemplatePackage.COLLECTION_TEMPLATE_EXP: { |
| 98 | CollectionTemplateExp collectionTemplateExp = (CollectionTemplateExp)theEObject; |
| 99 | T result = caseCollectionTemplateExp(collectionTemplateExp); |
| 100 | if (result == null) result = caseTemplateExp(collectionTemplateExp); |
| 101 | if (result == null) result = caseLiteralExp(collectionTemplateExp); |
| 102 | if (result == null) result = caseOclExpression(collectionTemplateExp); |
| 103 | if (result == null) result = caseTypedElement(collectionTemplateExp); |
| 104 | if (result == null) result = caseNamedElement(collectionTemplateExp); |
| 105 | if (result == null) result = caseElement(collectionTemplateExp); |
| 106 | if (result == null) result = caseObject(collectionTemplateExp); |
| 107 | if (result == null) result = defaultCase(theEObject); |
| 108 | return result; |
| 109 | } |
| 110 | case QVTTemplatePackage.OBJECT_TEMPLATE_EXP: { |
| 111 | ObjectTemplateExp objectTemplateExp = (ObjectTemplateExp)theEObject; |
| 112 | T result = caseObjectTemplateExp(objectTemplateExp); |
| 113 | if (result == null) result = caseTemplateExp(objectTemplateExp); |
| 114 | if (result == null) result = caseLiteralExp(objectTemplateExp); |
| 115 | if (result == null) result = caseOclExpression(objectTemplateExp); |
| 116 | if (result == null) result = caseTypedElement(objectTemplateExp); |
| 117 | if (result == null) result = caseNamedElement(objectTemplateExp); |
| 118 | if (result == null) result = caseElement(objectTemplateExp); |
| 119 | if (result == null) result = caseObject(objectTemplateExp); |
| 120 | if (result == null) result = defaultCase(theEObject); |
| 121 | return result; |
| 122 | } |
| 123 | case QVTTemplatePackage.PROPERTY_TEMPLATE_ITEM: { |
| 124 | PropertyTemplateItem propertyTemplateItem = (PropertyTemplateItem)theEObject; |
| 125 | T result = casePropertyTemplateItem(propertyTemplateItem); |
| 126 | if (result == null) result = caseElement(propertyTemplateItem); |
| 127 | if (result == null) result = caseObject(propertyTemplateItem); |
| 128 | if (result == null) result = defaultCase(theEObject); |
| 129 | return result; |
| 130 | } |
| 131 | case QVTTemplatePackage.TEMPLATE_EXP: { |
| 132 | TemplateExp templateExp = (TemplateExp)theEObject; |
| 133 | T result = caseTemplateExp(templateExp); |
| 134 | if (result == null) result = caseLiteralExp(templateExp); |
| 135 | if (result == null) result = caseOclExpression(templateExp); |
| 136 | if (result == null) result = caseTypedElement(templateExp); |
| 137 | if (result == null) result = caseNamedElement(templateExp); |
| 138 | if (result == null) result = caseElement(templateExp); |
| 139 | if (result == null) result = caseObject(templateExp); |
| 140 | if (result == null) result = defaultCase(theEObject); |
| 141 | return result; |
| 142 | } |
| 143 | default: return defaultCase(theEObject); |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | /** |
| 148 | * Returns the result of interpreting the object as an instance of '<em>Collection Template Exp</em>'. |
| 149 | * <!-- begin-user-doc --> |
| 150 | * This implementation returns null; |
| 151 | * returning a non-null result will terminate the switch. |
| 152 | * <!-- end-user-doc --> |
| 153 | * @param object the target of the switch. |
| 154 | * @return the result of interpreting the object as an instance of '<em>Collection Template Exp</em>'. |
| 155 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| 156 | * @generated |
| 157 | */ |
| 158 | public T caseCollectionTemplateExp(CollectionTemplateExp object) { |
| 159 | return null; |
| 160 | } |
| 161 | |
| 162 | /** |
| 163 | * Returns the result of interpreting the object as an instance of '<em>Object Template Exp</em>'. |
| 164 | * <!-- begin-user-doc --> |
| 165 | * This implementation returns null; |
| 166 | * returning a non-null result will terminate the switch. |
| 167 | * <!-- end-user-doc --> |
| 168 | * @param object the target of the switch. |
| 169 | * @return the result of interpreting the object as an instance of '<em>Object Template Exp</em>'. |
| 170 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| 171 | * @generated |
| 172 | */ |
| 173 | public T caseObjectTemplateExp(ObjectTemplateExp object) { |
| 174 | return null; |
| 175 | } |
| 176 | |
| 177 | /** |
| 178 | * Returns the result of interpreting the object as an instance of '<em>Property Template Item</em>'. |
| 179 | * <!-- begin-user-doc --> |
| 180 | * This implementation returns null; |
| 181 | * returning a non-null result will terminate the switch. |
| 182 | * <!-- end-user-doc --> |
| 183 | * @param object the target of the switch. |
| 184 | * @return the result of interpreting the object as an instance of '<em>Property Template Item</em>'. |
| 185 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| 186 | * @generated |
| 187 | */ |
| 188 | public T casePropertyTemplateItem(PropertyTemplateItem object) { |
| 189 | return null; |
| 190 | } |
| 191 | |
| 192 | /** |
| 193 | * Returns the result of interpreting the object as an instance of '<em>Template Exp</em>'. |
| 194 | * <!-- begin-user-doc --> |
| 195 | * This implementation returns null; |
| 196 | * returning a non-null result will terminate the switch. |
| 197 | * <!-- end-user-doc --> |
| 198 | * @param object the target of the switch. |
| 199 | * @return the result of interpreting the object as an instance of '<em>Template Exp</em>'. |
| 200 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| 201 | * @generated |
| 202 | */ |
| 203 | public T caseTemplateExp(TemplateExp object) { |
| 204 | return null; |
| 205 | } |
| 206 | |
| 207 | /** |
| 208 | * Returns the result of interpreting the object as an instance of '<em>Object</em>'. |
| 209 | * <!-- begin-user-doc --> |
| 210 | * This implementation returns null; |
| 211 | * returning a non-null result will terminate the switch. |
| 212 | * <!-- end-user-doc --> |
| 213 | * @param object the target of the switch. |
| 214 | * @return the result of interpreting the object as an instance of '<em>Object</em>'. |
| 215 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| 216 | * @generated |
| 217 | */ |
| 218 | public T caseObject(EMOF.Object object) { |
| 219 | return null; |
| 220 | } |
| 221 | |
| 222 | /** |
| 223 | * Returns the result of interpreting the object as an instance of '<em>Element</em>'. |
| 224 | * <!-- begin-user-doc --> |
| 225 | * This implementation returns null; |
| 226 | * returning a non-null result will terminate the switch. |
| 227 | * <!-- end-user-doc --> |
| 228 | * @param object the target of the switch. |
| 229 | * @return the result of interpreting the object as an instance of '<em>Element</em>'. |
| 230 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| 231 | * @generated |
| 232 | */ |
| 233 | public T caseElement(Element object) { |
| 234 | return null; |
| 235 | } |
| 236 | |
| 237 | /** |
| 238 | * Returns the result of interpreting the object as an instance of '<em>Named Element</em>'. |
| 239 | * <!-- begin-user-doc --> |
| 240 | * This implementation returns null; |
| 241 | * returning a non-null result will terminate the switch. |
| 242 | * <!-- end-user-doc --> |
| 243 | * @param object the target of the switch. |
| 244 | * @return the result of interpreting the object as an instance of '<em>Named Element</em>'. |
| 245 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| 246 | * @generated |
| 247 | */ |
| 248 | public T caseNamedElement(NamedElement object) { |
| 249 | return null; |
| 250 | } |
| 251 | |
| 252 | /** |
| 253 | * Returns the result of interpreting the object as an instance of '<em>Typed Element</em>'. |
| 254 | * <!-- begin-user-doc --> |
| 255 | * This implementation returns null; |
| 256 | * returning a non-null result will terminate the switch. |
| 257 | * <!-- end-user-doc --> |
| 258 | * @param object the target of the switch. |
| 259 | * @return the result of interpreting the object as an instance of '<em>Typed Element</em>'. |
| 260 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| 261 | * @generated |
| 262 | */ |
| 263 | public T caseTypedElement(TypedElement object) { |
| 264 | return null; |
| 265 | } |
| 266 | |
| 267 | /** |
| 268 | * Returns the result of interpreting the object as an instance of '<em>Ocl Expression</em>'. |
| 269 | * <!-- begin-user-doc --> |
| 270 | * This implementation returns null; |
| 271 | * returning a non-null result will terminate the switch. |
| 272 | * <!-- end-user-doc --> |
| 273 | * @param object the target of the switch. |
| 274 | * @return the result of interpreting the object as an instance of '<em>Ocl Expression</em>'. |
| 275 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| 276 | * @generated |
| 277 | */ |
| 278 | public T caseOclExpression(OclExpression object) { |
| 279 | return null; |
| 280 | } |
| 281 | |
| 282 | /** |
| 283 | * Returns the result of interpreting the object as an instance of '<em>Literal Exp</em>'. |
| 284 | * <!-- begin-user-doc --> |
| 285 | * This implementation returns null; |
| 286 | * returning a non-null result will terminate the switch. |
| 287 | * <!-- end-user-doc --> |
| 288 | * @param object the target of the switch. |
| 289 | * @return the result of interpreting the object as an instance of '<em>Literal Exp</em>'. |
| 290 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| 291 | * @generated |
| 292 | */ |
| 293 | public T caseLiteralExp(LiteralExp object) { |
| 294 | return null; |
| 295 | } |
| 296 | |
| 297 | /** |
| 298 | * Returns the result of interpreting the object as an instance of '<em>EObject</em>'. |
| 299 | * <!-- begin-user-doc --> |
| 300 | * This implementation returns null; |
| 301 | * returning a non-null result will terminate the switch, but this is the last case anyway. |
| 302 | * <!-- end-user-doc --> |
| 303 | * @param object the target of the switch. |
| 304 | * @return the result of interpreting the object as an instance of '<em>EObject</em>'. |
| 305 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) |
| 306 | * @generated |
| 307 | */ |
| 308 | public T defaultCase(EObject object) { |
| 309 | return null; |
| 310 | } |
| 311 | |
| 312 | } //QVTTemplateSwitch |