/**
* <copyright>
* </copyright>
*
* $Id$
*/
package simulator.scl.impl;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import simulator.scl.ConfigPackage;
import simulator.scl.IncrementTimeVariable;
import simulator.scl.UnitOfTime;
import simulator.scl.Variable;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Increment Time Variable</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link simulator.scl.impl.IncrementTimeVariableImpl#getVariable <em>Variable</em>}</li>
* <li>{@link simulator.scl.impl.IncrementTimeVariableImpl#getUnit <em>Unit</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class IncrementTimeVariableImpl extends ExpressionImpl implements IncrementTimeVariable {
/**
* The cached value of the '{@link #getVariable() <em>Variable</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getVariable()
* @generated
* @ordered
*/
protected Variable variable;
/**
* The default value of the '{@link #getUnit() <em>Unit</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getUnit()
* @generated
* @ordered
*/
protected static final UnitOfTime UNIT_EDEFAULT = UnitOfTime.HOUR;
/**
* The cached value of the '{@link #getUnit() <em>Unit</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getUnit()
* @generated
* @ordered
*/
protected UnitOfTime unit = UNIT_EDEFAULT;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected IncrementTimeVariableImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return ConfigPackage.Literals.INCREMENT_TIME_VARIABLE;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Variable getVariable() {
if (variable != null && variable.eIsProxy()) {
InternalEObject oldVariable = (InternalEObject)variable;
variable = (Variable)eResolveProxy(oldVariable);
if (variable != oldVariable) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, ConfigPackage.INCREMENT_TIME_VARIABLE__VARIABLE, oldVariable, variable));
}
}
return variable;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Variable basicGetVariable() {
return variable;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setVariable(Variable newVariable) {
Variable oldVariable = variable;
variable = newVariable;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ConfigPackage.INCREMENT_TIME_VARIABLE__VARIABLE, oldVariable, variable));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public UnitOfTime getUnit() {
return unit;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setUnit(UnitOfTime newUnit) {
UnitOfTime oldUnit = unit;
unit = newUnit == null ? UNIT_EDEFAULT : newUnit;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ConfigPackage.INCREMENT_TIME_VARIABLE__UNIT, oldUnit, unit));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case ConfigPackage.INCREMENT_TIME_VARIABLE__VARIABLE:
if (resolve) return getVariable();
return basicGetVariable();
case ConfigPackage.INCREMENT_TIME_VARIABLE__UNIT:
return getUnit();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case ConfigPackage.INCREMENT_TIME_VARIABLE__VARIABLE:
setVariable((Variable)newValue);
return;
case ConfigPackage.INCREMENT_TIME_VARIABLE__UNIT:
setUnit((UnitOfTime)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case ConfigPackage.INCREMENT_TIME_VARIABLE__VARIABLE:
setVariable((Variable)null);
return;
case ConfigPackage.INCREMENT_TIME_VARIABLE__UNIT:
setUnit(UNIT_EDEFAULT);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case ConfigPackage.INCREMENT_TIME_VARIABLE__VARIABLE:
return variable != null;
case ConfigPackage.INCREMENT_TIME_VARIABLE__UNIT:
return unit != UNIT_EDEFAULT;
}
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(" (unit: ");
result.append(unit);
result.append(')');
return result.toString();
}
} //IncrementTimeVariableImpl