/**
*/
package rba.core.impl;
import java.lang.reflect.InvocationTargetException;
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 rba.core.Expression;
import rba.core.ExpressionType;
import rba.core.IfStatement;
import rba.core.RBACorePackage;
/**
* An implementation of the model object 'If Statement'.
*
* The following features are implemented:
*
*
* - {@link rba.core.impl.IfStatementImpl#getCondition Condition}
* - {@link rba.core.impl.IfStatementImpl#getThenExpression Then Expression}
* - {@link rba.core.impl.IfStatementImpl#getElseExpression Else Expression}
*
*
* @generated
*/
public class IfStatementImpl extends ExpressionImpl implements IfStatement {
/**
* The cached value of the '{@link #getCondition() Condition}' containment reference.
*
* @see #getCondition()
* @generated
* @ordered
*/
protected Expression condition;
/**
* The cached value of the '{@link #getThenExpression() Then Expression}' containment reference.
* @see #getThenExpression()
* @generated
* @ordered
*/
protected Expression thenExpression;
/**
* The cached value of the '{@link #getElseExpression() Else Expression}' containment reference.
* @see #getElseExpression()
* @generated
* @ordered
*/
protected Expression elseExpression;
/**
*
* @generated
*/
protected IfStatementImpl() {
super();
}
/**
*
* @generated
*/
@Override
protected EClass eStaticClass() {
return RBACorePackage.Literals.IF_STATEMENT;
}
/**
*
* @generated
*/
public Expression getCondition() {
return condition;
}
/**
*
* @generated
*/
public NotificationChain basicSetCondition(Expression newCondition, NotificationChain msgs) {
Expression oldCondition = condition;
condition = newCondition;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET,
RBACorePackage.IF_STATEMENT__CONDITION, oldCondition, newCondition);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
/**
*
* @generated
*/
public void setCondition(Expression newCondition) {
if (newCondition != condition) {
NotificationChain msgs = null;
if (condition != null)
msgs = ((InternalEObject) condition).eInverseRemove(this,
EOPPOSITE_FEATURE_BASE - RBACorePackage.IF_STATEMENT__CONDITION, null, msgs);
if (newCondition != null)
msgs = ((InternalEObject) newCondition).eInverseAdd(this,
EOPPOSITE_FEATURE_BASE - RBACorePackage.IF_STATEMENT__CONDITION, null, msgs);
msgs = basicSetCondition(newCondition, msgs);
if (msgs != null)
msgs.dispatch();
} else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, RBACorePackage.IF_STATEMENT__CONDITION, newCondition,
newCondition));
}
/**
*
* @generated
*/
public Expression getThenExpression() {
return thenExpression;
}
/**
*
* @generated
*/
public NotificationChain basicSetThenExpression(Expression newThenExpression, NotificationChain msgs) {
Expression oldThenExpression = thenExpression;
thenExpression = newThenExpression;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET,
RBACorePackage.IF_STATEMENT__THEN_EXPRESSION, oldThenExpression, newThenExpression);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
/**
*
* @generated
*/
public void setThenExpression(Expression newThenExpression) {
if (newThenExpression != thenExpression) {
NotificationChain msgs = null;
if (thenExpression != null)
msgs = ((InternalEObject) thenExpression).eInverseRemove(this,
EOPPOSITE_FEATURE_BASE - RBACorePackage.IF_STATEMENT__THEN_EXPRESSION, null, msgs);
if (newThenExpression != null)
msgs = ((InternalEObject) newThenExpression).eInverseAdd(this,
EOPPOSITE_FEATURE_BASE - RBACorePackage.IF_STATEMENT__THEN_EXPRESSION, null, msgs);
msgs = basicSetThenExpression(newThenExpression, msgs);
if (msgs != null)
msgs.dispatch();
} else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, RBACorePackage.IF_STATEMENT__THEN_EXPRESSION,
newThenExpression, newThenExpression));
}
/**
*
* @generated
*/
public Expression getElseExpression() {
return elseExpression;
}
/**
*
* @generated
*/
public NotificationChain basicSetElseExpression(Expression newElseExpression, NotificationChain msgs) {
Expression oldElseExpression = elseExpression;
elseExpression = newElseExpression;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET,
RBACorePackage.IF_STATEMENT__ELSE_EXPRESSION, oldElseExpression, newElseExpression);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
/**
*
* @generated
*/
public void setElseExpression(Expression newElseExpression) {
if (newElseExpression != elseExpression) {
NotificationChain msgs = null;
if (elseExpression != null)
msgs = ((InternalEObject) elseExpression).eInverseRemove(this,
EOPPOSITE_FEATURE_BASE - RBACorePackage.IF_STATEMENT__ELSE_EXPRESSION, null, msgs);
if (newElseExpression != null)
msgs = ((InternalEObject) newElseExpression).eInverseAdd(this,
EOPPOSITE_FEATURE_BASE - RBACorePackage.IF_STATEMENT__ELSE_EXPRESSION, null, msgs);
msgs = basicSetElseExpression(newElseExpression, msgs);
if (msgs != null)
msgs.dispatch();
} else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, RBACorePackage.IF_STATEMENT__ELSE_EXPRESSION,
newElseExpression, newElseExpression));
}
/**
*
* @generated
*/
public ExpressionType getUnderlyingType() {
if (thenExpression != null) {
return thenExpression.getUnderlyingType();
}
return ExpressionType.VALUE;
}
/**
*
* @generated
*/
public String getExpressionText() {
StringBuffer expressionText = new StringBuffer();
expressionText.append("IF(");
expressionText.append(condition != null ? condition.getExpressionText() : "[Invalid_Expression]");
expressionText.append(") THEN ");
expressionText.append(thenExpression != null ? thenExpression.getExpressionText() : "[Invalid_Expression]");
expressionText.append(" ELSE ");
expressionText.append(elseExpression != null ? elseExpression.getExpressionText() : "[Invalid_Expression]");
return expressionText.toString();
}
/**
*
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case RBACorePackage.IF_STATEMENT__CONDITION:
return basicSetCondition(null, msgs);
case RBACorePackage.IF_STATEMENT__THEN_EXPRESSION:
return basicSetThenExpression(null, msgs);
case RBACorePackage.IF_STATEMENT__ELSE_EXPRESSION:
return basicSetElseExpression(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
*
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case RBACorePackage.IF_STATEMENT__CONDITION:
return getCondition();
case RBACorePackage.IF_STATEMENT__THEN_EXPRESSION:
return getThenExpression();
case RBACorePackage.IF_STATEMENT__ELSE_EXPRESSION:
return getElseExpression();
}
return super.eGet(featureID, resolve, coreType);
}
/**
*
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case RBACorePackage.IF_STATEMENT__CONDITION:
setCondition((Expression) newValue);
return;
case RBACorePackage.IF_STATEMENT__THEN_EXPRESSION:
setThenExpression((Expression) newValue);
return;
case RBACorePackage.IF_STATEMENT__ELSE_EXPRESSION:
setElseExpression((Expression) newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
*
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case RBACorePackage.IF_STATEMENT__CONDITION:
setCondition((Expression) null);
return;
case RBACorePackage.IF_STATEMENT__THEN_EXPRESSION:
setThenExpression((Expression) null);
return;
case RBACorePackage.IF_STATEMENT__ELSE_EXPRESSION:
setElseExpression((Expression) null);
return;
}
super.eUnset(featureID);
}
/**
*
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case RBACorePackage.IF_STATEMENT__CONDITION:
return condition != null;
case RBACorePackage.IF_STATEMENT__THEN_EXPRESSION:
return thenExpression != null;
case RBACorePackage.IF_STATEMENT__ELSE_EXPRESSION:
return elseExpression != null;
}
return super.eIsSet(featureID);
}
/**
*
* @generated
*/
@Override
public Object eInvoke(int operationID, EList> arguments) throws InvocationTargetException {
switch (operationID) {
case RBACorePackage.IF_STATEMENT___GET_UNDERLYING_TYPE:
return getUnderlyingType();
case RBACorePackage.IF_STATEMENT___GET_EXPRESSION_TEXT:
return getExpressionText();
}
return super.eInvoke(operationID, arguments);
}
} // IfStatementImpl