blob: 4a844e62d6b23ce246a9f7e963a375f95f60f0e7 [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.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.ocl.ecore.EcorePackage;
import org.eclipse.ocl.ecore.IfExp;
import org.eclipse.ocl.expressions.ExpressionsPackage;
import org.eclipse.ocl.expressions.OCLExpression;
import org.eclipse.ocl.expressions.operations.IfExpOperations;
import org.eclipse.ocl.utilities.Visitor;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>If Exp</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.ocl.ecore.impl.IfExpImpl#getCondition <em>Condition</em>}</li>
* <li>{@link org.eclipse.ocl.ecore.impl.IfExpImpl#getThenExpression <em>Then Expression</em>}</li>
* <li>{@link org.eclipse.ocl.ecore.impl.IfExpImpl#getElseExpression <em>Else Expression</em>}</li>
* </ul>
*
* @generated
*/
public class IfExpImpl
extends OCLExpressionImpl
implements IfExp {
/**
* The cached value of the '{@link #getCondition() <em>Condition</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getCondition()
* @generated
* @ordered
*/
protected OCLExpression<EClassifier> condition;
/**
* The cached value of the '{@link #getThenExpression() <em>Then Expression</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getThenExpression()
* @generated
* @ordered
*/
protected OCLExpression<EClassifier> thenExpression;
/**
* The cached value of the '{@link #getElseExpression() <em>Else Expression</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getElseExpression()
* @generated
* @ordered
*/
protected OCLExpression<EClassifier> elseExpression;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected IfExpImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return EcorePackage.Literals.IF_EXP;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public OCLExpression<EClassifier> getCondition() {
return condition;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetCondition(
OCLExpression<EClassifier> newCondition, NotificationChain msgs) {
OCLExpression<EClassifier> oldCondition = condition;
condition = newCondition;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this,
Notification.SET, EcorePackage.IF_EXP__CONDITION, oldCondition,
newCondition);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setCondition(OCLExpression<EClassifier> newCondition) {
if (newCondition != condition) {
NotificationChain msgs = null;
if (condition != null)
msgs = ((InternalEObject) condition).eInverseRemove(this,
EOPPOSITE_FEATURE_BASE - EcorePackage.IF_EXP__CONDITION,
null, msgs);
if (newCondition != null)
msgs = ((InternalEObject) newCondition).eInverseAdd(this,
EOPPOSITE_FEATURE_BASE - EcorePackage.IF_EXP__CONDITION,
null, msgs);
msgs = basicSetCondition(newCondition, msgs);
if (msgs != null)
msgs.dispatch();
} else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET,
EcorePackage.IF_EXP__CONDITION, newCondition, newCondition));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public OCLExpression<EClassifier> getThenExpression() {
return thenExpression;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetThenExpression(
OCLExpression<EClassifier> newThenExpression,
NotificationChain msgs) {
OCLExpression<EClassifier> oldThenExpression = thenExpression;
thenExpression = newThenExpression;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this,
Notification.SET, EcorePackage.IF_EXP__THEN_EXPRESSION,
oldThenExpression, newThenExpression);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setThenExpression(
OCLExpression<EClassifier> newThenExpression) {
if (newThenExpression != thenExpression) {
NotificationChain msgs = null;
if (thenExpression != null)
msgs = ((InternalEObject) thenExpression).eInverseRemove(this,
EOPPOSITE_FEATURE_BASE
- EcorePackage.IF_EXP__THEN_EXPRESSION,
null, msgs);
if (newThenExpression != null)
msgs = ((InternalEObject) newThenExpression).eInverseAdd(this,
EOPPOSITE_FEATURE_BASE
- EcorePackage.IF_EXP__THEN_EXPRESSION,
null, msgs);
msgs = basicSetThenExpression(newThenExpression, msgs);
if (msgs != null)
msgs.dispatch();
} else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET,
EcorePackage.IF_EXP__THEN_EXPRESSION, newThenExpression,
newThenExpression));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public OCLExpression<EClassifier> getElseExpression() {
return elseExpression;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetElseExpression(
OCLExpression<EClassifier> newElseExpression,
NotificationChain msgs) {
OCLExpression<EClassifier> oldElseExpression = elseExpression;
elseExpression = newElseExpression;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this,
Notification.SET, EcorePackage.IF_EXP__ELSE_EXPRESSION,
oldElseExpression, newElseExpression);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setElseExpression(
OCLExpression<EClassifier> newElseExpression) {
if (newElseExpression != elseExpression) {
NotificationChain msgs = null;
if (elseExpression != null)
msgs = ((InternalEObject) elseExpression).eInverseRemove(this,
EOPPOSITE_FEATURE_BASE
- EcorePackage.IF_EXP__ELSE_EXPRESSION,
null, msgs);
if (newElseExpression != null)
msgs = ((InternalEObject) newElseExpression).eInverseAdd(this,
EOPPOSITE_FEATURE_BASE
- EcorePackage.IF_EXP__ELSE_EXPRESSION,
null, msgs);
msgs = basicSetElseExpression(newElseExpression, msgs);
if (msgs != null)
msgs.dispatch();
} else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET,
EcorePackage.IF_EXP__ELSE_EXPRESSION, newElseExpression,
newElseExpression));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
public boolean checkBooleanCondition(DiagnosticChain diagnostics,
Map<Object, Object> context) {
return IfExpOperations.checkBooleanCondition(this, diagnostics,
context);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
public boolean checkIfType(DiagnosticChain diagnostics,
Map<Object, Object> context) {
return IfExpOperations.checkIfType(this, diagnostics, context);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd,
int featureID, NotificationChain msgs) {
switch (featureID) {
case EcorePackage.IF_EXP__CONDITION :
return basicSetCondition(null, msgs);
case EcorePackage.IF_EXP__THEN_EXPRESSION :
return basicSetThenExpression(null, msgs);
case EcorePackage.IF_EXP__ELSE_EXPRESSION :
return basicSetElseExpression(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.IF_EXP__CONDITION :
return getCondition();
case EcorePackage.IF_EXP__THEN_EXPRESSION :
return getThenExpression();
case EcorePackage.IF_EXP__ELSE_EXPRESSION :
return getElseExpression();
}
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.IF_EXP__CONDITION :
setCondition((OCLExpression<EClassifier>) newValue);
return;
case EcorePackage.IF_EXP__THEN_EXPRESSION :
setThenExpression((OCLExpression<EClassifier>) newValue);
return;
case EcorePackage.IF_EXP__ELSE_EXPRESSION :
setElseExpression((OCLExpression<EClassifier>) newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case EcorePackage.IF_EXP__CONDITION :
setCondition((OCLExpression<EClassifier>) null);
return;
case EcorePackage.IF_EXP__THEN_EXPRESSION :
setThenExpression((OCLExpression<EClassifier>) null);
return;
case EcorePackage.IF_EXP__ELSE_EXPRESSION :
setElseExpression((OCLExpression<EClassifier>) null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case EcorePackage.IF_EXP__CONDITION :
return condition != null;
case EcorePackage.IF_EXP__THEN_EXPRESSION :
return thenExpression != null;
case EcorePackage.IF_EXP__ELSE_EXPRESSION :
return elseExpression != 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.IfExp.class) {
switch (derivedFeatureID) {
case EcorePackage.IF_EXP__CONDITION :
return ExpressionsPackage.IF_EXP__CONDITION;
case EcorePackage.IF_EXP__THEN_EXPRESSION :
return ExpressionsPackage.IF_EXP__THEN_EXPRESSION;
case EcorePackage.IF_EXP__ELSE_EXPRESSION :
return ExpressionsPackage.IF_EXP__ELSE_EXPRESSION;
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.IfExp.class) {
switch (baseFeatureID) {
case ExpressionsPackage.IF_EXP__CONDITION :
return EcorePackage.IF_EXP__CONDITION;
case ExpressionsPackage.IF_EXP__THEN_EXPRESSION :
return EcorePackage.IF_EXP__THEN_EXPRESSION;
case ExpressionsPackage.IF_EXP__ELSE_EXPRESSION :
return EcorePackage.IF_EXP__ELSE_EXPRESSION;
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, ?, ?, ?, ?, ?, ?, ?, ?>) v)
.visitIfExp(this);
}
} //IfExpImpl