/** * Copyright (c) 2012-2016 Marsha Chechik, Alessio Di Sandro, Michalis Famelis, * Rick Salay. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Alessio Di Sandro - Implementation. */ package edu.toronto.cs.se.modelepedia.icse15_sequencediagram_mavo.impl; import edu.toronto.cs.se.mavo.impl.MAVOReferenceImpl; import edu.toronto.cs.se.modelepedia.icse15_sequencediagram_mavo.ICSE15_SequenceDiagram_MAVOPackage; import edu.toronto.cs.se.modelepedia.icse15_sequencediagram_mavo.Lifeline; import edu.toronto.cs.se.modelepedia.icse15_sequencediagram_mavo.Message; import edu.toronto.cs.se.modelepedia.icse15_sequencediagram_mavo.SourceLifelineReference; 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.InternalEObject; import org.eclipse.emf.ecore.impl.ENotificationImpl; import org.eclipse.emf.ecore.util.EcoreUtil; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>Source Lifeline Reference</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * </p> * <ul> * <li>{@link edu.toronto.cs.se.modelepedia.icse15_sequencediagram_mavo.impl.SourceLifelineReferenceImpl#getSource <em>Source</em>}</li> * <li>{@link edu.toronto.cs.se.modelepedia.icse15_sequencediagram_mavo.impl.SourceLifelineReferenceImpl#getTarget <em>Target</em>}</li> * </ul> * * @generated */ public class SourceLifelineReferenceImpl extends MAVOReferenceImpl implements SourceLifelineReference { /** * The cached value of the '{@link #getTarget() <em>Target</em>}' reference. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getTarget() * @generated * @ordered */ protected Lifeline target; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected SourceLifelineReferenceImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return ICSE15_SequenceDiagram_MAVOPackage.Literals.SOURCE_LIFELINE_REFERENCE; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Message getSource() { if (eContainerFeatureID() != ICSE15_SequenceDiagram_MAVOPackage.SOURCE_LIFELINE_REFERENCE__SOURCE) return null; return (Message)eInternalContainer(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain basicSetSource(Message newSource, NotificationChain msgs) { msgs = eBasicSetContainer((InternalEObject)newSource, ICSE15_SequenceDiagram_MAVOPackage.SOURCE_LIFELINE_REFERENCE__SOURCE, msgs); return msgs; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setSource(Message newSource) { if (newSource != eInternalContainer() || (eContainerFeatureID() != ICSE15_SequenceDiagram_MAVOPackage.SOURCE_LIFELINE_REFERENCE__SOURCE && newSource != null)) { if (EcoreUtil.isAncestor(this, newSource)) throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); NotificationChain msgs = null; if (eInternalContainer() != null) msgs = eBasicRemoveFromContainer(msgs); if (newSource != null) msgs = ((InternalEObject)newSource).eInverseAdd(this, ICSE15_SequenceDiagram_MAVOPackage.MESSAGE__SOURCE_LIFELINE, Message.class, msgs); msgs = basicSetSource(newSource, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, ICSE15_SequenceDiagram_MAVOPackage.SOURCE_LIFELINE_REFERENCE__SOURCE, newSource, newSource)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Lifeline getTarget() { if (target != null && target.eIsProxy()) { InternalEObject oldTarget = (InternalEObject)target; target = (Lifeline)eResolveProxy(oldTarget); if (target != oldTarget) { if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.RESOLVE, ICSE15_SequenceDiagram_MAVOPackage.SOURCE_LIFELINE_REFERENCE__TARGET, oldTarget, target)); } } return target; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Lifeline basicGetTarget() { return target; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain basicSetTarget(Lifeline newTarget, NotificationChain msgs) { Lifeline oldTarget = target; target = newTarget; if (eNotificationRequired()) { ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ICSE15_SequenceDiagram_MAVOPackage.SOURCE_LIFELINE_REFERENCE__TARGET, oldTarget, newTarget); if (msgs == null) msgs = notification; else msgs.add(notification); } return msgs; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setTarget(Lifeline newTarget) { if (newTarget != target) { NotificationChain msgs = null; if (target != null) msgs = ((InternalEObject)target).eInverseRemove(this, ICSE15_SequenceDiagram_MAVOPackage.LIFELINE__MESSAGES_AS_SOURCE, Lifeline.class, msgs); if (newTarget != null) msgs = ((InternalEObject)newTarget).eInverseAdd(this, ICSE15_SequenceDiagram_MAVOPackage.LIFELINE__MESSAGES_AS_SOURCE, Lifeline.class, msgs); msgs = basicSetTarget(newTarget, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, ICSE15_SequenceDiagram_MAVOPackage.SOURCE_LIFELINE_REFERENCE__TARGET, newTarget, newTarget)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case ICSE15_SequenceDiagram_MAVOPackage.SOURCE_LIFELINE_REFERENCE__SOURCE: if (eInternalContainer() != null) msgs = eBasicRemoveFromContainer(msgs); return basicSetSource((Message)otherEnd, msgs); case ICSE15_SequenceDiagram_MAVOPackage.SOURCE_LIFELINE_REFERENCE__TARGET: if (target != null) msgs = ((InternalEObject)target).eInverseRemove(this, ICSE15_SequenceDiagram_MAVOPackage.LIFELINE__MESSAGES_AS_SOURCE, Lifeline.class, msgs); return basicSetTarget((Lifeline)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 ICSE15_SequenceDiagram_MAVOPackage.SOURCE_LIFELINE_REFERENCE__SOURCE: return basicSetSource(null, msgs); case ICSE15_SequenceDiagram_MAVOPackage.SOURCE_LIFELINE_REFERENCE__TARGET: return basicSetTarget(null, msgs); } return super.eInverseRemove(otherEnd, featureID, msgs); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { switch (eContainerFeatureID()) { case ICSE15_SequenceDiagram_MAVOPackage.SOURCE_LIFELINE_REFERENCE__SOURCE: return eInternalContainer().eInverseRemove(this, ICSE15_SequenceDiagram_MAVOPackage.MESSAGE__SOURCE_LIFELINE, Message.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 ICSE15_SequenceDiagram_MAVOPackage.SOURCE_LIFELINE_REFERENCE__SOURCE: return getSource(); case ICSE15_SequenceDiagram_MAVOPackage.SOURCE_LIFELINE_REFERENCE__TARGET: if (resolve) return getTarget(); return basicGetTarget(); } return super.eGet(featureID, resolve, coreType); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eSet(int featureID, Object newValue) { switch (featureID) { case ICSE15_SequenceDiagram_MAVOPackage.SOURCE_LIFELINE_REFERENCE__SOURCE: setSource((Message)newValue); return; case ICSE15_SequenceDiagram_MAVOPackage.SOURCE_LIFELINE_REFERENCE__TARGET: setTarget((Lifeline)newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case ICSE15_SequenceDiagram_MAVOPackage.SOURCE_LIFELINE_REFERENCE__SOURCE: setSource((Message)null); return; case ICSE15_SequenceDiagram_MAVOPackage.SOURCE_LIFELINE_REFERENCE__TARGET: setTarget((Lifeline)null); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case ICSE15_SequenceDiagram_MAVOPackage.SOURCE_LIFELINE_REFERENCE__SOURCE: return getSource() != null; case ICSE15_SequenceDiagram_MAVOPackage.SOURCE_LIFELINE_REFERENCE__TARGET: return target != null; } return super.eIsSet(featureID); } } //SourceLifelineReferenceImpl