1 17 package org.eclipse.emf.mapping.ecore2ecore.util; 18 19 20 import java.util.List ; 21 22 import org.eclipse.emf.ecore.EClass; 23 import org.eclipse.emf.ecore.EObject; 24 25 import org.eclipse.emf.mapping.Mapping; 26 import org.eclipse.emf.mapping.MappingRoot; 27 28 import org.eclipse.emf.mapping.ecore2ecore.*; 29 30 31 44 public class Ecore2EcoreSwitch { 45 51 protected static Ecore2EcorePackage modelPackage; 52 53 59 public Ecore2EcoreSwitch() 60 { 61 if (modelPackage == null) 62 { 63 modelPackage = Ecore2EcorePackage.eINSTANCE; 64 } 65 } 66 67 74 public Object doSwitch(EObject theEObject) 75 { 76 return doSwitch(theEObject.eClass(), theEObject); 77 } 78 79 86 protected Object doSwitch(EClass theEClass, EObject theEObject) 87 { 88 if (theEClass.eContainer() == modelPackage) 89 { 90 return doSwitch(theEClass.getClassifierID(), theEObject); 91 } 92 else 93 { 94 List eSuperTypes = theEClass.getESuperTypes(); 95 return 96 eSuperTypes.isEmpty() ? 97 defaultCase(theEObject) : 98 doSwitch((EClass)eSuperTypes.get(0), theEObject); 99 } 100 } 101 102 109 protected Object doSwitch(int classifierID, EObject theEObject) 110 { 111 switch (classifierID) 112 { 113 case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT: 114 { 115 Ecore2EcoreMappingRoot ecore2EcoreMappingRoot = (Ecore2EcoreMappingRoot)theEObject; 116 Object result = caseEcore2EcoreMappingRoot(ecore2EcoreMappingRoot); 117 if (result == null) result = caseMappingRoot(ecore2EcoreMappingRoot); 118 if (result == null) result = caseMapping(ecore2EcoreMappingRoot); 119 if (result == null) result = defaultCase(theEObject); 120 return result; 121 } 122 default: return defaultCase(theEObject); 123 } 124 } 125 126 137 public Object caseEcore2EcoreMappingRoot(Ecore2EcoreMappingRoot object) 138 { 139 return null; 140 } 141 142 153 public Object caseMapping(Mapping object) 154 { 155 return null; 156 } 157 158 169 public Object caseMappingRoot(MappingRoot object) 170 { 171 return null; 172 } 173 174 185 public Object defaultCase(EObject object) 186 { 187 return null; 188 } 189 190 } | Popular Tags |