blob: 508b5ea62799b3e5d83389503c94c7f017c9b858 [file] [log] [blame]
/**
*/
package org.eclipse.qvto.examples.xtext.imperativeoclcs.impl;
import java.util.Collection;
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;
import org.eclipse.ocl.xtext.basecs.util.BaseCSVisitor;
import org.eclipse.ocl.xtext.essentialoclcs.ExpCS;
import org.eclipse.qvto.examples.xtext.imperativeoclcs.ImperativeOCLCSPackage;
import org.eclipse.qvto.examples.xtext.imperativeoclcs.SwitchAltCS;
import org.eclipse.qvto.examples.xtext.imperativeoclcs.SwitchExpCS;
import org.eclipse.qvto.examples.xtext.imperativeoclcs.util.ImperativeOCLCSVisitor;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Switch Exp CS</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.qvto.examples.xtext.imperativeoclcs.impl.SwitchExpCSImpl#getAlternativePart <em>Alternative Part</em>}</li>
* <li>{@link org.eclipse.qvto.examples.xtext.imperativeoclcs.impl.SwitchExpCSImpl#getElsePart <em>Else Part</em>}</li>
* </ul>
*
* @generated
*/
public class SwitchExpCSImpl extends StatementCSImpl implements SwitchExpCS {
/**
* The cached value of the '{@link #getAlternativePart() <em>Alternative Part</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getAlternativePart()
* @generated
* @ordered
*/
protected EList<SwitchAltCS> alternativePart;
/**
* The cached value of the '{@link #getElsePart() <em>Else Part</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getElsePart()
* @generated
* @ordered
*/
protected ExpCS elsePart;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected SwitchExpCSImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return ImperativeOCLCSPackage.Literals.SWITCH_EXP_CS;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<SwitchAltCS> getAlternativePart() {
if (alternativePart == null) {
alternativePart = new EObjectContainmentEList<SwitchAltCS>(SwitchAltCS.class, this, ImperativeOCLCSPackage.SWITCH_EXP_CS__ALTERNATIVE_PART);
}
return alternativePart;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public ExpCS getElsePart() {
return elsePart;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetElsePart(ExpCS newElsePart, NotificationChain msgs) {
ExpCS oldElsePart = elsePart;
elsePart = newElsePart;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ImperativeOCLCSPackage.SWITCH_EXP_CS__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(ExpCS newElsePart) {
if (newElsePart != elsePart) {
NotificationChain msgs = null;
if (elsePart != null)
msgs = ((InternalEObject)elsePart).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ImperativeOCLCSPackage.SWITCH_EXP_CS__ELSE_PART, null, msgs);
if (newElsePart != null)
msgs = ((InternalEObject)newElsePart).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ImperativeOCLCSPackage.SWITCH_EXP_CS__ELSE_PART, null, msgs);
msgs = basicSetElsePart(newElsePart, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ImperativeOCLCSPackage.SWITCH_EXP_CS__ELSE_PART, newElsePart, newElsePart));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case ImperativeOCLCSPackage.SWITCH_EXP_CS__ALTERNATIVE_PART:
return ((InternalEList<?>)getAlternativePart()).basicRemove(otherEnd, msgs);
case ImperativeOCLCSPackage.SWITCH_EXP_CS__ELSE_PART:
return basicSetElsePart(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 ImperativeOCLCSPackage.SWITCH_EXP_CS__ALTERNATIVE_PART:
return getAlternativePart();
case ImperativeOCLCSPackage.SWITCH_EXP_CS__ELSE_PART:
return getElsePart();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case ImperativeOCLCSPackage.SWITCH_EXP_CS__ALTERNATIVE_PART:
getAlternativePart().clear();
getAlternativePart().addAll((Collection<? extends SwitchAltCS>)newValue);
return;
case ImperativeOCLCSPackage.SWITCH_EXP_CS__ELSE_PART:
setElsePart((ExpCS)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case ImperativeOCLCSPackage.SWITCH_EXP_CS__ALTERNATIVE_PART:
getAlternativePart().clear();
return;
case ImperativeOCLCSPackage.SWITCH_EXP_CS__ELSE_PART:
setElsePart((ExpCS)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case ImperativeOCLCSPackage.SWITCH_EXP_CS__ALTERNATIVE_PART:
return alternativePart != null && !alternativePart.isEmpty();
case ImperativeOCLCSPackage.SWITCH_EXP_CS__ELSE_PART:
return elsePart != null;
}
return super.eIsSet(featureID);
}
/**
* {@inheritDoc}
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public <R> R accept(BaseCSVisitor<R> visitor) {
return (R) ((ImperativeOCLCSVisitor<?>)visitor).visitSwitchExpCS(this);
}
} //SwitchExpCSImpl