/**
* <copyright>
* </copyright>
*
* $Id$
*/
package domain.impl;
import domain.CodeElement;
import domain.Dependency;
import domain.DependencyType;
import domain.DomainPackage;
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;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Dependency</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link domain.impl.DependencyImpl#getFrom <em>From</em>}</li>
* <li>{@link domain.impl.DependencyImpl#getTo <em>To</em>}</li>
* <li>{@link domain.impl.DependencyImpl#getType <em>Type</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class DependencyImpl extends GraphElementImpl implements Dependency {
/**
* The cached value of the '{@link #getFrom() <em>From</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getFrom()
* @generated
* @ordered
*/
protected CodeElement from;
/**
* The cached value of the '{@link #getTo() <em>To</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getTo()
* @generated
* @ordered
*/
protected CodeElement to;
/**
* The default value of the '{@link #getType() <em>Type</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getType()
* @generated
* @ordered
*/
protected static final DependencyType TYPE_EDEFAULT = DependencyType.METHOD_CALL;
/**
* The cached value of the '{@link #getType() <em>Type</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getType()
* @generated
* @ordered
*/
protected DependencyType type = TYPE_EDEFAULT;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected DependencyImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return DomainPackage.Literals.DEPENDENCY;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public CodeElement getFrom() {
if (from != null && from.eIsProxy()) {
InternalEObject oldFrom = (InternalEObject)from;
from = (CodeElement)eResolveProxy(oldFrom);
if (from != oldFrom) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, DomainPackage.DEPENDENCY__FROM, oldFrom, from));
}
}
return from;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public CodeElement basicGetFrom() {
return from;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetFrom(CodeElement newFrom, NotificationChain msgs) {
CodeElement oldFrom = from;
from = newFrom;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, DomainPackage.DEPENDENCY__FROM, oldFrom, newFrom);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setFrom(CodeElement newFrom) {
if (newFrom != from) {
NotificationChain msgs = null;
if (from != null)
msgs = ((InternalEObject)from).eInverseRemove(this, DomainPackage.CODE_ELEMENT__OUTGOING_DEPS, CodeElement.class, msgs);
if (newFrom != null)
msgs = ((InternalEObject)newFrom).eInverseAdd(this, DomainPackage.CODE_ELEMENT__OUTGOING_DEPS, CodeElement.class, msgs);
msgs = basicSetFrom(newFrom, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, DomainPackage.DEPENDENCY__FROM, newFrom, newFrom));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public CodeElement getTo() {
if (to != null && to.eIsProxy()) {
InternalEObject oldTo = (InternalEObject)to;
to = (CodeElement)eResolveProxy(oldTo);
if (to != oldTo) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, DomainPackage.DEPENDENCY__TO, oldTo, to));
}
}
return to;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public CodeElement basicGetTo() {
return to;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetTo(CodeElement newTo, NotificationChain msgs) {
CodeElement oldTo = to;
to = newTo;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, DomainPackage.DEPENDENCY__TO, oldTo, newTo);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setTo(CodeElement newTo) {
if (newTo != to) {
NotificationChain msgs = null;
if (to != null)
msgs = ((InternalEObject)to).eInverseRemove(this, DomainPackage.CODE_ELEMENT__INCOMING_DEPS, CodeElement.class, msgs);
if (newTo != null)
msgs = ((InternalEObject)newTo).eInverseAdd(this, DomainPackage.CODE_ELEMENT__INCOMING_DEPS, CodeElement.class, msgs);
msgs = basicSetTo(newTo, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, DomainPackage.DEPENDENCY__TO, newTo, newTo));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public DependencyType getType() {
return type;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setType(DependencyType newType) {
DependencyType oldType = type;
type = newType == null ? TYPE_EDEFAULT : newType;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, DomainPackage.DEPENDENCY__TYPE, oldType, type));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case DomainPackage.DEPENDENCY__FROM:
if (from != null)
msgs = ((InternalEObject)from).eInverseRemove(this, DomainPackage.CODE_ELEMENT__OUTGOING_DEPS, CodeElement.class, msgs);
return basicSetFrom((CodeElement)otherEnd, msgs);
case DomainPackage.DEPENDENCY__TO:
if (to != null)
msgs = ((InternalEObject)to).eInverseRemove(this, DomainPackage.CODE_ELEMENT__INCOMING_DEPS, CodeElement.class, msgs);
return basicSetTo((CodeElement)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 DomainPackage.DEPENDENCY__FROM:
return basicSetFrom(null, msgs);
case DomainPackage.DEPENDENCY__TO:
return basicSetTo(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 DomainPackage.DEPENDENCY__FROM:
if (resolve) return getFrom();
return basicGetFrom();
case DomainPackage.DEPENDENCY__TO:
if (resolve) return getTo();
return basicGetTo();
case DomainPackage.DEPENDENCY__TYPE:
return getType();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case DomainPackage.DEPENDENCY__FROM:
setFrom((CodeElement)newValue);
return;
case DomainPackage.DEPENDENCY__TO:
setTo((CodeElement)newValue);
return;
case DomainPackage.DEPENDENCY__TYPE:
setType((DependencyType)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case DomainPackage.DEPENDENCY__FROM:
setFrom((CodeElement)null);
return;
case DomainPackage.DEPENDENCY__TO:
setTo((CodeElement)null);
return;
case DomainPackage.DEPENDENCY__TYPE:
setType(TYPE_EDEFAULT);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case DomainPackage.DEPENDENCY__FROM:
return from != null;
case DomainPackage.DEPENDENCY__TO:
return to != null;
case DomainPackage.DEPENDENCY__TYPE:
return type != TYPE_EDEFAULT;
}
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(" (type: ");
result.append(type);
result.append(')');
return result.toString();
}
} //DependencyImpl