| 1 | /** |
| 2 | * <copyright> |
| 3 | * </copyright> |
| 4 | * |
| 5 | * $Id$ |
| 6 | */ |
| 7 | package de.fzi.se.quality.util; |
| 8 | |
| 9 | import de.fzi.se.quality.*; |
| 10 | |
| 11 | import de.uka.ipd.sdq.identifier.Identifier; |
| 12 | |
| 13 | import java.util.List; |
| 14 | |
| 15 | import org.eclipse.emf.ecore.EClass; |
| 16 | import org.eclipse.emf.ecore.EObject; |
| 17 | |
| 18 | /** |
| 19 | * <!-- begin-user-doc --> |
| 20 | * The <b>Switch</b> for the model's inheritance hierarchy. |
| 21 | * It supports the call {@link #doSwitch(EObject) doSwitch(object)} |
| 22 | * to invoke the <code>caseXXX</code> method for each class of the model, |
| 23 | * starting with the actual class of the object |
| 24 | * and proceeding up the inheritance hierarchy |
| 25 | * until a non-null result is returned, |
| 26 | * which is the result of the switch. |
| 27 | * <!-- end-user-doc --> |
| 28 | * @see de.fzi.se.quality.QualityPackage |
| 29 | * @generated |
| 30 | */ |
| 31 | public class QualitySwitch<T> { |
| 32 | /** |
| 33 | * The cached model package |
| 34 | * <!-- begin-user-doc --> |
| 35 | * <!-- end-user-doc --> |
| 36 | * @generated |
| 37 | */ |
| 38 | protected static QualityPackage modelPackage; |
| 39 | |
| 40 | /** |
| 41 | * Creates an instance of the switch. |
| 42 | * <!-- begin-user-doc --> |
| 43 | * <!-- end-user-doc --> |
| 44 | * @generated |
| 45 | */ |
| 46 | public QualitySwitch() { |
| 47 | if (modelPackage == null) { |
| 48 | modelPackage = QualityPackage.eINSTANCE; |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. |
| 54 | * <!-- begin-user-doc --> |
| 55 | * <!-- end-user-doc --> |
| 56 | * @return the first non-null result returned by a <code>caseXXX</code> call. |
| 57 | * @generated |
| 58 | */ |
| 59 | public T doSwitch(EObject theEObject) { |
| 60 | return doSwitch(theEObject.eClass(), theEObject); |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. |
| 65 | * <!-- begin-user-doc --> |
| 66 | * <!-- end-user-doc --> |
| 67 | * @return the first non-null result returned by a <code>caseXXX</code> call. |
| 68 | * @generated |
| 69 | */ |
| 70 | protected T doSwitch(EClass theEClass, EObject theEObject) { |
| 71 | if (theEClass.eContainer() == modelPackage) { |
| 72 | return doSwitch(theEClass.getClassifierID(), theEObject); |
| 73 | } |
| 74 | else { |
| 75 | List<EClass> eSuperTypes = theEClass.getESuperTypes(); |
| 76 | return |
| 77 | eSuperTypes.isEmpty() ? |
| 78 | defaultCase(theEObject) : |
| 79 | doSwitch(eSuperTypes.get(0), theEObject); |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. |
| 85 | * <!-- begin-user-doc --> |
| 86 | * <!-- end-user-doc --> |
| 87 | * @return the first non-null result returned by a <code>caseXXX</code> call. |
| 88 | * @generated |
| 89 | */ |
| 90 | protected T doSwitch(int classifierID, EObject theEObject) { |
| 91 | switch (classifierID) { |
| 92 | case QualityPackage.QUALITY_REPOSITORY: { |
| 93 | QualityRepository qualityRepository = (QualityRepository)theEObject; |
| 94 | T result = caseQualityRepository(qualityRepository); |
| 95 | if (result == null) result = caseIdentifier(qualityRepository); |
| 96 | if (result == null) result = defaultCase(theEObject); |
| 97 | return result; |
| 98 | } |
| 99 | case QualityPackage.QUALITY_STATEMENT: { |
| 100 | QualityStatement qualityStatement = (QualityStatement)theEObject; |
| 101 | T result = caseQualityStatement(qualityStatement); |
| 102 | if (result == null) result = caseIdentifier(qualityStatement); |
| 103 | if (result == null) result = defaultCase(theEObject); |
| 104 | return result; |
| 105 | } |
| 106 | default: return defaultCase(theEObject); |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * Returns the result of interpreting the object as an instance of '<em>Repository</em>'. |
| 112 | * <!-- begin-user-doc --> |
| 113 | * This implementation returns null; |
| 114 | * returning a non-null result will terminate the switch. |
| 115 | * <!-- end-user-doc --> |
| 116 | * @param object the target of the switch. |
| 117 | * @return the result of interpreting the object as an instance of '<em>Repository</em>'. |
| 118 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| 119 | * @generated |
| 120 | */ |
| 121 | public T caseQualityRepository(QualityRepository object) { |
| 122 | return null; |
| 123 | } |
| 124 | |
| 125 | /** |
| 126 | * Returns the result of interpreting the object as an instance of '<em>Statement</em>'. |
| 127 | * <!-- begin-user-doc --> |
| 128 | * This implementation returns null; |
| 129 | * returning a non-null result will terminate the switch. |
| 130 | * <!-- end-user-doc --> |
| 131 | * @param object the target of the switch. |
| 132 | * @return the result of interpreting the object as an instance of '<em>Statement</em>'. |
| 133 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| 134 | * @generated |
| 135 | */ |
| 136 | public T caseQualityStatement(QualityStatement object) { |
| 137 | return null; |
| 138 | } |
| 139 | |
| 140 | /** |
| 141 | * Returns the result of interpreting the object as an instance of '<em>Identifier</em>'. |
| 142 | * <!-- begin-user-doc --> |
| 143 | * This implementation returns null; |
| 144 | * returning a non-null result will terminate the switch. |
| 145 | * <!-- end-user-doc --> |
| 146 | * @param object the target of the switch. |
| 147 | * @return the result of interpreting the object as an instance of '<em>Identifier</em>'. |
| 148 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| 149 | * @generated |
| 150 | */ |
| 151 | public T caseIdentifier(Identifier object) { |
| 152 | return null; |
| 153 | } |
| 154 | |
| 155 | /** |
| 156 | * Returns the result of interpreting the object as an instance of '<em>EObject</em>'. |
| 157 | * <!-- begin-user-doc --> |
| 158 | * This implementation returns null; |
| 159 | * returning a non-null result will terminate the switch, but this is the last case anyway. |
| 160 | * <!-- end-user-doc --> |
| 161 | * @param object the target of the switch. |
| 162 | * @return the result of interpreting the object as an instance of '<em>EObject</em>'. |
| 163 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) |
| 164 | * @generated |
| 165 | */ |
| 166 | public T defaultCase(EObject object) { |
| 167 | return null; |
| 168 | } |
| 169 | |
| 170 | } //QualitySwitch |