/** * <copyright> * </copyright> * * $Id$ */ package org.eclipse.gmf.mappings.impl; import java.util.Collection; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.notify.NotificationChain; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.InternalEObject; import org.eclipse.emf.ecore.impl.ENotificationImpl; import org.eclipse.emf.ecore.impl.EObjectImpl; import org.eclipse.emf.ecore.util.EObjectWithInverseResolvingEList; import org.eclipse.emf.ecore.util.InternalEList; import org.eclipse.gmf.gmfgraph.Compartment; import org.eclipse.gmf.mappings.ChildReference; import org.eclipse.gmf.mappings.CompartmentMapping; import org.eclipse.gmf.mappings.GMFMapPackage; import org.eclipse.gmf.mappings.NodeMapping; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>Compartment Mapping</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * <ul> * <li>{@link org.eclipse.gmf.mappings.impl.CompartmentMappingImpl#getCompartment <em>Compartment</em>}</li> * <li>{@link org.eclipse.gmf.mappings.impl.CompartmentMappingImpl#getParentNode <em>Parent Node</em>}</li> * <li>{@link org.eclipse.gmf.mappings.impl.CompartmentMappingImpl#getChildren <em>Children</em>}</li> * </ul> * </p> * * @generated */ public class CompartmentMappingImpl extends EObjectImpl implements CompartmentMapping { /** * The cached value of the '{@link #getCompartment() <em>Compartment</em>}' reference. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getCompartment() * @generated * @ordered */ protected Compartment compartment; /** * The cached value of the '{@link #getChildren() <em>Children</em>}' reference list. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getChildren() * @generated * @ordered */ protected EList<ChildReference> children; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected CompartmentMappingImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return GMFMapPackage.eINSTANCE.getCompartmentMapping(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Compartment getCompartment() { if (compartment != null && compartment.eIsProxy()) { InternalEObject oldCompartment = (InternalEObject)compartment; compartment = (Compartment)eResolveProxy(oldCompartment); if (compartment != oldCompartment) { if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.RESOLVE, GMFMapPackage.COMPARTMENT_MAPPING__COMPARTMENT, oldCompartment, compartment)); } } return compartment; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Compartment basicGetCompartment() { return compartment; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setCompartment(Compartment newCompartment) { Compartment oldCompartment = compartment; compartment = newCompartment; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, GMFMapPackage.COMPARTMENT_MAPPING__COMPARTMENT, oldCompartment, compartment)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NodeMapping getParentNode() { if (eContainerFeatureID() != GMFMapPackage.COMPARTMENT_MAPPING__PARENT_NODE) return null; return (NodeMapping)eContainer(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EList<ChildReference> getChildren() { if (children == null) { children = new EObjectWithInverseResolvingEList<ChildReference>(ChildReference.class, this, GMFMapPackage.COMPARTMENT_MAPPING__CHILDREN, GMFMapPackage.CHILD_REFERENCE__COMPARTMENT); } return children; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @SuppressWarnings("unchecked") @Override public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case GMFMapPackage.COMPARTMENT_MAPPING__PARENT_NODE: if (eInternalContainer() != null) msgs = eBasicRemoveFromContainer(msgs); return eBasicSetContainer(otherEnd, GMFMapPackage.COMPARTMENT_MAPPING__PARENT_NODE, msgs); case GMFMapPackage.COMPARTMENT_MAPPING__CHILDREN: return ((InternalEList<InternalEObject>)(InternalEList<?>)getChildren()).basicAdd(otherEnd, msgs); } return super.eInverseAdd(otherEnd, featureID, msgs); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case GMFMapPackage.COMPARTMENT_MAPPING__PARENT_NODE: return eBasicSetContainer(null, GMFMapPackage.COMPARTMENT_MAPPING__PARENT_NODE, msgs); case GMFMapPackage.COMPARTMENT_MAPPING__CHILDREN: return ((InternalEList<?>)getChildren()).basicRemove(otherEnd, msgs); } return super.eInverseRemove(otherEnd, featureID, msgs); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { switch (eContainerFeatureID()) { case GMFMapPackage.COMPARTMENT_MAPPING__PARENT_NODE: return eInternalContainer().eInverseRemove(this, GMFMapPackage.NODE_MAPPING__COMPARTMENTS, NodeMapping.class, msgs); } return super.eBasicRemoveFromContainerFeature(msgs); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Object eGet(int featureID, boolean resolve, boolean coreType) { switch (featureID) { case GMFMapPackage.COMPARTMENT_MAPPING__COMPARTMENT: if (resolve) return getCompartment(); return basicGetCompartment(); case GMFMapPackage.COMPARTMENT_MAPPING__PARENT_NODE: return getParentNode(); case GMFMapPackage.COMPARTMENT_MAPPING__CHILDREN: return getChildren(); } return super.eGet(featureID, resolve, coreType); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @SuppressWarnings("unchecked") @Override public void eSet(int featureID, Object newValue) { switch (featureID) { case GMFMapPackage.COMPARTMENT_MAPPING__COMPARTMENT: setCompartment((Compartment)newValue); return; case GMFMapPackage.COMPARTMENT_MAPPING__CHILDREN: getChildren().clear(); getChildren().addAll((Collection<? extends ChildReference>)newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case GMFMapPackage.COMPARTMENT_MAPPING__COMPARTMENT: setCompartment((Compartment)null); return; case GMFMapPackage.COMPARTMENT_MAPPING__CHILDREN: getChildren().clear(); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case GMFMapPackage.COMPARTMENT_MAPPING__COMPARTMENT: return compartment != null; case GMFMapPackage.COMPARTMENT_MAPPING__PARENT_NODE: return getParentNode() != null; case GMFMapPackage.COMPARTMENT_MAPPING__CHILDREN: return children != null && !children.isEmpty(); } return super.eIsSet(featureID); } } //CompartmentMappingImpl