/**
*/
package org.yakindu.sct.model.stext.stext.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.yakindu.base.expressions.expressions.Expression;
import org.yakindu.sct.model.stext.stext.StextPackage;
import org.yakindu.sct.model.stext.stext.TimeEventSpec;
import org.yakindu.sct.model.stext.stext.TimeEventType;
import org.yakindu.sct.model.stext.stext.TimeUnit;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Time Event Spec</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.yakindu.sct.model.stext.stext.impl.TimeEventSpecImpl#getType <em>Type</em>}</li>
* <li>{@link org.yakindu.sct.model.stext.stext.impl.TimeEventSpecImpl#getValue <em>Value</em>}</li>
* <li>{@link org.yakindu.sct.model.stext.stext.impl.TimeEventSpecImpl#getUnit <em>Unit</em>}</li>
* </ul>
*
* @generated
*/
public class TimeEventSpecImpl extends EventSpecImpl implements TimeEventSpec {
/**
* The default value of the '{@link #getType() <em>Type</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getType()
* @generated
* @ordered
*/
protected static final TimeEventType TYPE_EDEFAULT = TimeEventType.AFTER;
/**
* The cached value of the '{@link #getType() <em>Type</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getType()
* @generated
* @ordered
*/
protected TimeEventType type = TYPE_EDEFAULT;
/**
* The cached value of the '{@link #getValue() <em>Value</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getValue()
* @generated
* @ordered
*/
protected Expression value;
/**
* The default value of the '{@link #getUnit() <em>Unit</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getUnit()
* @generated
* @ordered
*/
protected static final TimeUnit UNIT_EDEFAULT = TimeUnit.SECOND;
/**
* The cached value of the '{@link #getUnit() <em>Unit</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getUnit()
* @generated
* @ordered
*/
protected TimeUnit unit = UNIT_EDEFAULT;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected TimeEventSpecImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return StextPackage.Literals.TIME_EVENT_SPEC;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public TimeEventType getType() {
return type;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setType(TimeEventType newType) {
TimeEventType oldType = type;
type = newType == null ? TYPE_EDEFAULT : newType;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, StextPackage.TIME_EVENT_SPEC__TYPE, oldType, type));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Expression getValue() {
return value;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetValue(Expression newValue, NotificationChain msgs) {
Expression oldValue = value;
value = newValue;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, StextPackage.TIME_EVENT_SPEC__VALUE, oldValue, newValue);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setValue(Expression newValue) {
if (newValue != value) {
NotificationChain msgs = null;
if (value != null)
msgs = ((InternalEObject)value).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - StextPackage.TIME_EVENT_SPEC__VALUE, null, msgs);
if (newValue != null)
msgs = ((InternalEObject)newValue).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - StextPackage.TIME_EVENT_SPEC__VALUE, null, msgs);
msgs = basicSetValue(newValue, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, StextPackage.TIME_EVENT_SPEC__VALUE, newValue, newValue));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public TimeUnit getUnit() {
return unit;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setUnit(TimeUnit newUnit) {
TimeUnit oldUnit = unit;
unit = newUnit == null ? UNIT_EDEFAULT : newUnit;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, StextPackage.TIME_EVENT_SPEC__UNIT, oldUnit, unit));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case StextPackage.TIME_EVENT_SPEC__VALUE:
return basicSetValue(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 StextPackage.TIME_EVENT_SPEC__TYPE:
return getType();
case StextPackage.TIME_EVENT_SPEC__VALUE:
return getValue();
case StextPackage.TIME_EVENT_SPEC__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 StextPackage.TIME_EVENT_SPEC__TYPE:
setType((TimeEventType)newValue);
return;
case StextPackage.TIME_EVENT_SPEC__VALUE:
setValue((Expression)newValue);
return;
case StextPackage.TIME_EVENT_SPEC__UNIT:
setUnit((TimeUnit)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case StextPackage.TIME_EVENT_SPEC__TYPE:
setType(TYPE_EDEFAULT);
return;
case StextPackage.TIME_EVENT_SPEC__VALUE:
setValue((Expression)null);
return;
case StextPackage.TIME_EVENT_SPEC__UNIT:
setUnit(UNIT_EDEFAULT);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case StextPackage.TIME_EVENT_SPEC__TYPE:
return type != TYPE_EDEFAULT;
case StextPackage.TIME_EVENT_SPEC__VALUE:
return value != null;
case StextPackage.TIME_EVENT_SPEC__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(" (type: ");
result.append(type);
result.append(", unit: ");
result.append(unit);
result.append(')');
return result.toString();
}
} //TimeEventSpecImpl