/**
* <copyright>
* </copyright>
*
* $Id$
*/
package com.crispico.flower.mp.model.codesync.impl;
import com.crispico.flower.mp.model.codesync.CodeSyncElement;
import com.crispico.flower.mp.model.codesync.CodeSyncPackage;
import com.crispico.flower.mp.model.codesync.Relation;
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.impl.EObjectImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Relation</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link com.crispico.flower.mp.model.codesync.impl.RelationImpl#getSource <em>Source</em>}</li>
* <li>{@link com.crispico.flower.mp.model.codesync.impl.RelationImpl#getTarget <em>Target</em>}</li>
* <li>{@link com.crispico.flower.mp.model.codesync.impl.RelationImpl#getType <em>Type</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class RelationImpl extends EObjectImpl implements Relation {
/**
* The cached value of the '{@link #getTarget() <em>Target</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getTarget()
* @generated
* @ordered
*/
protected CodeSyncElement target;
/**
* The default value of the '{@link #getType() <em>Type</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getType()
* @generated
* @ordered
*/
protected static final String TYPE_EDEFAULT = null;
/**
* The cached value of the '{@link #getType() <em>Type</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getType()
* @generated
* @ordered
*/
protected String type = TYPE_EDEFAULT;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected RelationImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return CodeSyncPackage.Literals.RELATION;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public CodeSyncElement getSource() {
if (eContainerFeatureID() != CodeSyncPackage.RELATION__SOURCE) return null;
return (CodeSyncElement)eContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetSource(CodeSyncElement newSource, NotificationChain msgs) {
msgs = eBasicSetContainer((InternalEObject)newSource, CodeSyncPackage.RELATION__SOURCE, msgs);
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setSource(CodeSyncElement newSource) {
if (newSource != eInternalContainer() || (eContainerFeatureID() != CodeSyncPackage.RELATION__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, CodeSyncPackage.CODE_SYNC_ELEMENT__RELATIONS, CodeSyncElement.class, msgs);
msgs = basicSetSource(newSource, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, CodeSyncPackage.RELATION__SOURCE, newSource, newSource));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public CodeSyncElement getTarget() {
if (target != null && target.eIsProxy()) {
InternalEObject oldTarget = (InternalEObject)target;
target = (CodeSyncElement)eResolveProxy(oldTarget);
if (target != oldTarget) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, CodeSyncPackage.RELATION__TARGET, oldTarget, target));
}
}
return target;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public CodeSyncElement basicGetTarget() {
return target;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setTarget(CodeSyncElement newTarget) {
CodeSyncElement oldTarget = target;
target = newTarget;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, CodeSyncPackage.RELATION__TARGET, oldTarget, target));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getType() {
return type;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setType(String newType) {
String oldType = type;
type = newType;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, CodeSyncPackage.RELATION__TYPE, oldType, type));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case CodeSyncPackage.RELATION__SOURCE:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetSource((CodeSyncElement)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 CodeSyncPackage.RELATION__SOURCE:
return basicSetSource(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
switch (eContainerFeatureID()) {
case CodeSyncPackage.RELATION__SOURCE:
return eInternalContainer().eInverseRemove(this, CodeSyncPackage.CODE_SYNC_ELEMENT__RELATIONS, CodeSyncElement.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 CodeSyncPackage.RELATION__SOURCE:
return getSource();
case CodeSyncPackage.RELATION__TARGET:
if (resolve) return getTarget();
return basicGetTarget();
case CodeSyncPackage.RELATION__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 CodeSyncPackage.RELATION__SOURCE:
setSource((CodeSyncElement)newValue);
return;
case CodeSyncPackage.RELATION__TARGET:
setTarget((CodeSyncElement)newValue);
return;
case CodeSyncPackage.RELATION__TYPE:
setType((String)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case CodeSyncPackage.RELATION__SOURCE:
setSource((CodeSyncElement)null);
return;
case CodeSyncPackage.RELATION__TARGET:
setTarget((CodeSyncElement)null);
return;
case CodeSyncPackage.RELATION__TYPE:
setType(TYPE_EDEFAULT);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case CodeSyncPackage.RELATION__SOURCE:
return getSource() != null;
case CodeSyncPackage.RELATION__TARGET:
return target != null;
case CodeSyncPackage.RELATION__TYPE:
return TYPE_EDEFAULT == null ? type != null : !TYPE_EDEFAULT.equals(type);
}
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();
}
} //RelationImpl