/**
*/
package modes3.impl;
import java.util.Collection;
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.common.util.EList;
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;
import org.eclipse.emf.ecore.util.EObjectResolvingEList;
/**
*
* An implementation of the model object 'Segment'.
*
*
* The following features are implemented:
*
*
* - {@link modes3.impl.SegmentImpl#getConnectedTo Connected To}
* - {@link modes3.impl.SegmentImpl#getOccupiedBy Occupied By}
* - {@link modes3.impl.SegmentImpl#getId Id}
*
*
* @generated
*/
public class SegmentImpl extends MinimalEObjectImpl.Container implements Segment {
/**
* The cached value of the '{@link #getConnectedTo() Connected To}' reference list.
*
*
* @see #getConnectedTo()
* @generated
* @ordered
*/
protected EList connectedTo;
/**
* The cached value of the '{@link #getOccupiedBy() Occupied By}' reference.
*
*
* @see #getOccupiedBy()
* @generated
* @ordered
*/
protected Train occupiedBy;
/**
* 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;
/**
*
*
* @generated
*/
protected SegmentImpl() {
super();
}
/**
*
*
* @generated
*/
@Override
protected EClass eStaticClass() {
return Modes3Package.Literals.SEGMENT;
}
/**
*
*
* @generated
*/
public EList getConnectedTo() {
if (connectedTo == null) {
connectedTo = new EObjectResolvingEList(Segment.class, this, Modes3Package.SEGMENT__CONNECTED_TO);
}
return connectedTo;
}
/**
*
*
* @generated
*/
public Train getOccupiedBy() {
if (occupiedBy != null && occupiedBy.eIsProxy()) {
InternalEObject oldOccupiedBy = (InternalEObject)occupiedBy;
occupiedBy = (Train)eResolveProxy(oldOccupiedBy);
if (occupiedBy != oldOccupiedBy) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, Modes3Package.SEGMENT__OCCUPIED_BY, oldOccupiedBy, occupiedBy));
}
}
return occupiedBy;
}
/**
*
*
* @generated
*/
public Train basicGetOccupiedBy() {
return occupiedBy;
}
/**
*
*
* @generated
*/
public NotificationChain basicSetOccupiedBy(Train newOccupiedBy, NotificationChain msgs) {
Train oldOccupiedBy = occupiedBy;
occupiedBy = newOccupiedBy;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Modes3Package.SEGMENT__OCCUPIED_BY, oldOccupiedBy, newOccupiedBy);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
*
*
* @generated
*/
public void setOccupiedBy(Train newOccupiedBy) {
if (newOccupiedBy != occupiedBy) {
NotificationChain msgs = null;
if (occupiedBy != null)
msgs = ((InternalEObject)occupiedBy).eInverseRemove(this, Modes3Package.TRAIN__LOCATION, Train.class, msgs);
if (newOccupiedBy != null)
msgs = ((InternalEObject)newOccupiedBy).eInverseAdd(this, Modes3Package.TRAIN__LOCATION, Train.class, msgs);
msgs = basicSetOccupiedBy(newOccupiedBy, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, Modes3Package.SEGMENT__OCCUPIED_BY, newOccupiedBy, newOccupiedBy));
}
/**
*
*
* @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.SEGMENT__ID, oldId, id));
}
/**
*
*
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case Modes3Package.SEGMENT__OCCUPIED_BY:
if (occupiedBy != null)
msgs = ((InternalEObject)occupiedBy).eInverseRemove(this, Modes3Package.TRAIN__LOCATION, Train.class, msgs);
return basicSetOccupiedBy((Train)otherEnd, msgs);
}
return super.eInverseAdd(otherEnd, featureID, msgs);
}
/**
*
*
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case Modes3Package.SEGMENT__OCCUPIED_BY:
return basicSetOccupiedBy(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
*
*
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case Modes3Package.SEGMENT__CONNECTED_TO:
return getConnectedTo();
case Modes3Package.SEGMENT__OCCUPIED_BY:
if (resolve) return getOccupiedBy();
return basicGetOccupiedBy();
case Modes3Package.SEGMENT__ID:
return getId();
}
return super.eGet(featureID, resolve, coreType);
}
/**
*
*
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case Modes3Package.SEGMENT__CONNECTED_TO:
getConnectedTo().clear();
getConnectedTo().addAll((Collection extends Segment>)newValue);
return;
case Modes3Package.SEGMENT__OCCUPIED_BY:
setOccupiedBy((Train)newValue);
return;
case Modes3Package.SEGMENT__ID:
setId((Integer)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
*
*
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case Modes3Package.SEGMENT__CONNECTED_TO:
getConnectedTo().clear();
return;
case Modes3Package.SEGMENT__OCCUPIED_BY:
setOccupiedBy((Train)null);
return;
case Modes3Package.SEGMENT__ID:
setId(ID_EDEFAULT);
return;
}
super.eUnset(featureID);
}
/**
*
*
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case Modes3Package.SEGMENT__CONNECTED_TO:
return connectedTo != null && !connectedTo.isEmpty();
case Modes3Package.SEGMENT__OCCUPIED_BY:
return occupiedBy != null;
case Modes3Package.SEGMENT__ID:
return id != ID_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(')');
return result.toString();
}
} //SegmentImpl