blob: ee59e6f7965cb7c2a692afa38a523b6bf1fd49f6 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2007, 2018 IBM Corporation, Zeligsoft Inc., and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* IBM - Initial API and implementation
* Zeligsoft - Bugs 248869, 207365
*******************************************************************************/
package org.eclipse.ocl.ecore.impl;
import java.util.Map;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.DiagnosticChain;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EParameter;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.ocl.ecore.EcorePackage;
import org.eclipse.ocl.ecore.LetExp;
import org.eclipse.ocl.expressions.ExpressionsPackage;
import org.eclipse.ocl.expressions.OCLExpression;
import org.eclipse.ocl.expressions.Variable;
import org.eclipse.ocl.expressions.operations.LetExpOperations;
import org.eclipse.ocl.utilities.Visitor;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Let Exp</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.ocl.ecore.impl.LetExpImpl#getIn <em>In</em>}</li>
* <li>{@link org.eclipse.ocl.ecore.impl.LetExpImpl#getVariable <em>Variable</em>}</li>
* </ul>
*
* @generated
*/
public class LetExpImpl
extends OCLExpressionImpl
implements LetExp {
/**
* The cached value of the '{@link #getIn() <em>In</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getIn()
* @generated
* @ordered
*/
protected OCLExpression<EClassifier> in;
/**
* The cached value of the '{@link #getVariable() <em>Variable</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getVariable()
* @generated
* @ordered
*/
protected Variable<EClassifier, EParameter> variable;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected LetExpImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return EcorePackage.Literals.LET_EXP;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public OCLExpression<EClassifier> getIn() {
return in;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetIn(OCLExpression<EClassifier> newIn,
NotificationChain msgs) {
OCLExpression<EClassifier> oldIn = in;
in = newIn;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this,
Notification.SET, EcorePackage.LET_EXP__IN, oldIn, newIn);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setIn(OCLExpression<EClassifier> newIn) {
if (newIn != in) {
NotificationChain msgs = null;
if (in != null)
msgs = ((InternalEObject) in).eInverseRemove(this,
EOPPOSITE_FEATURE_BASE - EcorePackage.LET_EXP__IN, null,
msgs);
if (newIn != null)
msgs = ((InternalEObject) newIn).eInverseAdd(this,
EOPPOSITE_FEATURE_BASE - EcorePackage.LET_EXP__IN, null,
msgs);
msgs = basicSetIn(newIn, msgs);
if (msgs != null)
msgs.dispatch();
} else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET,
EcorePackage.LET_EXP__IN, newIn, newIn));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Variable<EClassifier, EParameter> getVariable() {
return variable;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetVariable(
Variable<EClassifier, EParameter> newVariable,
NotificationChain msgs) {
Variable<EClassifier, EParameter> oldVariable = variable;
variable = newVariable;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this,
Notification.SET, EcorePackage.LET_EXP__VARIABLE, oldVariable,
newVariable);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setVariable(Variable<EClassifier, EParameter> newVariable) {
if (newVariable != variable) {
NotificationChain msgs = null;
if (variable != null)
msgs = ((InternalEObject) variable).eInverseRemove(this,
EOPPOSITE_FEATURE_BASE - EcorePackage.LET_EXP__VARIABLE,
null, msgs);
if (newVariable != null)
msgs = ((InternalEObject) newVariable).eInverseAdd(this,
EOPPOSITE_FEATURE_BASE - EcorePackage.LET_EXP__VARIABLE,
null, msgs);
msgs = basicSetVariable(newVariable, msgs);
if (msgs != null)
msgs.dispatch();
} else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET,
EcorePackage.LET_EXP__VARIABLE, newVariable, newVariable));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
public boolean checkLetType(DiagnosticChain diagnostics,
Map<Object, Object> context) {
return LetExpOperations.checkLetType(this, diagnostics, context);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd,
int featureID, NotificationChain msgs) {
switch (featureID) {
case EcorePackage.LET_EXP__IN :
return basicSetIn(null, msgs);
case EcorePackage.LET_EXP__VARIABLE :
return basicSetVariable(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 EcorePackage.LET_EXP__IN :
return getIn();
case EcorePackage.LET_EXP__VARIABLE :
return getVariable();
}
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 EcorePackage.LET_EXP__IN :
setIn((OCLExpression<EClassifier>) newValue);
return;
case EcorePackage.LET_EXP__VARIABLE :
setVariable((Variable<EClassifier, EParameter>) newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case EcorePackage.LET_EXP__IN :
setIn((OCLExpression<EClassifier>) null);
return;
case EcorePackage.LET_EXP__VARIABLE :
setVariable((Variable<EClassifier, EParameter>) null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case EcorePackage.LET_EXP__IN :
return in != null;
case EcorePackage.LET_EXP__VARIABLE :
return variable != null;
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public int eBaseStructuralFeatureID(int derivedFeatureID,
Class<?> baseClass) {
if (baseClass == org.eclipse.ocl.expressions.LetExp.class) {
switch (derivedFeatureID) {
case EcorePackage.LET_EXP__IN :
return ExpressionsPackage.LET_EXP__IN;
case EcorePackage.LET_EXP__VARIABLE :
return ExpressionsPackage.LET_EXP__VARIABLE;
default :
return -1;
}
}
return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public int eDerivedStructuralFeatureID(int baseFeatureID,
Class<?> baseClass) {
if (baseClass == org.eclipse.ocl.expressions.LetExp.class) {
switch (baseFeatureID) {
case ExpressionsPackage.LET_EXP__IN :
return EcorePackage.LET_EXP__IN;
case ExpressionsPackage.LET_EXP__VARIABLE :
return EcorePackage.LET_EXP__VARIABLE;
default :
return -1;
}
}
return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
@Override
public String toString() {
return super.toString();
}
/**
* @generated NOT
*/
@Override
@SuppressWarnings("unchecked")
public <T, U extends Visitor<T, ?, ?, ?, ?, ?, ?, ?, ?, ?>> T accept(U v) {
return ((Visitor<T, EClassifier, ?, ?, ?, EParameter, ?, ?, ?, ?>) v)
.visitLetExp(this);
}
} //LetExpImpl