/** * <copyright> * </copyright> * * $Id: PAnnotatedEModelElementImpl.java,v 1.8 2008/01/29 12:58:06 mtaal Exp $ */ package org.eclipse.emf.teneo.annotations.pamodel.impl; import java.util.ArrayList; import java.util.List; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.notify.NotificationChain; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.ENamedElement; import org.eclipse.emf.ecore.InternalEObject; import org.eclipse.emf.ecore.impl.ENotificationImpl; import org.eclipse.emf.ecore.impl.EObjectImpl; import org.eclipse.emf.teneo.annotations.pamodel.PAnnotatedEModelElement; import org.eclipse.emf.teneo.annotations.pamodel.PamodelPackage; import org.eclipse.emf.teneo.annotations.pannotation.PAnnotation; import org.eclipse.emf.teneo.annotations.pannotation.Transient; /** * <!-- begin-user-doc --> An implementation of the model object '<em><b>PAnnotated EModel Element</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * <ul> * <li>{@link org.eclipse.emf.teneo.annotations.pamodel.impl.PAnnotatedEModelElementImpl#getModelElement <em>Model Element</em>}</li> * <li>{@link org.eclipse.emf.teneo.annotations.pamodel.impl.PAnnotatedEModelElementImpl#getTransient <em>Transient</em>}</li> * </ul> * </p> * * @generated */ public abstract class PAnnotatedEModelElementImpl extends EObjectImpl implements PAnnotatedEModelElement { /** * The cached value of the '{@link #getModelElement() <em>Model Element</em>}' reference. <!-- * begin-user-doc --> <!-- end-user-doc --> * * @see #getModelElement() * @generated * @ordered */ protected ENamedElement modelElement; /** * The cached value of the '{@link #getTransient() <em>Transient</em>}' containment reference. * <!-- begin-user-doc --> <!-- end-user-doc --> * @see #getTransient() * @generated * @ordered */ protected Transient transient_; /** * <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ protected PAnnotatedEModelElementImpl() { super(); } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return PamodelPackage.Literals.PANNOTATED_EMODEL_ELEMENT; } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ public ENamedElement getModelElement() { if (modelElement != null && modelElement.eIsProxy()) { InternalEObject oldModelElement = (InternalEObject)modelElement; modelElement = (ENamedElement)eResolveProxy(oldModelElement); if (modelElement != oldModelElement) { if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.RESOLVE, PamodelPackage.PANNOTATED_EMODEL_ELEMENT__MODEL_ELEMENT, oldModelElement, modelElement)); } } return modelElement; } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ public ENamedElement basicGetModelElement() { return modelElement; } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ public void setModelElement(ENamedElement newModelElement) { ENamedElement oldModelElement = modelElement; modelElement = newModelElement; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, PamodelPackage.PANNOTATED_EMODEL_ELEMENT__MODEL_ELEMENT, oldModelElement, modelElement)); } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ public Transient getTransient() { return transient_; } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ public NotificationChain basicSetTransient(Transient newTransient, NotificationChain msgs) { Transient oldTransient = transient_; transient_ = newTransient; if (eNotificationRequired()) { ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, PamodelPackage.PANNOTATED_EMODEL_ELEMENT__TRANSIENT, oldTransient, newTransient); if (msgs == null) msgs = notification; else msgs.add(notification); } return msgs; } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ public void setTransient(Transient newTransient) { if (newTransient != transient_) { NotificationChain msgs = null; if (transient_ != null) msgs = ((InternalEObject)transient_).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - PamodelPackage.PANNOTATED_EMODEL_ELEMENT__TRANSIENT, null, msgs); if (newTransient != null) msgs = ((InternalEObject)newTransient).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - PamodelPackage.PANNOTATED_EMODEL_ELEMENT__TRANSIENT, null, msgs); msgs = basicSetTransient(newTransient, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, PamodelPackage.PANNOTATED_EMODEL_ELEMENT__TRANSIENT, newTransient, newTransient)); } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case PamodelPackage.PANNOTATED_EMODEL_ELEMENT__TRANSIENT: return basicSetTransient(null, msgs); } return super.eInverseRemove(otherEnd, featureID, msgs); } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ @Override public Object eGet(int featureID, boolean resolve, boolean coreType) { switch (featureID) { case PamodelPackage.PANNOTATED_EMODEL_ELEMENT__MODEL_ELEMENT: if (resolve) return getModelElement(); return basicGetModelElement(); case PamodelPackage.PANNOTATED_EMODEL_ELEMENT__TRANSIENT: return getTransient(); } return super.eGet(featureID, resolve, coreType); } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ @Override public void eSet(int featureID, Object newValue) { switch (featureID) { case PamodelPackage.PANNOTATED_EMODEL_ELEMENT__MODEL_ELEMENT: setModelElement((ENamedElement)newValue); return; case PamodelPackage.PANNOTATED_EMODEL_ELEMENT__TRANSIENT: setTransient((Transient)newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case PamodelPackage.PANNOTATED_EMODEL_ELEMENT__MODEL_ELEMENT: setModelElement((ENamedElement)null); return; case PamodelPackage.PANNOTATED_EMODEL_ELEMENT__TRANSIENT: setTransient((Transient)null); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case PamodelPackage.PANNOTATED_EMODEL_ELEMENT__MODEL_ELEMENT: return modelElement != null; case PamodelPackage.PANNOTATED_EMODEL_ELEMENT__TRANSIENT: return transient_ != null; } return super.eIsSet(featureID); } /** * {@inheritDoc } */ public List<PAnnotation> getAnnotations() { // TODO implement as wrapper on eContents? List<PAnnotation> annotations = new ArrayList<PAnnotation>(); for (Object x : eContents()) { if (x instanceof PAnnotation) { annotations.add((PAnnotation) x); } } return annotations; } /** * Overridden to provide type info * * @see org.eclipse.emf.ecore.impl.BasicEObjectImpl#toString() */ @Override public String toString() { ENamedElement em = getModelElement(); return em.eClass().getName() + "/" + em.getName(); } } // PAnnotatedEModelElementImpl