1 17 package org.eclipse.emf.mapping.impl; 18 19 20 import java.util.Collection ; 21 22 import org.eclipse.emf.common.notify.Notification; 23 import org.eclipse.emf.common.notify.NotificationChain; 24 import org.eclipse.emf.common.util.EList; 25 import org.eclipse.emf.ecore.EClass; 26 import org.eclipse.emf.ecore.EObject; 27 import org.eclipse.emf.ecore.EStructuralFeature; 28 import org.eclipse.emf.ecore.InternalEObject; 29 import org.eclipse.emf.ecore.impl.ENotificationImpl; 30 import org.eclipse.emf.ecore.impl.EObjectImpl; 31 import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; 32 import org.eclipse.emf.ecore.util.EcoreUtil; 33 import org.eclipse.emf.ecore.util.InternalEList; 34 import org.eclipse.emf.mapping.Mapping; 35 import org.eclipse.emf.mapping.MappingHelper; 36 import org.eclipse.emf.mapping.MappingPackage; 37 38 39 55 public class MappingHelperImpl extends EObjectImpl implements MappingHelper 56 { 57 65 protected EObject helpedObject = null; 66 67 75 protected EList nested = null; 76 77 82 protected MappingHelperImpl() 83 { 84 super(); 85 } 86 87 92 protected EClass eStaticClass() 93 { 94 return MappingPackage.eINSTANCE.getMappingHelper(); 95 } 96 97 102 public Mapping getMapper() 103 { 104 if (eContainerFeatureID != MappingPackage.MAPPING_HELPER__MAPPER) return null; 105 return (Mapping)eContainer; 106 } 107 108 113 public void setMapper(Mapping newMapper) 114 { 115 if (newMapper != eContainer || (eContainerFeatureID != MappingPackage.MAPPING_HELPER__MAPPER && newMapper != null)) 116 { 117 if (EcoreUtil.isAncestor(this, newMapper)) 118 throw new IllegalArgumentException ("Recursive containment not allowed for " + toString()); 119 NotificationChain msgs = null; 120 if (eContainer != null) 121 msgs = eBasicRemoveFromContainer(msgs); 122 if (newMapper != null) 123 msgs = ((InternalEObject)newMapper).eInverseAdd(this, MappingPackage.MAPPING__HELPER, Mapping.class, msgs); 124 msgs = eBasicSetContainer((InternalEObject)newMapper, MappingPackage.MAPPING_HELPER__MAPPER, msgs); 125 if (msgs != null) msgs.dispatch(); 126 } 127 else if (eNotificationRequired()) 128 eNotify(new ENotificationImpl(this, Notification.SET, MappingPackage.MAPPING_HELPER__MAPPER, newMapper, newMapper)); 129 } 130 131 136 public EObject getHelpedObject() 137 { 138 if (helpedObject != null && helpedObject.eIsProxy()) 139 { 140 EObject oldHelpedObject = helpedObject; 141 helpedObject = (EObject)eResolveProxy((InternalEObject)helpedObject); 142 if (helpedObject != oldHelpedObject) 143 { 144 if (eNotificationRequired()) 145 eNotify(new ENotificationImpl(this, Notification.RESOLVE, MappingPackage.MAPPING_HELPER__HELPED_OBJECT, oldHelpedObject, helpedObject)); 146 } 147 } 148 return helpedObject; 149 } 150 151 156 public EObject basicGetHelpedObject() 157 { 158 return helpedObject; 159 } 160 161 166 public void setHelpedObject(EObject newHelpedObject) 167 { 168 EObject oldHelpedObject = helpedObject; 169 helpedObject = newHelpedObject; 170 if (eNotificationRequired()) 171 eNotify(new ENotificationImpl(this, Notification.SET, MappingPackage.MAPPING_HELPER__HELPED_OBJECT, oldHelpedObject, helpedObject)); 172 } 173 174 179 public MappingHelper getNestedIn() 180 { 181 if (eContainerFeatureID != MappingPackage.MAPPING_HELPER__NESTED_IN) return null; 182 return (MappingHelper)eContainer; 183 } 184 185 190 public void setNestedIn(MappingHelper newNestedIn) 191 { 192 if (newNestedIn != eContainer || (eContainerFeatureID != MappingPackage.MAPPING_HELPER__NESTED_IN && newNestedIn != null)) 193 { 194 if (EcoreUtil.isAncestor(this, newNestedIn)) 195 throw new IllegalArgumentException ("Recursive containment not allowed for " + toString()); 196 NotificationChain msgs = null; 197 if (eContainer != null) 198 msgs = eBasicRemoveFromContainer(msgs); 199 if (newNestedIn != null) 200 msgs = ((InternalEObject)newNestedIn).eInverseAdd(this, MappingPackage.MAPPING_HELPER__NESTED, MappingHelper.class, msgs); 201 msgs = eBasicSetContainer((InternalEObject)newNestedIn, MappingPackage.MAPPING_HELPER__NESTED_IN, msgs); 202 if (msgs != null) msgs.dispatch(); 203 } 204 else if (eNotificationRequired()) 205 eNotify(new ENotificationImpl(this, Notification.SET, MappingPackage.MAPPING_HELPER__NESTED_IN, newNestedIn, newNestedIn)); 206 } 207 208 213 public EList getNested() 214 { 215 if (nested == null) 216 { 217 nested = new EObjectContainmentWithInverseEList(MappingHelper.class, this, MappingPackage.MAPPING_HELPER__NESTED, MappingPackage.MAPPING_HELPER__NESTED_IN); 218 } 219 return nested; 220 } 221 222 227 public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) 228 { 229 if (featureID >= 0) 230 { 231 switch (eDerivedStructuralFeatureID(featureID, baseClass)) 232 { 233 case MappingPackage.MAPPING_HELPER__MAPPER: 234 if (eContainer != null) 235 msgs = eBasicRemoveFromContainer(msgs); 236 return eBasicSetContainer(otherEnd, MappingPackage.MAPPING_HELPER__MAPPER, msgs); 237 case MappingPackage.MAPPING_HELPER__NESTED_IN: 238 if (eContainer != null) 239 msgs = eBasicRemoveFromContainer(msgs); 240 return eBasicSetContainer(otherEnd, MappingPackage.MAPPING_HELPER__NESTED_IN, msgs); 241 case MappingPackage.MAPPING_HELPER__NESTED: 242 return ((InternalEList)getNested()).basicAdd(otherEnd, msgs); 243 default: 244 return eDynamicInverseAdd(otherEnd, featureID, baseClass, msgs); 245 } 246 } 247 if (eContainer != null) 248 msgs = eBasicRemoveFromContainer(msgs); 249 return eBasicSetContainer(otherEnd, featureID, msgs); 250 } 251 252 257 public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) 258 { 259 if (featureID >= 0) 260 { 261 switch (eDerivedStructuralFeatureID(featureID, baseClass)) 262 { 263 case MappingPackage.MAPPING_HELPER__MAPPER: 264 return eBasicSetContainer(null, MappingPackage.MAPPING_HELPER__MAPPER, msgs); 265 case MappingPackage.MAPPING_HELPER__NESTED_IN: 266 return eBasicSetContainer(null, MappingPackage.MAPPING_HELPER__NESTED_IN, msgs); 267 case MappingPackage.MAPPING_HELPER__NESTED: 268 return ((InternalEList)getNested()).basicRemove(otherEnd, msgs); 269 default: 270 return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs); 271 } 272 } 273 return eBasicSetContainer(null, featureID, msgs); 274 } 275 276 281 public NotificationChain eBasicRemoveFromContainer(NotificationChain msgs) 282 { 283 if (eContainerFeatureID >= 0) 284 { 285 switch (eContainerFeatureID) 286 { 287 case MappingPackage.MAPPING_HELPER__MAPPER: 288 return eContainer.eInverseRemove(this, MappingPackage.MAPPING__HELPER, Mapping.class, msgs); 289 case MappingPackage.MAPPING_HELPER__NESTED_IN: 290 return eContainer.eInverseRemove(this, MappingPackage.MAPPING_HELPER__NESTED, MappingHelper.class, msgs); 291 default: 292 return eDynamicBasicRemoveFromContainer(msgs); 293 } 294 } 295 return eContainer.eInverseRemove(this, EOPPOSITE_FEATURE_BASE - eContainerFeatureID, null, msgs); 296 } 297 298 303 public Object eGet(EStructuralFeature eFeature, boolean resolve) 304 { 305 switch (eDerivedStructuralFeatureID(eFeature)) 306 { 307 case MappingPackage.MAPPING_HELPER__MAPPER: 308 return getMapper(); 309 case MappingPackage.MAPPING_HELPER__HELPED_OBJECT: 310 if (resolve) return getHelpedObject(); 311 return basicGetHelpedObject(); 312 case MappingPackage.MAPPING_HELPER__NESTED_IN: 313 return getNestedIn(); 314 case MappingPackage.MAPPING_HELPER__NESTED: 315 return getNested(); 316 } 317 return eDynamicGet(eFeature, resolve); 318 } 319 320 325 public void eSet(EStructuralFeature eFeature, Object newValue) 326 { 327 switch (eDerivedStructuralFeatureID(eFeature)) 328 { 329 case MappingPackage.MAPPING_HELPER__MAPPER: 330 setMapper((Mapping)newValue); 331 return; 332 case MappingPackage.MAPPING_HELPER__HELPED_OBJECT: 333 setHelpedObject((EObject)newValue); 334 return; 335 case MappingPackage.MAPPING_HELPER__NESTED_IN: 336 setNestedIn((MappingHelper)newValue); 337 return; 338 case MappingPackage.MAPPING_HELPER__NESTED: 339 getNested().clear(); 340 getNested().addAll((Collection )newValue); 341 return; 342 } 343 eDynamicSet(eFeature, newValue); 344 } 345 346 351 public void eUnset(EStructuralFeature eFeature) 352 { 353 switch (eDerivedStructuralFeatureID(eFeature)) 354 { 355 case MappingPackage.MAPPING_HELPER__MAPPER: 356 setMapper((Mapping)null); 357 return; 358 case MappingPackage.MAPPING_HELPER__HELPED_OBJECT: 359 setHelpedObject((EObject)null); 360 return; 361 case MappingPackage.MAPPING_HELPER__NESTED_IN: 362 setNestedIn((MappingHelper)null); 363 return; 364 case MappingPackage.MAPPING_HELPER__NESTED: 365 getNested().clear(); 366 return; 367 } 368 eDynamicUnset(eFeature); 369 } 370 371 376 public boolean eIsSet(EStructuralFeature eFeature) 377 { 378 switch (eDerivedStructuralFeatureID(eFeature)) 379 { 380 case MappingPackage.MAPPING_HELPER__MAPPER: 381 return getMapper() != null; 382 case MappingPackage.MAPPING_HELPER__HELPED_OBJECT: 383 return helpedObject != null; 384 case MappingPackage.MAPPING_HELPER__NESTED_IN: 385 return getNestedIn() != null; 386 case MappingPackage.MAPPING_HELPER__NESTED: 387 return nested != null && !nested.isEmpty(); 388 } 389 return eDynamicIsSet(eFeature); 390 } 391 392 } 394 395 | Popular Tags |