/**
* <copyright>
* </copyright>
*
*/
package org.eclipse.etrice.core.room.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.etrice.core.room.DetailCode;
import org.eclipse.etrice.core.room.RoomPackage;
import org.eclipse.etrice.core.room.Transition;
import org.eclipse.etrice.core.room.TransitionTerminal;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Transition</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.etrice.core.room.impl.TransitionImpl#getName <em>Name</em>}</li>
* <li>{@link org.eclipse.etrice.core.room.impl.TransitionImpl#getTo <em>To</em>}</li>
* <li>{@link org.eclipse.etrice.core.room.impl.TransitionImpl#getAction <em>Action</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class TransitionImpl extends StateGraphItemImpl implements Transition
{
/**
* The default value of the '{@link #getName() <em>Name</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getName()
* @generated
* @ordered
*/
protected static final String NAME_EDEFAULT = null;
/**
* The cached value of the '{@link #getName() <em>Name</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getName()
* @generated
* @ordered
*/
protected String name = NAME_EDEFAULT;
/**
* The cached value of the '{@link #getTo() <em>To</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getTo()
* @generated
* @ordered
*/
protected TransitionTerminal to;
/**
* The cached value of the '{@link #getAction() <em>Action</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getAction()
* @generated
* @ordered
*/
protected DetailCode action;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected TransitionImpl()
{
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass()
{
return RoomPackage.Literals.TRANSITION;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getName()
{
return name;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setName(String newName)
{
String oldName = name;
name = newName;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, RoomPackage.TRANSITION__NAME, oldName, name));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public TransitionTerminal getTo()
{
return to;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetTo(TransitionTerminal newTo, NotificationChain msgs)
{
TransitionTerminal oldTo = to;
to = newTo;
if (eNotificationRequired())
{
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, RoomPackage.TRANSITION__TO, oldTo, newTo);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setTo(TransitionTerminal newTo)
{
if (newTo != to)
{
NotificationChain msgs = null;
if (to != null)
msgs = ((InternalEObject)to).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - RoomPackage.TRANSITION__TO, null, msgs);
if (newTo != null)
msgs = ((InternalEObject)newTo).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - RoomPackage.TRANSITION__TO, null, msgs);
msgs = basicSetTo(newTo, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, RoomPackage.TRANSITION__TO, newTo, newTo));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public DetailCode getAction()
{
return action;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetAction(DetailCode newAction, NotificationChain msgs)
{
DetailCode oldAction = action;
action = newAction;
if (eNotificationRequired())
{
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, RoomPackage.TRANSITION__ACTION, oldAction, newAction);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setAction(DetailCode newAction)
{
if (newAction != action)
{
NotificationChain msgs = null;
if (action != null)
msgs = ((InternalEObject)action).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - RoomPackage.TRANSITION__ACTION, null, msgs);
if (newAction != null)
msgs = ((InternalEObject)newAction).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - RoomPackage.TRANSITION__ACTION, null, msgs);
msgs = basicSetAction(newAction, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, RoomPackage.TRANSITION__ACTION, newAction, newAction));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
{
switch (featureID)
{
case RoomPackage.TRANSITION__TO:
return basicSetTo(null, msgs);
case RoomPackage.TRANSITION__ACTION:
return basicSetAction(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 RoomPackage.TRANSITION__NAME:
return getName();
case RoomPackage.TRANSITION__TO:
return getTo();
case RoomPackage.TRANSITION__ACTION:
return getAction();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue)
{
switch (featureID)
{
case RoomPackage.TRANSITION__NAME:
setName((String)newValue);
return;
case RoomPackage.TRANSITION__TO:
setTo((TransitionTerminal)newValue);
return;
case RoomPackage.TRANSITION__ACTION:
setAction((DetailCode)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID)
{
switch (featureID)
{
case RoomPackage.TRANSITION__NAME:
setName(NAME_EDEFAULT);
return;
case RoomPackage.TRANSITION__TO:
setTo((TransitionTerminal)null);
return;
case RoomPackage.TRANSITION__ACTION:
setAction((DetailCode)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID)
{
switch (featureID)
{
case RoomPackage.TRANSITION__NAME:
return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
case RoomPackage.TRANSITION__TO:
return to != null;
case RoomPackage.TRANSITION__ACTION:
return action != 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(" (name: ");
result.append(name);
result.append(')');
return result.toString();
}
} //TransitionImpl