/**
*/
package org.eclipse.viatra.solver.language.solverLanguage.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.viatra.solver.language.solverLanguage.Expression;
import org.eclipse.viatra.solver.language.solverLanguage.LetBinding;
import org.eclipse.viatra.solver.language.solverLanguage.LetExpression;
import org.eclipse.viatra.solver.language.solverLanguage.SolverLanguagePackage;
/**
*
* An implementation of the model object 'Let Expression'.
*
*
* The following features are implemented:
*
*
* - {@link org.eclipse.viatra.solver.language.solverLanguage.impl.LetExpressionImpl#getBindings Bindings}
* - {@link org.eclipse.viatra.solver.language.solverLanguage.impl.LetExpressionImpl#getBody Body}
*
*
* @generated
*/
public class LetExpressionImpl extends ExpressionImpl implements LetExpression {
/**
* The cached value of the '{@link #getBindings() Bindings}' containment reference list.
*
*
* @see #getBindings()
* @generated
* @ordered
*/
protected EList bindings;
/**
* The cached value of the '{@link #getBody() Body}' containment reference.
*
*
* @see #getBody()
* @generated
* @ordered
*/
protected Expression body;
/**
*
*
* @generated
*/
protected LetExpressionImpl() {
super();
}
/**
*
*
* @generated
*/
@Override
protected EClass eStaticClass() {
return SolverLanguagePackage.Literals.LET_EXPRESSION;
}
/**
*
*
* @generated
*/
public EList getBindings() {
if (bindings == null) {
bindings = new EObjectContainmentEList(LetBinding.class, this,
SolverLanguagePackage.LET_EXPRESSION__BINDINGS);
}
return bindings;
}
/**
*
*
* @generated
*/
public Expression getBody() {
return body;
}
/**
*
*
* @generated
*/
public NotificationChain basicSetBody(Expression newBody, NotificationChain msgs) {
Expression oldBody = body;
body = newBody;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET,
SolverLanguagePackage.LET_EXPRESSION__BODY, oldBody, newBody);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
/**
*
*
* @generated
*/
public void setBody(Expression newBody) {
if (newBody != body) {
NotificationChain msgs = null;
if (body != null)
msgs = ((InternalEObject) body).eInverseRemove(this,
EOPPOSITE_FEATURE_BASE - SolverLanguagePackage.LET_EXPRESSION__BODY, null, msgs);
if (newBody != null)
msgs = ((InternalEObject) newBody).eInverseAdd(this,
EOPPOSITE_FEATURE_BASE - SolverLanguagePackage.LET_EXPRESSION__BODY, null, msgs);
msgs = basicSetBody(newBody, msgs);
if (msgs != null)
msgs.dispatch();
} else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, SolverLanguagePackage.LET_EXPRESSION__BODY, newBody,
newBody));
}
/**
*
*
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case SolverLanguagePackage.LET_EXPRESSION__BINDINGS:
return ((InternalEList>) getBindings()).basicRemove(otherEnd, msgs);
case SolverLanguagePackage.LET_EXPRESSION__BODY:
return basicSetBody(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
*
*
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case SolverLanguagePackage.LET_EXPRESSION__BINDINGS:
return getBindings();
case SolverLanguagePackage.LET_EXPRESSION__BODY:
return getBody();
}
return super.eGet(featureID, resolve, coreType);
}
/**
*
*
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case SolverLanguagePackage.LET_EXPRESSION__BINDINGS:
getBindings().clear();
getBindings().addAll((Collection extends LetBinding>) newValue);
return;
case SolverLanguagePackage.LET_EXPRESSION__BODY:
setBody((Expression) newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
*
*
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case SolverLanguagePackage.LET_EXPRESSION__BINDINGS:
getBindings().clear();
return;
case SolverLanguagePackage.LET_EXPRESSION__BODY:
setBody((Expression) null);
return;
}
super.eUnset(featureID);
}
/**
*
*
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case SolverLanguagePackage.LET_EXPRESSION__BINDINGS:
return bindings != null && !bindings.isEmpty();
case SolverLanguagePackage.LET_EXPRESSION__BODY:
return body != null;
}
return super.eIsSet(featureID);
}
} //LetExpressionImpl