blob: 3d0bee4ac6ba102d166f3bcad26942d7aa8187fd [file] [log] [blame]
/**
* * Copyright (c) 2006-2010 Istvan Rath and Daniel Varro
* * 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:
* * Istvan Rath, Daniel Varro - initial API and implementation
*
*/
package org.eclipse.viatra2.gtasmmodel.vpm.editmodel.impl;
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;
import org.eclipse.viatra2.gtasmmodel.vpm.editmodel.EditmodelPackage;
import org.eclipse.viatra2.gtasmmodel.vpm.editmodel.ModelElement;
import org.eclipse.viatra2.gtasmmodel.vpm.editmodel.Relation;
/**
* <!-- 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 org.eclipse.viatra2.gtasmmodel.vpm.editmodel.impl.RelationImpl#getTo <em>To</em>}</li>
* <li>{@link org.eclipse.viatra2.gtasmmodel.vpm.editmodel.impl.RelationImpl#getFromStr <em>From Str</em>}</li>
* <li>{@link org.eclipse.viatra2.gtasmmodel.vpm.editmodel.impl.RelationImpl#getToStr <em>To Str</em>}</li>
* <li>{@link org.eclipse.viatra2.gtasmmodel.vpm.editmodel.impl.RelationImpl#getFrom <em>From</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class RelationImpl extends ModelElementImpl implements Relation
{
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public static final String copyright = " * Copyright (c) 2006-2010 Istvan Rath and Daniel Varro\r\n * All rights reserved. This program and the accompanying materials\r\n * are made available under the terms of the Eclipse Public License v1.0\r\n * which accompanies this distribution, and is available at\r\n * http://www.eclipse.org/legal/epl-v10.html\r\n *\r\n * Contributors:\r\n * Istvan Rath, Daniel Varro - initial API and implementation\r\n";
/**
* The cached value of the '{@link #getTo() <em>To</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getTo()
* @generated
* @ordered
*/
protected ModelElement to;
/**
* The default value of the '{@link #getFromStr() <em>From Str</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getFromStr()
* @generated
* @ordered
*/
protected static final String FROM_STR_EDEFAULT = null;
/**
* The cached value of the '{@link #getFromStr() <em>From Str</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getFromStr()
* @generated
* @ordered
*/
protected String fromStr = FROM_STR_EDEFAULT;
/**
* The default value of the '{@link #getToStr() <em>To Str</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getToStr()
* @generated
* @ordered
*/
protected static final String TO_STR_EDEFAULT = null;
/**
* The cached value of the '{@link #getToStr() <em>To Str</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getToStr()
* @generated
* @ordered
*/
protected String toStr = TO_STR_EDEFAULT;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected RelationImpl()
{
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass()
{
return EditmodelPackage.Literals.RELATION;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public ModelElement getTo()
{
if (to != null && to.eIsProxy())
{
InternalEObject oldTo = (InternalEObject)to;
to = (ModelElement)eResolveProxy(oldTo);
if (to != oldTo)
{
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, EditmodelPackage.RELATION__TO, oldTo, to));
}
}
return to;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public ModelElement basicGetTo()
{
return to;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetTo(ModelElement newTo, NotificationChain msgs)
{
ModelElement oldTo = to;
to = newTo;
if (eNotificationRequired())
{
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, EditmodelPackage.RELATION__TO, oldTo, newTo);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setTo(ModelElement newTo)
{
if (newTo != to)
{
NotificationChain msgs = null;
if (to != null)
msgs = ((InternalEObject)to).eInverseRemove(this, EditmodelPackage.MODEL_ELEMENT__RELATIONS_TO, ModelElement.class, msgs);
if (newTo != null)
msgs = ((InternalEObject)newTo).eInverseAdd(this, EditmodelPackage.MODEL_ELEMENT__RELATIONS_TO, ModelElement.class, msgs);
msgs = basicSetTo(newTo, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, EditmodelPackage.RELATION__TO, newTo, newTo));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getFromStr()
{
return fromStr;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setFromStr(String newFromStr)
{
String oldFromStr = fromStr;
fromStr = newFromStr;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, EditmodelPackage.RELATION__FROM_STR, oldFromStr, fromStr));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getToStr()
{
return toStr;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setToStr(String newToStr)
{
String oldToStr = toStr;
toStr = newToStr;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, EditmodelPackage.RELATION__TO_STR, oldToStr, toStr));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public ModelElement getFrom()
{
if (eContainerFeatureID() != EditmodelPackage.RELATION__FROM) return null;
return (ModelElement)eContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetFrom(ModelElement newFrom, NotificationChain msgs)
{
msgs = eBasicSetContainer((InternalEObject)newFrom, EditmodelPackage.RELATION__FROM, msgs);
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setFrom(ModelElement newFrom)
{
if (newFrom != eInternalContainer() || (eContainerFeatureID() != EditmodelPackage.RELATION__FROM && newFrom != null))
{
if (EcoreUtil.isAncestor(this, newFrom))
throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
NotificationChain msgs = null;
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
if (newFrom != null)
msgs = ((InternalEObject)newFrom).eInverseAdd(this, EditmodelPackage.MODEL_ELEMENT__RELATIONS_FROM, ModelElement.class, msgs);
msgs = basicSetFrom(newFrom, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, EditmodelPackage.RELATION__FROM, newFrom, newFrom));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs)
{
switch (featureID)
{
case EditmodelPackage.RELATION__TO:
if (to != null)
msgs = ((InternalEObject)to).eInverseRemove(this, EditmodelPackage.MODEL_ELEMENT__RELATIONS_TO, ModelElement.class, msgs);
return basicSetTo((ModelElement)otherEnd, msgs);
case EditmodelPackage.RELATION__FROM:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetFrom((ModelElement)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 EditmodelPackage.RELATION__TO:
return basicSetTo(null, msgs);
case EditmodelPackage.RELATION__FROM:
return basicSetFrom(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs)
{
switch (eContainerFeatureID())
{
case EditmodelPackage.RELATION__FROM:
return eInternalContainer().eInverseRemove(this, EditmodelPackage.MODEL_ELEMENT__RELATIONS_FROM, ModelElement.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 EditmodelPackage.RELATION__TO:
if (resolve) return getTo();
return basicGetTo();
case EditmodelPackage.RELATION__FROM_STR:
return getFromStr();
case EditmodelPackage.RELATION__TO_STR:
return getToStr();
case EditmodelPackage.RELATION__FROM:
return getFrom();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue)
{
switch (featureID)
{
case EditmodelPackage.RELATION__TO:
setTo((ModelElement)newValue);
return;
case EditmodelPackage.RELATION__FROM_STR:
setFromStr((String)newValue);
return;
case EditmodelPackage.RELATION__TO_STR:
setToStr((String)newValue);
return;
case EditmodelPackage.RELATION__FROM:
setFrom((ModelElement)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID)
{
switch (featureID)
{
case EditmodelPackage.RELATION__TO:
setTo((ModelElement)null);
return;
case EditmodelPackage.RELATION__FROM_STR:
setFromStr(FROM_STR_EDEFAULT);
return;
case EditmodelPackage.RELATION__TO_STR:
setToStr(TO_STR_EDEFAULT);
return;
case EditmodelPackage.RELATION__FROM:
setFrom((ModelElement)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID)
{
switch (featureID)
{
case EditmodelPackage.RELATION__TO:
return to != null;
case EditmodelPackage.RELATION__FROM_STR:
return FROM_STR_EDEFAULT == null ? fromStr != null : !FROM_STR_EDEFAULT.equals(fromStr);
case EditmodelPackage.RELATION__TO_STR:
return TO_STR_EDEFAULT == null ? toStr != null : !TO_STR_EDEFAULT.equals(toStr);
case EditmodelPackage.RELATION__FROM:
return getFrom() != 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(" (fromStr: ");
result.append(fromStr);
result.append(", toStr: ");
result.append(toStr);
result.append(')');
return result.toString();
}
} //RelationImpl