1 17 package org.eclipse.emf.mapping.util; 18 19 import java.util.List ; 20 21 import org.eclipse.emf.ecore.EClass; 22 import org.eclipse.emf.ecore.EObject; 23 import org.eclipse.emf.mapping.*; 24 25 26 39 public class MappingSwitch 40 { 41 47 protected static MappingPackage modelPackage; 48 49 55 public MappingSwitch() 56 { 57 if (modelPackage == null) 58 { 59 modelPackage = MappingPackage.eINSTANCE; 60 } 61 } 62 63 70 public Object doSwitch(EObject theEObject) 71 { 72 return doSwitch(theEObject.eClass(), theEObject); 73 } 74 75 82 protected Object doSwitch(EClass theEClass, EObject theEObject) 83 { 84 if (theEClass.eContainer() == modelPackage) 85 { 86 return doSwitch(theEClass.getClassifierID(), theEObject); 87 } 88 else 89 { 90 List eSuperTypes = theEClass.getESuperTypes(); 91 return 92 eSuperTypes.isEmpty() ? 93 defaultCase(theEObject) : 94 doSwitch((EClass)eSuperTypes.get(0), theEObject); 95 } 96 } 97 98 105 protected Object doSwitch(int classifierID, EObject theEObject) 106 { 107 switch (classifierID) 108 { 109 case MappingPackage.MAPPING_HELPER: 110 { 111 MappingHelper mappingHelper = (MappingHelper)theEObject; 112 Object result = caseMappingHelper(mappingHelper); 113 if (result == null) result = defaultCase(theEObject); 114 return result; 115 } 116 case MappingPackage.MAPPING: 117 { 118 Mapping mapping = (Mapping)theEObject; 119 Object result = caseMapping(mapping); 120 if (result == null) result = defaultCase(theEObject); 121 return result; 122 } 123 case MappingPackage.TYPE_CONVERTER: 124 { 125 TypeConverter typeConverter = (TypeConverter)theEObject; 126 Object result = caseTypeConverter(typeConverter); 127 if (result == null) result = caseMappingHelper(typeConverter); 128 if (result == null) result = defaultCase(theEObject); 129 return result; 130 } 131 case MappingPackage.FUNCTION_PAIR: 132 { 133 FunctionPair functionPair = (FunctionPair)theEObject; 134 Object result = caseFunctionPair(functionPair); 135 if (result == null) result = caseTypeConverter(functionPair); 136 if (result == null) result = caseMappingHelper(functionPair); 137 if (result == null) result = defaultCase(theEObject); 138 return result; 139 } 140 case MappingPackage.FUNCTION_NAME_PAIR: 141 { 142 FunctionNamePair functionNamePair = (FunctionNamePair)theEObject; 143 Object result = caseFunctionNamePair(functionNamePair); 144 if (result == null) result = caseTypeConverter(functionNamePair); 145 if (result == null) result = caseMappingHelper(functionNamePair); 146 if (result == null) result = defaultCase(theEObject); 147 return result; 148 } 149 case MappingPackage.MAPPING_STRATEGY: 150 { 151 MappingStrategy mappingStrategy = (MappingStrategy)theEObject; 152 Object result = caseMappingStrategy(mappingStrategy); 153 if (result == null) result = caseMappingHelper(mappingStrategy); 154 if (result == null) result = defaultCase(theEObject); 155 return result; 156 } 157 case MappingPackage.MAPPING_ROOT: 158 { 159 MappingRoot mappingRoot = (MappingRoot)theEObject; 160 Object result = caseMappingRoot(mappingRoot); 161 if (result == null) result = caseMapping(mappingRoot); 162 if (result == null) result = defaultCase(theEObject); 163 return result; 164 } 165 case MappingPackage.COMPLEX_TYPE_CONVERTER: 166 { 167 ComplexTypeConverter complexTypeConverter = (ComplexTypeConverter)theEObject; 168 Object result = caseComplexTypeConverter(complexTypeConverter); 169 if (result == null) result = caseTypeConverter(complexTypeConverter); 170 if (result == null) result = caseMappingHelper(complexTypeConverter); 171 if (result == null) result = defaultCase(theEObject); 172 return result; 173 } 174 default: return defaultCase(theEObject); 175 } 176 } 177 178 189 public Object caseMappingHelper(MappingHelper object) 190 { 191 return null; 192 } 193 194 205 public Object caseMapping(Mapping object) 206 { 207 return null; 208 } 209 210 221 public Object caseTypeConverter(TypeConverter object) 222 { 223 return null; 224 } 225 226 237 public Object caseFunctionPair(FunctionPair object) 238 { 239 return null; 240 } 241 242 253 public Object caseFunctionNamePair(FunctionNamePair object) 254 { 255 return null; 256 } 257 258 269 public Object caseMappingStrategy(MappingStrategy object) 270 { 271 return null; 272 } 273 274 285 public Object caseMappingRoot(MappingRoot object) 286 { 287 return null; 288 } 289 290 301 public Object caseComplexTypeConverter(ComplexTypeConverter object) 302 { 303 return null; 304 } 305 306 317 public Object defaultCase(EObject object) 318 { 319 return null; 320 } 321 322 } | Popular Tags |