1 17 package org.eclipse.emf.ecore.util; 18 19 20 import java.util.List ; 21 import java.util.Map ; 22 23 import org.eclipse.emf.ecore.*; 24 import org.eclipse.emf.ecore.EClass; 25 import org.eclipse.emf.ecore.EObject; 26 27 28 41 public class EcoreSwitch 42 { 43 49 protected static EcorePackage modelPackage; 50 51 57 public EcoreSwitch() 58 { 59 if (modelPackage == null) 60 { 61 modelPackage = EcorePackage.eINSTANCE; 62 } 63 } 64 65 72 public Object doSwitch(EObject theEObject) 73 { 74 return doSwitch(theEObject.eClass(), theEObject); 75 } 76 77 84 protected Object doSwitch(EClass theEClass, EObject theEObject) 85 { 86 if (theEClass.eContainer() == modelPackage) 87 { 88 return doSwitch(theEClass.getClassifierID(), theEObject); 89 } 90 else 91 { 92 List eSuperTypes = theEClass.getESuperTypes(); 93 return 94 eSuperTypes.isEmpty() ? 95 defaultCase(theEObject) : 96 doSwitch((EClass)eSuperTypes.get(0), theEObject); 97 } 98 } 99 100 107 protected Object doSwitch(int classifierID, EObject theEObject) 108 { 109 switch (classifierID) 110 { 111 case EcorePackage.EATTRIBUTE: 112 { 113 EAttribute eAttribute = (EAttribute)theEObject; 114 Object result = caseEAttribute(eAttribute); 115 if (result == null) result = caseEStructuralFeature(eAttribute); 116 if (result == null) result = caseETypedElement(eAttribute); 117 if (result == null) result = caseENamedElement(eAttribute); 118 if (result == null) result = caseEModelElement(eAttribute); 119 if (result == null) result = defaultCase(theEObject); 120 return result; 121 } 122 case EcorePackage.EANNOTATION: 123 { 124 EAnnotation eAnnotation = (EAnnotation)theEObject; 125 Object result = caseEAnnotation(eAnnotation); 126 if (result == null) result = caseEModelElement(eAnnotation); 127 if (result == null) result = defaultCase(theEObject); 128 return result; 129 } 130 case EcorePackage.ECLASS: 131 { 132 EClass eClass = (EClass)theEObject; 133 Object result = caseEClass(eClass); 134 if (result == null) result = caseEClassifier(eClass); 135 if (result == null) result = caseENamedElement(eClass); 136 if (result == null) result = caseEModelElement(eClass); 137 if (result == null) result = defaultCase(theEObject); 138 return result; 139 } 140 case EcorePackage.ECLASSIFIER: 141 { 142 EClassifier eClassifier = (EClassifier)theEObject; 143 Object result = caseEClassifier(eClassifier); 144 if (result == null) result = caseENamedElement(eClassifier); 145 if (result == null) result = caseEModelElement(eClassifier); 146 if (result == null) result = defaultCase(theEObject); 147 return result; 148 } 149 case EcorePackage.EDATA_TYPE: 150 { 151 EDataType eDataType = (EDataType)theEObject; 152 Object result = caseEDataType(eDataType); 153 if (result == null) result = caseEClassifier(eDataType); 154 if (result == null) result = caseENamedElement(eDataType); 155 if (result == null) result = caseEModelElement(eDataType); 156 if (result == null) result = defaultCase(theEObject); 157 return result; 158 } 159 case EcorePackage.EENUM: 160 { 161 EEnum eEnum = (EEnum)theEObject; 162 Object result = caseEEnum(eEnum); 163 if (result == null) result = caseEDataType(eEnum); 164 if (result == null) result = caseEClassifier(eEnum); 165 if (result == null) result = caseENamedElement(eEnum); 166 if (result == null) result = caseEModelElement(eEnum); 167 if (result == null) result = defaultCase(theEObject); 168 return result; 169 } 170 case EcorePackage.EENUM_LITERAL: 171 { 172 EEnumLiteral eEnumLiteral = (EEnumLiteral)theEObject; 173 Object result = caseEEnumLiteral(eEnumLiteral); 174 if (result == null) result = caseENamedElement(eEnumLiteral); 175 if (result == null) result = caseEModelElement(eEnumLiteral); 176 if (result == null) result = defaultCase(theEObject); 177 return result; 178 } 179 case EcorePackage.EFACTORY: 180 { 181 EFactory eFactory = (EFactory)theEObject; 182 Object result = caseEFactory(eFactory); 183 if (result == null) result = caseEModelElement(eFactory); 184 if (result == null) result = defaultCase(theEObject); 185 return result; 186 } 187 case EcorePackage.EMODEL_ELEMENT: 188 { 189 EModelElement eModelElement = (EModelElement)theEObject; 190 Object result = caseEModelElement(eModelElement); 191 if (result == null) result = defaultCase(theEObject); 192 return result; 193 } 194 case EcorePackage.ENAMED_ELEMENT: 195 { 196 ENamedElement eNamedElement = (ENamedElement)theEObject; 197 Object result = caseENamedElement(eNamedElement); 198 if (result == null) result = caseEModelElement(eNamedElement); 199 if (result == null) result = defaultCase(theEObject); 200 return result; 201 } 202 case EcorePackage.EOPERATION: 203 { 204 EOperation eOperation = (EOperation)theEObject; 205 Object result = caseEOperation(eOperation); 206 if (result == null) result = caseETypedElement(eOperation); 207 if (result == null) result = caseENamedElement(eOperation); 208 if (result == null) result = caseEModelElement(eOperation); 209 if (result == null) result = defaultCase(theEObject); 210 return result; 211 } 212 case EcorePackage.EPACKAGE: 213 { 214 EPackage ePackage = (EPackage)theEObject; 215 Object result = caseEPackage(ePackage); 216 if (result == null) result = caseENamedElement(ePackage); 217 if (result == null) result = caseEModelElement(ePackage); 218 if (result == null) result = defaultCase(theEObject); 219 return result; 220 } 221 case EcorePackage.EPARAMETER: 222 { 223 EParameter eParameter = (EParameter)theEObject; 224 Object result = caseEParameter(eParameter); 225 if (result == null) result = caseETypedElement(eParameter); 226 if (result == null) result = caseENamedElement(eParameter); 227 if (result == null) result = caseEModelElement(eParameter); 228 if (result == null) result = defaultCase(theEObject); 229 return result; 230 } 231 case EcorePackage.EREFERENCE: 232 { 233 EReference eReference = (EReference)theEObject; 234 Object result = caseEReference(eReference); 235 if (result == null) result = caseEStructuralFeature(eReference); 236 if (result == null) result = caseETypedElement(eReference); 237 if (result == null) result = caseENamedElement(eReference); 238 if (result == null) result = caseEModelElement(eReference); 239 if (result == null) result = defaultCase(theEObject); 240 return result; 241 } 242 case EcorePackage.ESTRUCTURAL_FEATURE: 243 { 244 EStructuralFeature eStructuralFeature = (EStructuralFeature)theEObject; 245 Object result = caseEStructuralFeature(eStructuralFeature); 246 if (result == null) result = caseETypedElement(eStructuralFeature); 247 if (result == null) result = caseENamedElement(eStructuralFeature); 248 if (result == null) result = caseEModelElement(eStructuralFeature); 249 if (result == null) result = defaultCase(theEObject); 250 return result; 251 } 252 case EcorePackage.ETYPED_ELEMENT: 253 { 254 ETypedElement eTypedElement = (ETypedElement)theEObject; 255 Object result = caseETypedElement(eTypedElement); 256 if (result == null) result = caseENamedElement(eTypedElement); 257 if (result == null) result = caseEModelElement(eTypedElement); 258 if (result == null) result = defaultCase(theEObject); 259 return result; 260 } 261 case EcorePackage.ESTRING_TO_STRING_MAP_ENTRY: 262 { 263 Map.Entry eStringToStringMapEntry = (Map.Entry )theEObject; 264 Object result = caseEStringToStringMapEntry(eStringToStringMapEntry); 265 if (result == null) result = defaultCase(theEObject); 266 return result; 267 } 268 default: return defaultCase(theEObject); 269 } 270 } 271 272 283 public Object caseEModelElement(EModelElement object) 284 { 285 return null; 286 } 287 288 299 public Object caseEStructuralFeature(EStructuralFeature object) 300 { 301 return null; 302 } 303 304 315 public Object caseEAnnotation(EAnnotation object) 316 { 317 return null; 318 } 319 320 331 public Object caseEAttribute(EAttribute object) 332 { 333 return null; 334 } 335 336 347 public Object caseEClass(EClass object) 348 { 349 return null; 350 } 351 352 363 public Object caseEDataType(EDataType object) 364 { 365 return null; 366 } 367 368 379 public Object caseEClassifier(EClassifier object) 380 { 381 return null; 382 } 383 384 395 public Object caseENamedElement(ENamedElement object) 396 { 397 return null; 398 } 399 400 411 public Object defaultCase(EObject object) 412 { 413 return null; 414 } 415 416 427 public Object caseETypedElement(ETypedElement object) 428 { 429 return null; 430 } 431 432 443 public Object caseEParameter(EParameter object) 444 { 445 return null; 446 } 447 448 459 public Object caseEOperation(EOperation object) 460 { 461 return null; 462 } 463 464 475 public Object caseEPackage(EPackage object) 476 { 477 return null; 478 } 479 480 491 public Object caseEFactory(EFactory object) 492 { 493 return null; 494 } 495 496 507 public Object caseEEnumLiteral(EEnumLiteral object) 508 { 509 return null; 510 } 511 512 523 public Object caseEEnum(EEnum object) 524 { 525 return null; 526 } 527 528 539 public Object caseEReference(EReference object) 540 { 541 return null; 542 } 543 544 555 public Object caseEStringToStringMapEntry(Map.Entry object) 556 { 557 return null; 558 } 559 560 } | Popular Tags |