/**
*/
package modes3.impl;
import modes3.Modes3Package;
import modes3.Segment;
import modes3.Train;
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.MinimalEObjectImpl;
/**
*
* An implementation of the model object 'Train'.
*
*
* The following features are implemented:
*
*
* - {@link modes3.impl.TrainImpl#getLocation Location}
* - {@link modes3.impl.TrainImpl#getId Id}
* - {@link modes3.impl.TrainImpl#getSpeed Speed}
*
*
* @generated
*/
public class TrainImpl extends MinimalEObjectImpl.Container implements Train {
/**
* The cached value of the '{@link #getLocation() Location}' reference.
*
*
* @see #getLocation()
* @generated
* @ordered
*/
protected Segment location;
/**
* The default value of the '{@link #getId() Id}' attribute.
*
*
* @see #getId()
* @generated
* @ordered
*/
protected static final int ID_EDEFAULT = 0;
/**
* The cached value of the '{@link #getId() Id}' attribute.
*
*
* @see #getId()
* @generated
* @ordered
*/
protected int id = ID_EDEFAULT;
/**
* The default value of the '{@link #getSpeed() Speed}' attribute.
*
*
* @see #getSpeed()
* @generated
* @ordered
*/
protected static final double SPEED_EDEFAULT = 0.0;
/**
* The cached value of the '{@link #getSpeed() Speed}' attribute.
*
*
* @see #getSpeed()
* @generated
* @ordered
*/
protected double speed = SPEED_EDEFAULT;
/**
*
*
* @generated
*/
protected TrainImpl() {
super();
}
/**
*
*
* @generated
*/
@Override
protected EClass eStaticClass() {
return Modes3Package.Literals.TRAIN;
}
/**
*
*
* @generated
*/
public Segment getLocation() {
if (location != null && location.eIsProxy()) {
InternalEObject oldLocation = (InternalEObject)location;
location = (Segment)eResolveProxy(oldLocation);
if (location != oldLocation) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, Modes3Package.TRAIN__LOCATION, oldLocation, location));
}
}
return location;
}
/**
*
*
* @generated
*/
public Segment basicGetLocation() {
return location;
}
/**
*
*
* @generated
*/
public NotificationChain basicSetLocation(Segment newLocation, NotificationChain msgs) {
Segment oldLocation = location;
location = newLocation;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Modes3Package.TRAIN__LOCATION, oldLocation, newLocation);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
*
*
* @generated
*/
public void setLocation(Segment newLocation) {
if (newLocation != location) {
NotificationChain msgs = null;
if (location != null)
msgs = ((InternalEObject)location).eInverseRemove(this, Modes3Package.SEGMENT__OCCUPIED_BY, Segment.class, msgs);
if (newLocation != null)
msgs = ((InternalEObject)newLocation).eInverseAdd(this, Modes3Package.SEGMENT__OCCUPIED_BY, Segment.class, msgs);
msgs = basicSetLocation(newLocation, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, Modes3Package.TRAIN__LOCATION, newLocation, newLocation));
}
/**
*
*
* @generated
*/
public int getId() {
return id;
}
/**
*
*
* @generated
*/
public void setId(int newId) {
int oldId = id;
id = newId;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, Modes3Package.TRAIN__ID, oldId, id));
}
/**
*
*
* @generated
*/
public double getSpeed() {
return speed;
}
/**
*
*
* @generated
*/
public void setSpeed(double newSpeed) {
double oldSpeed = speed;
speed = newSpeed;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, Modes3Package.TRAIN__SPEED, oldSpeed, speed));
}
/**
*
*
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case Modes3Package.TRAIN__LOCATION:
if (location != null)
msgs = ((InternalEObject)location).eInverseRemove(this, Modes3Package.SEGMENT__OCCUPIED_BY, Segment.class, msgs);
return basicSetLocation((Segment)otherEnd, msgs);
}
return super.eInverseAdd(otherEnd, featureID, msgs);
}
/**
*
*
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case Modes3Package.TRAIN__LOCATION:
return basicSetLocation(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
*
*
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case Modes3Package.TRAIN__LOCATION:
if (resolve) return getLocation();
return basicGetLocation();
case Modes3Package.TRAIN__ID:
return getId();
case Modes3Package.TRAIN__SPEED:
return getSpeed();
}
return super.eGet(featureID, resolve, coreType);
}
/**
*
*
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case Modes3Package.TRAIN__LOCATION:
setLocation((Segment)newValue);
return;
case Modes3Package.TRAIN__ID:
setId((Integer)newValue);
return;
case Modes3Package.TRAIN__SPEED:
setSpeed((Double)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
*
*
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case Modes3Package.TRAIN__LOCATION:
setLocation((Segment)null);
return;
case Modes3Package.TRAIN__ID:
setId(ID_EDEFAULT);
return;
case Modes3Package.TRAIN__SPEED:
setSpeed(SPEED_EDEFAULT);
return;
}
super.eUnset(featureID);
}
/**
*
*
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case Modes3Package.TRAIN__LOCATION:
return location != null;
case Modes3Package.TRAIN__ID:
return id != ID_EDEFAULT;
case Modes3Package.TRAIN__SPEED:
return speed != SPEED_EDEFAULT;
}
return super.eIsSet(featureID);
}
/**
*
*
* @generated
*/
@Override
public String toString() {
if (eIsProxy()) return super.toString();
StringBuilder result = new StringBuilder(super.toString());
result.append(" (id: ");
result.append(id);
result.append(", speed: ");
result.append(speed);
result.append(')');
return result.toString();
}
} //TrainImpl