blob: d7c49fc2b8e7d7bf2f96d65c8f99788acb884754 [file] [log] [blame]
/**
*/
package org.eclipse.papyrus.bpmn.BPMNProfile.impl;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.BasicDiagnostic;
import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.emf.common.util.DiagnosticChain;
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.plugin.EcorePlugin;
import org.eclipse.emf.ecore.util.EObjectValidator;
import org.eclipse.papyrus.bpmn.BPMNProfile.AssociationDirection;
import org.eclipse.papyrus.bpmn.BPMNProfile.BPMNAssociation;
import org.eclipse.papyrus.bpmn.BPMNProfile.BPMNProfilePackage;
import org.eclipse.papyrus.bpmn.BPMNProfile.BaseElement;
import org.eclipse.papyrus.bpmn.BPMNProfile.util.BPMNProfileValidator;
import org.eclipse.uml2.uml.Dependency;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>BPMN Association</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.papyrus.bpmn.BPMNProfile.impl.BPMNAssociationImpl#getBase_Dependency <em>Base Dependency</em>}</li>
* <li>{@link org.eclipse.papyrus.bpmn.BPMNProfile.impl.BPMNAssociationImpl#getAssociationDirection <em>Association Direction</em>}</li>
* <li>{@link org.eclipse.papyrus.bpmn.BPMNProfile.impl.BPMNAssociationImpl#getTargetRef <em>Target Ref</em>}</li>
* <li>{@link org.eclipse.papyrus.bpmn.BPMNProfile.impl.BPMNAssociationImpl#getSourceRef <em>Source Ref</em>}</li>
* </ul>
*
* @generated
*/
public class BPMNAssociationImpl extends BPMNArtifactImpl implements BPMNAssociation {
/**
* The cached value of the '{@link #getBase_Dependency() <em>Base Dependency</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getBase_Dependency()
* @generated
* @ordered
*/
protected Dependency base_Dependency;
/**
* The default value of the '{@link #getAssociationDirection() <em>Association Direction</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getAssociationDirection()
* @generated
* @ordered
*/
protected static final AssociationDirection ASSOCIATION_DIRECTION_EDEFAULT = AssociationDirection.NONE;
/**
* The cached value of the '{@link #getAssociationDirection() <em>Association Direction</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getAssociationDirection()
* @generated
* @ordered
*/
protected AssociationDirection associationDirection = ASSOCIATION_DIRECTION_EDEFAULT;
/**
* The cached value of the '{@link #getTargetRef() <em>Target Ref</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getTargetRef()
* @generated
* @ordered
*/
protected BaseElement targetRef;
/**
* The cached value of the '{@link #getSourceRef() <em>Source Ref</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getSourceRef()
* @generated
* @ordered
*/
protected BaseElement sourceRef;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected BPMNAssociationImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return BPMNProfilePackage.eINSTANCE.getBPMNAssociation();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Dependency getBase_Dependency() {
if (base_Dependency != null && base_Dependency.eIsProxy()) {
InternalEObject oldBase_Dependency = (InternalEObject)base_Dependency;
base_Dependency = (Dependency)eResolveProxy(oldBase_Dependency);
if (base_Dependency != oldBase_Dependency) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, BPMNProfilePackage.BPMN_ASSOCIATION__BASE_DEPENDENCY, oldBase_Dependency, base_Dependency));
}
}
return base_Dependency;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Dependency basicGetBase_Dependency() {
return base_Dependency;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setBase_Dependency(Dependency newBase_Dependency) {
Dependency oldBase_Dependency = base_Dependency;
base_Dependency = newBase_Dependency;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, BPMNProfilePackage.BPMN_ASSOCIATION__BASE_DEPENDENCY, oldBase_Dependency, base_Dependency));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public AssociationDirection getAssociationDirection() {
return associationDirection;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setAssociationDirection(AssociationDirection newAssociationDirection) {
AssociationDirection oldAssociationDirection = associationDirection;
associationDirection = newAssociationDirection == null ? ASSOCIATION_DIRECTION_EDEFAULT : newAssociationDirection;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, BPMNProfilePackage.BPMN_ASSOCIATION__ASSOCIATION_DIRECTION, oldAssociationDirection, associationDirection));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public BaseElement getTargetRef() {
if (targetRef != null && targetRef.eIsProxy()) {
InternalEObject oldTargetRef = (InternalEObject)targetRef;
targetRef = (BaseElement)eResolveProxy(oldTargetRef);
if (targetRef != oldTargetRef) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, BPMNProfilePackage.BPMN_ASSOCIATION__TARGET_REF, oldTargetRef, targetRef));
}
}
return targetRef;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public BaseElement basicGetTargetRef() {
return targetRef;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetTargetRef(BaseElement newTargetRef, NotificationChain msgs) {
BaseElement oldTargetRef = targetRef;
targetRef = newTargetRef;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, BPMNProfilePackage.BPMN_ASSOCIATION__TARGET_REF, oldTargetRef, newTargetRef);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setTargetRef(BaseElement newTargetRef) {
if (newTargetRef != targetRef) {
NotificationChain msgs = null;
if (targetRef != null)
msgs = ((InternalEObject)targetRef).eInverseRemove(this, BPMNProfilePackage.BASE_ELEMENT__INCOMING, BaseElement.class, msgs);
if (newTargetRef != null)
msgs = ((InternalEObject)newTargetRef).eInverseAdd(this, BPMNProfilePackage.BASE_ELEMENT__INCOMING, BaseElement.class, msgs);
msgs = basicSetTargetRef(newTargetRef, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, BPMNProfilePackage.BPMN_ASSOCIATION__TARGET_REF, newTargetRef, newTargetRef));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public BaseElement getSourceRef() {
if (sourceRef != null && sourceRef.eIsProxy()) {
InternalEObject oldSourceRef = (InternalEObject)sourceRef;
sourceRef = (BaseElement)eResolveProxy(oldSourceRef);
if (sourceRef != oldSourceRef) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, BPMNProfilePackage.BPMN_ASSOCIATION__SOURCE_REF, oldSourceRef, sourceRef));
}
}
return sourceRef;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public BaseElement basicGetSourceRef() {
return sourceRef;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetSourceRef(BaseElement newSourceRef, NotificationChain msgs) {
BaseElement oldSourceRef = sourceRef;
sourceRef = newSourceRef;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, BPMNProfilePackage.BPMN_ASSOCIATION__SOURCE_REF, oldSourceRef, newSourceRef);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setSourceRef(BaseElement newSourceRef) {
if (newSourceRef != sourceRef) {
NotificationChain msgs = null;
if (sourceRef != null)
msgs = ((InternalEObject)sourceRef).eInverseRemove(this, BPMNProfilePackage.BASE_ELEMENT__OUTGOING, BaseElement.class, msgs);
if (newSourceRef != null)
msgs = ((InternalEObject)newSourceRef).eInverseAdd(this, BPMNProfilePackage.BASE_ELEMENT__OUTGOING, BaseElement.class, msgs);
msgs = basicSetSourceRef(newSourceRef, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, BPMNProfilePackage.BPMN_ASSOCIATION__SOURCE_REF, newSourceRef, newSourceRef));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public boolean AssociationEnd(DiagnosticChain diagnostics, Map<Object, Object> context) {
// TODO: implement this method
// -> specify the condition that violates the invariant
// -> verify the details of the diagnostic, including severity and message
// Ensure that you remove @generated or mark it @generated NOT
if (false) {
if (diagnostics != null) {
diagnostics.add
(new BasicDiagnostic
(Diagnostic.ERROR,
BPMNProfileValidator.DIAGNOSTIC_SOURCE,
BPMNProfileValidator.BPMN_ASSOCIATION__ASSOCIATION_END,
EcorePlugin.INSTANCE.getString("_UI_GenericInvariant_diagnostic", new Object[] { "AssociationEnd", EObjectValidator.getObjectLabel(this, context) }),
new Object [] { this }));
}
return false;
}
return true;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case BPMNProfilePackage.BPMN_ASSOCIATION__TARGET_REF:
if (targetRef != null)
msgs = ((InternalEObject)targetRef).eInverseRemove(this, BPMNProfilePackage.BASE_ELEMENT__INCOMING, BaseElement.class, msgs);
return basicSetTargetRef((BaseElement)otherEnd, msgs);
case BPMNProfilePackage.BPMN_ASSOCIATION__SOURCE_REF:
if (sourceRef != null)
msgs = ((InternalEObject)sourceRef).eInverseRemove(this, BPMNProfilePackage.BASE_ELEMENT__OUTGOING, BaseElement.class, msgs);
return basicSetSourceRef((BaseElement)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 BPMNProfilePackage.BPMN_ASSOCIATION__TARGET_REF:
return basicSetTargetRef(null, msgs);
case BPMNProfilePackage.BPMN_ASSOCIATION__SOURCE_REF:
return basicSetSourceRef(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 BPMNProfilePackage.BPMN_ASSOCIATION__BASE_DEPENDENCY:
if (resolve) return getBase_Dependency();
return basicGetBase_Dependency();
case BPMNProfilePackage.BPMN_ASSOCIATION__ASSOCIATION_DIRECTION:
return getAssociationDirection();
case BPMNProfilePackage.BPMN_ASSOCIATION__TARGET_REF:
if (resolve) return getTargetRef();
return basicGetTargetRef();
case BPMNProfilePackage.BPMN_ASSOCIATION__SOURCE_REF:
if (resolve) return getSourceRef();
return basicGetSourceRef();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case BPMNProfilePackage.BPMN_ASSOCIATION__BASE_DEPENDENCY:
setBase_Dependency((Dependency)newValue);
return;
case BPMNProfilePackage.BPMN_ASSOCIATION__ASSOCIATION_DIRECTION:
setAssociationDirection((AssociationDirection)newValue);
return;
case BPMNProfilePackage.BPMN_ASSOCIATION__TARGET_REF:
setTargetRef((BaseElement)newValue);
return;
case BPMNProfilePackage.BPMN_ASSOCIATION__SOURCE_REF:
setSourceRef((BaseElement)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case BPMNProfilePackage.BPMN_ASSOCIATION__BASE_DEPENDENCY:
setBase_Dependency((Dependency)null);
return;
case BPMNProfilePackage.BPMN_ASSOCIATION__ASSOCIATION_DIRECTION:
setAssociationDirection(ASSOCIATION_DIRECTION_EDEFAULT);
return;
case BPMNProfilePackage.BPMN_ASSOCIATION__TARGET_REF:
setTargetRef((BaseElement)null);
return;
case BPMNProfilePackage.BPMN_ASSOCIATION__SOURCE_REF:
setSourceRef((BaseElement)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case BPMNProfilePackage.BPMN_ASSOCIATION__BASE_DEPENDENCY:
return base_Dependency != null;
case BPMNProfilePackage.BPMN_ASSOCIATION__ASSOCIATION_DIRECTION:
return associationDirection != ASSOCIATION_DIRECTION_EDEFAULT;
case BPMNProfilePackage.BPMN_ASSOCIATION__TARGET_REF:
return targetRef != null;
case BPMNProfilePackage.BPMN_ASSOCIATION__SOURCE_REF:
return sourceRef != null;
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
@SuppressWarnings("unchecked")
public Object eInvoke(int operationID, EList<?> arguments) throws InvocationTargetException {
switch (operationID) {
case BPMNProfilePackage.BPMN_ASSOCIATION___ASSOCIATION_END__DIAGNOSTICCHAIN_MAP:
return AssociationEnd((DiagnosticChain)arguments.get(0), (Map<Object, Object>)arguments.get(1));
}
return super.eInvoke(operationID, arguments);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public String toString() {
if (eIsProxy()) return super.toString();
StringBuffer result = new StringBuffer(super.toString());
result.append(" (associationDirection: ");
result.append(associationDirection);
result.append(')');
return result.toString();
}
} //BPMNAssociationImpl