/**
* <copyright>
* </copyright>
*
* $Id$
*/
package net.sf.etl.samples.ej.ast.impl;
import java.util.Collection;
import net.sf.etl.samples.ej.ast.AstPackage;
import net.sf.etl.samples.ej.ast.IfStatement;
import net.sf.etl.samples.ej.ast.IfThenPart;
import net.sf.etl.samples.ej.ast.MethodBlock;
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>If Statement</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link net.sf.etl.samples.ej.ast.impl.IfStatementImpl#getIfThenPart <em>If Then Part</em>}</li>
* <li>{@link net.sf.etl.samples.ej.ast.impl.IfStatementImpl#getElsePart <em>Else Part</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class IfStatementImpl extends MethodContentStatementImpl implements IfStatement {
/**
* The cached value of the '{@link #getIfThenPart() <em>If Then Part</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getIfThenPart()
* @generated
* @ordered
*/
protected EList ifThenPart = null;
/**
* The cached value of the '{@link #getElsePart() <em>Else Part</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getElsePart()
* @generated
* @ordered
*/
protected MethodBlock elsePart = null;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected IfStatementImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected EClass eStaticClass() {
return AstPackage.Literals.IF_STATEMENT;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList getIfThenPart() {
if (ifThenPart == null) {
ifThenPart = new EObjectContainmentEList(IfThenPart.class, this, AstPackage.IF_STATEMENT__IF_THEN_PART);
}
return ifThenPart;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public MethodBlock getElsePart() {
return elsePart;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetElsePart(MethodBlock newElsePart, NotificationChain msgs) {
MethodBlock oldElsePart = elsePart;
elsePart = newElsePart;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, AstPackage.IF_STATEMENT__ELSE_PART, oldElsePart, newElsePart);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setElsePart(MethodBlock newElsePart) {
if (newElsePart != elsePart) {
NotificationChain msgs = null;
if (elsePart != null)
msgs = ((InternalEObject)elsePart).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - AstPackage.IF_STATEMENT__ELSE_PART, null, msgs);
if (newElsePart != null)
msgs = ((InternalEObject)newElsePart).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - AstPackage.IF_STATEMENT__ELSE_PART, null, msgs);
msgs = basicSetElsePart(newElsePart, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, AstPackage.IF_STATEMENT__ELSE_PART, newElsePart, newElsePart));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case AstPackage.IF_STATEMENT__IF_THEN_PART:
return ((InternalEList)getIfThenPart()).basicRemove(otherEnd, msgs);
case AstPackage.IF_STATEMENT__ELSE_PART:
return basicSetElsePart(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case AstPackage.IF_STATEMENT__IF_THEN_PART:
return getIfThenPart();
case AstPackage.IF_STATEMENT__ELSE_PART:
return getElsePart();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case AstPackage.IF_STATEMENT__IF_THEN_PART:
getIfThenPart().clear();
getIfThenPart().addAll((Collection)newValue);
return;
case AstPackage.IF_STATEMENT__ELSE_PART:
setElsePart((MethodBlock)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void eUnset(int featureID) {
switch (featureID) {
case AstPackage.IF_STATEMENT__IF_THEN_PART:
getIfThenPart().clear();
return;
case AstPackage.IF_STATEMENT__ELSE_PART:
setElsePart((MethodBlock)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public boolean eIsSet(int featureID) {
switch (featureID) {
case AstPackage.IF_STATEMENT__IF_THEN_PART:
return ifThenPart != null && !ifThenPart.isEmpty();
case AstPackage.IF_STATEMENT__ELSE_PART:
return elsePart != null;
}
return super.eIsSet(featureID);
}
} //IfStatementImpl