/**
*/
package fr.inria.diverse.minilang.impl;
import fr.inria.diverse.minilang.Block;
import fr.inria.diverse.minilang.BooleanExpression;
import fr.inria.diverse.minilang.MinilangPackage;
import fr.inria.diverse.minilang.While;
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.eclipse.emf.ecore.impl.MinimalEObjectImpl;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>While</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link fr.inria.diverse.minilang.impl.WhileImpl#getCondition <em>Condition</em>}</li>
* <li>{@link fr.inria.diverse.minilang.impl.WhileImpl#getBody <em>Body</em>}</li>
* </ul>
*
* @generated
*/
public class WhileImpl extends MinimalEObjectImpl.Container implements While {
/**
* The cached value of the '{@link #getCondition() <em>Condition</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getCondition()
* @generated
* @ordered
*/
protected BooleanExpression condition;
/**
* The cached value of the '{@link #getBody() <em>Body</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getBody()
* @generated
* @ordered
*/
protected Block body;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected WhileImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return MinilangPackage.Literals.WHILE;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public BooleanExpression getCondition() {
return condition;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetCondition(BooleanExpression newCondition, NotificationChain msgs) {
BooleanExpression oldCondition = condition;
condition = newCondition;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, MinilangPackage.WHILE__CONDITION, oldCondition, newCondition);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setCondition(BooleanExpression newCondition) {
if (newCondition != condition) {
NotificationChain msgs = null;
if (condition != null)
msgs = ((InternalEObject)condition).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - MinilangPackage.WHILE__CONDITION, null, msgs);
if (newCondition != null)
msgs = ((InternalEObject)newCondition).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - MinilangPackage.WHILE__CONDITION, null, msgs);
msgs = basicSetCondition(newCondition, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, MinilangPackage.WHILE__CONDITION, newCondition, newCondition));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Block getBody() {
if (body != null && body.eIsProxy()) {
InternalEObject oldBody = (InternalEObject)body;
body = (Block)eResolveProxy(oldBody);
if (body != oldBody) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, MinilangPackage.WHILE__BODY, oldBody, body));
}
}
return body;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Block basicGetBody() {
return body;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setBody(Block newBody) {
Block oldBody = body;
body = newBody;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, MinilangPackage.WHILE__BODY, oldBody, body));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case MinilangPackage.WHILE__CONDITION:
return basicSetCondition(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 MinilangPackage.WHILE__CONDITION:
return getCondition();
case MinilangPackage.WHILE__BODY:
if (resolve) return getBody();
return basicGetBody();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case MinilangPackage.WHILE__CONDITION:
setCondition((BooleanExpression)newValue);
return;
case MinilangPackage.WHILE__BODY:
setBody((Block)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case MinilangPackage.WHILE__CONDITION:
setCondition((BooleanExpression)null);
return;
case MinilangPackage.WHILE__BODY:
setBody((Block)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case MinilangPackage.WHILE__CONDITION:
return condition != null;
case MinilangPackage.WHILE__BODY:
return body != null;
}
return super.eIsSet(featureID);
}
} //WhileImpl