/**
*/
package net.cis.common.model.structure.impl;
import java.util.Collection;
import net.cis.common.model.structure.Ship;
import net.cis.common.model.structure.ShipType;
import net.cis.common.model.structure.Slot;
import net.cis.common.model.structure.StructurePackage;
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.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Ship</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link net.cis.common.model.structure.impl.ShipImpl#getHeight <em>Height</em>}</li>
* <li>{@link net.cis.common.model.structure.impl.ShipImpl#getWidth <em>Width</em>}</li>
* <li>{@link net.cis.common.model.structure.impl.ShipImpl#getLength <em>Length</em>}</li>
* <li>{@link net.cis.common.model.structure.impl.ShipImpl#getShipType <em>Ship Type</em>}</li>
* <li>{@link net.cis.common.model.structure.impl.ShipImpl#getWeight <em>Weight</em>}</li>
* <li>{@link net.cis.common.model.structure.impl.ShipImpl#getMaxAngularVelocity <em>Max Angular Velocity</em>}</li>
* <li>{@link net.cis.common.model.structure.impl.ShipImpl#getMaxLinearVelocity <em>Max Linear Velocity</em>}</li>
* <li>{@link net.cis.common.model.structure.impl.ShipImpl#getSlots <em>Slots</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class ShipImpl extends AbstractStructureImpl implements Ship {
/**
* The default value of the '{@link #getHeight() <em>Height</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getHeight()
* @generated
* @ordered
*/
protected static final float HEIGHT_EDEFAULT = 0.0F;
/**
* The cached value of the '{@link #getHeight() <em>Height</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getHeight()
* @generated
* @ordered
*/
protected float height = HEIGHT_EDEFAULT;
/**
* The default value of the '{@link #getWidth() <em>Width</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getWidth()
* @generated
* @ordered
*/
protected static final float WIDTH_EDEFAULT = 0.0F;
/**
* The cached value of the '{@link #getWidth() <em>Width</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getWidth()
* @generated
* @ordered
*/
protected float width = WIDTH_EDEFAULT;
/**
* The default value of the '{@link #getLength() <em>Length</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getLength()
* @generated
* @ordered
*/
protected static final float LENGTH_EDEFAULT = 0.0F;
/**
* The cached value of the '{@link #getLength() <em>Length</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getLength()
* @generated
* @ordered
*/
protected float length = LENGTH_EDEFAULT;
/**
* The default value of the '{@link #getShipType() <em>Ship Type</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getShipType()
* @generated
* @ordered
*/
protected static final ShipType SHIP_TYPE_EDEFAULT = ShipType.FIGHTER;
/**
* The cached value of the '{@link #getShipType() <em>Ship Type</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getShipType()
* @generated
* @ordered
*/
protected ShipType shipType = SHIP_TYPE_EDEFAULT;
/**
* The default value of the '{@link #getWeight() <em>Weight</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getWeight()
* @generated
* @ordered
*/
protected static final float WEIGHT_EDEFAULT = 0.0F;
/**
* The cached value of the '{@link #getWeight() <em>Weight</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getWeight()
* @generated
* @ordered
*/
protected float weight = WEIGHT_EDEFAULT;
/**
* The default value of the '{@link #getMaxAngularVelocity() <em>Max Angular Velocity</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getMaxAngularVelocity()
* @generated
* @ordered
*/
protected static final float MAX_ANGULAR_VELOCITY_EDEFAULT = 0.0F;
/**
* The cached value of the '{@link #getMaxAngularVelocity() <em>Max Angular Velocity</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getMaxAngularVelocity()
* @generated
* @ordered
*/
protected float maxAngularVelocity = MAX_ANGULAR_VELOCITY_EDEFAULT;
/**
* The default value of the '{@link #getMaxLinearVelocity() <em>Max Linear Velocity</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getMaxLinearVelocity()
* @generated
* @ordered
*/
protected static final float MAX_LINEAR_VELOCITY_EDEFAULT = 0.0F;
/**
* The cached value of the '{@link #getMaxLinearVelocity() <em>Max Linear Velocity</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getMaxLinearVelocity()
* @generated
* @ordered
*/
protected float maxLinearVelocity = MAX_LINEAR_VELOCITY_EDEFAULT;
/**
* The cached value of the '{@link #getSlots() <em>Slots</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getSlots()
* @generated
* @ordered
*/
protected EList<Slot> slots;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected ShipImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return StructurePackage.Literals.SHIP;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public float getHeight() {
return height;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setHeight(float newHeight) {
float oldHeight = height;
height = newHeight;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, StructurePackage.SHIP__HEIGHT, oldHeight, height));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public float getWidth() {
return width;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setWidth(float newWidth) {
float oldWidth = width;
width = newWidth;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, StructurePackage.SHIP__WIDTH, oldWidth, width));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public float getLength() {
return length;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setLength(float newLength) {
float oldLength = length;
length = newLength;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, StructurePackage.SHIP__LENGTH, oldLength, length));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public ShipType getShipType() {
return shipType;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setShipType(ShipType newShipType) {
ShipType oldShipType = shipType;
shipType = newShipType == null ? SHIP_TYPE_EDEFAULT : newShipType;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, StructurePackage.SHIP__SHIP_TYPE, oldShipType, shipType));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public float getWeight() {
return weight;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setWeight(float newWeight) {
float oldWeight = weight;
weight = newWeight;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, StructurePackage.SHIP__WEIGHT, oldWeight, weight));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public float getMaxAngularVelocity() {
return maxAngularVelocity;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setMaxAngularVelocity(float newMaxAngularVelocity) {
float oldMaxAngularVelocity = maxAngularVelocity;
maxAngularVelocity = newMaxAngularVelocity;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, StructurePackage.SHIP__MAX_ANGULAR_VELOCITY, oldMaxAngularVelocity, maxAngularVelocity));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public float getMaxLinearVelocity() {
return maxLinearVelocity;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setMaxLinearVelocity(float newMaxLinearVelocity) {
float oldMaxLinearVelocity = maxLinearVelocity;
maxLinearVelocity = newMaxLinearVelocity;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, StructurePackage.SHIP__MAX_LINEAR_VELOCITY, oldMaxLinearVelocity, maxLinearVelocity));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<Slot> getSlots() {
if (slots == null) {
slots = new EObjectContainmentEList<Slot>(Slot.class, this, StructurePackage.SHIP__SLOTS);
}
return slots;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case StructurePackage.SHIP__SLOTS:
return ((InternalEList<?>)getSlots()).basicRemove(otherEnd, 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 StructurePackage.SHIP__HEIGHT:
return getHeight();
case StructurePackage.SHIP__WIDTH:
return getWidth();
case StructurePackage.SHIP__LENGTH:
return getLength();
case StructurePackage.SHIP__SHIP_TYPE:
return getShipType();
case StructurePackage.SHIP__WEIGHT:
return getWeight();
case StructurePackage.SHIP__MAX_ANGULAR_VELOCITY:
return getMaxAngularVelocity();
case StructurePackage.SHIP__MAX_LINEAR_VELOCITY:
return getMaxLinearVelocity();
case StructurePackage.SHIP__SLOTS:
return getSlots();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case StructurePackage.SHIP__HEIGHT:
setHeight((Float)newValue);
return;
case StructurePackage.SHIP__WIDTH:
setWidth((Float)newValue);
return;
case StructurePackage.SHIP__LENGTH:
setLength((Float)newValue);
return;
case StructurePackage.SHIP__SHIP_TYPE:
setShipType((ShipType)newValue);
return;
case StructurePackage.SHIP__WEIGHT:
setWeight((Float)newValue);
return;
case StructurePackage.SHIP__MAX_ANGULAR_VELOCITY:
setMaxAngularVelocity((Float)newValue);
return;
case StructurePackage.SHIP__MAX_LINEAR_VELOCITY:
setMaxLinearVelocity((Float)newValue);
return;
case StructurePackage.SHIP__SLOTS:
getSlots().clear();
getSlots().addAll((Collection<? extends Slot>)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case StructurePackage.SHIP__HEIGHT:
setHeight(HEIGHT_EDEFAULT);
return;
case StructurePackage.SHIP__WIDTH:
setWidth(WIDTH_EDEFAULT);
return;
case StructurePackage.SHIP__LENGTH:
setLength(LENGTH_EDEFAULT);
return;
case StructurePackage.SHIP__SHIP_TYPE:
setShipType(SHIP_TYPE_EDEFAULT);
return;
case StructurePackage.SHIP__WEIGHT:
setWeight(WEIGHT_EDEFAULT);
return;
case StructurePackage.SHIP__MAX_ANGULAR_VELOCITY:
setMaxAngularVelocity(MAX_ANGULAR_VELOCITY_EDEFAULT);
return;
case StructurePackage.SHIP__MAX_LINEAR_VELOCITY:
setMaxLinearVelocity(MAX_LINEAR_VELOCITY_EDEFAULT);
return;
case StructurePackage.SHIP__SLOTS:
getSlots().clear();
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case StructurePackage.SHIP__HEIGHT:
return height != HEIGHT_EDEFAULT;
case StructurePackage.SHIP__WIDTH:
return width != WIDTH_EDEFAULT;
case StructurePackage.SHIP__LENGTH:
return length != LENGTH_EDEFAULT;
case StructurePackage.SHIP__SHIP_TYPE:
return shipType != SHIP_TYPE_EDEFAULT;
case StructurePackage.SHIP__WEIGHT:
return weight != WEIGHT_EDEFAULT;
case StructurePackage.SHIP__MAX_ANGULAR_VELOCITY:
return maxAngularVelocity != MAX_ANGULAR_VELOCITY_EDEFAULT;
case StructurePackage.SHIP__MAX_LINEAR_VELOCITY:
return maxLinearVelocity != MAX_LINEAR_VELOCITY_EDEFAULT;
case StructurePackage.SHIP__SLOTS:
return slots != null && !slots.isEmpty();
}
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(" (height: ");
result.append(height);
result.append(", width: ");
result.append(width);
result.append(", length: ");
result.append(length);
result.append(", shipType: ");
result.append(shipType);
result.append(", weight: ");
result.append(weight);
result.append(", maxAngularVelocity: ");
result.append(maxAngularVelocity);
result.append(", maxLinearVelocity: ");
result.append(maxLinearVelocity);
result.append(')');
return result.toString();
}
} //ShipImpl