/**
* <copyright>
* </copyright>
*
* $Id$
*/
package activityDiagram.impl;
import activityDiagram.Activity;
import activityDiagram.ActivityDiagramPackage;
import activityDiagram.ControlFlow;
import activityDiagram.Element;
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>Control Flow</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link activityDiagram.impl.ControlFlowImpl#getSource <em>Source</em>}</li>
* <li>{@link activityDiagram.impl.ControlFlowImpl#getTarget <em>Target</em>}</li>
* <li>{@link activityDiagram.impl.ControlFlowImpl#getCondition <em>Condition</em>}</li>
* <li>{@link activityDiagram.impl.ControlFlowImpl#getActivity <em>Activity</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class ControlFlowImpl extends ElementImpl implements ControlFlow {
/**
* The cached value of the '{@link #getSource() <em>Source</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getSource()
* @generated
* @ordered
*/
protected Element source;
/**
* The cached value of the '{@link #getTarget() <em>Target</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getTarget()
* @generated
* @ordered
*/
protected Element target;
/**
* The default value of the '{@link #getCondition() <em>Condition</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getCondition()
* @generated
* @ordered
*/
protected static final String CONDITION_EDEFAULT = null;
/**
* The cached value of the '{@link #getCondition() <em>Condition</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getCondition()
* @generated
* @ordered
*/
protected String condition = CONDITION_EDEFAULT;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected ControlFlowImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return ActivityDiagramPackage.Literals.CONTROL_FLOW;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Element getSource() {
if (source != null && source.eIsProxy()) {
InternalEObject oldSource = (InternalEObject)source;
source = (Element)eResolveProxy(oldSource);
if (source != oldSource) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, ActivityDiagramPackage.CONTROL_FLOW__SOURCE, oldSource, source));
}
}
return source;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Element basicGetSource() {
return source;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setSource(Element newSource) {
Element oldSource = source;
source = newSource;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ActivityDiagramPackage.CONTROL_FLOW__SOURCE, oldSource, source));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Element getTarget() {
if (target != null && target.eIsProxy()) {
InternalEObject oldTarget = (InternalEObject)target;
target = (Element)eResolveProxy(oldTarget);
if (target != oldTarget) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, ActivityDiagramPackage.CONTROL_FLOW__TARGET, oldTarget, target));
}
}
return target;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Element basicGetTarget() {
return target;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setTarget(Element newTarget) {
Element oldTarget = target;
target = newTarget;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ActivityDiagramPackage.CONTROL_FLOW__TARGET, oldTarget, target));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getCondition() {
return condition;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setCondition(String newCondition) {
String oldCondition = condition;
condition = newCondition;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ActivityDiagramPackage.CONTROL_FLOW__CONDITION, oldCondition, condition));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Activity getActivity() {
if (eContainerFeatureID() != ActivityDiagramPackage.CONTROL_FLOW__ACTIVITY) return null;
return (Activity)eContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetActivity(Activity newActivity, NotificationChain msgs) {
msgs = eBasicSetContainer((InternalEObject)newActivity, ActivityDiagramPackage.CONTROL_FLOW__ACTIVITY, msgs);
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setActivity(Activity newActivity) {
if (newActivity != eInternalContainer() || (eContainerFeatureID() != ActivityDiagramPackage.CONTROL_FLOW__ACTIVITY && newActivity != null)) {
if (EcoreUtil.isAncestor(this, newActivity))
throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
NotificationChain msgs = null;
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
if (newActivity != null)
msgs = ((InternalEObject)newActivity).eInverseAdd(this, ActivityDiagramPackage.ACTIVITY__FLOWS, Activity.class, msgs);
msgs = basicSetActivity(newActivity, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ActivityDiagramPackage.CONTROL_FLOW__ACTIVITY, newActivity, newActivity));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case ActivityDiagramPackage.CONTROL_FLOW__ACTIVITY:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetActivity((Activity)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 ActivityDiagramPackage.CONTROL_FLOW__ACTIVITY:
return basicSetActivity(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
switch (eContainerFeatureID()) {
case ActivityDiagramPackage.CONTROL_FLOW__ACTIVITY:
return eInternalContainer().eInverseRemove(this, ActivityDiagramPackage.ACTIVITY__FLOWS, Activity.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 ActivityDiagramPackage.CONTROL_FLOW__SOURCE:
if (resolve) return getSource();
return basicGetSource();
case ActivityDiagramPackage.CONTROL_FLOW__TARGET:
if (resolve) return getTarget();
return basicGetTarget();
case ActivityDiagramPackage.CONTROL_FLOW__CONDITION:
return getCondition();
case ActivityDiagramPackage.CONTROL_FLOW__ACTIVITY:
return getActivity();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case ActivityDiagramPackage.CONTROL_FLOW__SOURCE:
setSource((Element)newValue);
return;
case ActivityDiagramPackage.CONTROL_FLOW__TARGET:
setTarget((Element)newValue);
return;
case ActivityDiagramPackage.CONTROL_FLOW__CONDITION:
setCondition((String)newValue);
return;
case ActivityDiagramPackage.CONTROL_FLOW__ACTIVITY:
setActivity((Activity)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case ActivityDiagramPackage.CONTROL_FLOW__SOURCE:
setSource((Element)null);
return;
case ActivityDiagramPackage.CONTROL_FLOW__TARGET:
setTarget((Element)null);
return;
case ActivityDiagramPackage.CONTROL_FLOW__CONDITION:
setCondition(CONDITION_EDEFAULT);
return;
case ActivityDiagramPackage.CONTROL_FLOW__ACTIVITY:
setActivity((Activity)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case ActivityDiagramPackage.CONTROL_FLOW__SOURCE:
return source != null;
case ActivityDiagramPackage.CONTROL_FLOW__TARGET:
return target != null;
case ActivityDiagramPackage.CONTROL_FLOW__CONDITION:
return CONDITION_EDEFAULT == null ? condition != null : !CONDITION_EDEFAULT.equals(condition);
case ActivityDiagramPackage.CONTROL_FLOW__ACTIVITY:
return getActivity() != null;
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public String toString() {
if (eIsProxy()) return super.toString();
StringBuffer result = new StringBuffer(super.toString());
result.append(" (condition: ");
result.append(condition);
result.append(')');
return result.toString();
}
} //ControlFlowImpl