/**
* <copyright>
* Copyright (c) 2008, 2009 Open Canarias S.L. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* A. Sanchez-Barbudo - initial API and implementation
* </copyright>
*
* $Id: ComputeExpImpl.java,v 1.3 2009/02/06 15:47:30 radvorak Exp $
*/
package org.eclipse.m2m.qvt.oml.ecore.ImperativeOCL.impl;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.m2m.qvt.oml.ecore.ImperativeOCL.ComputeExp;
import org.eclipse.m2m.qvt.oml.ecore.ImperativeOCL.ImperativeOCLPackage;
import org.eclipse.m2m.qvt.oml.ecore.ImperativeOCL.util.ImperativeOCLVisitor;
import org.eclipse.ocl.ecore.OCLExpression;
import org.eclipse.ocl.ecore.Variable;
import org.eclipse.ocl.utilities.Visitor;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Compute Exp</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.m2m.qvt.oml.ecore.ImperativeOCL.impl.ComputeExpImpl#getBody <em>Body</em>}</li>
* <li>{@link org.eclipse.m2m.qvt.oml.ecore.ImperativeOCL.impl.ComputeExpImpl#getReturnedElement <em>Returned Element</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class ComputeExpImpl extends ImperativeExpressionImpl implements ComputeExp {
/**
* The cached value of the '{@link #getBody() <em>Body</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getBody()
* @generated
* @ordered
*/
protected OCLExpression body;
/**
* The cached value of the '{@link #getReturnedElement() <em>Returned Element</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getReturnedElement()
* @generated
* @ordered
*/
protected Variable returnedElement;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected ComputeExpImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return ImperativeOCLPackage.Literals.COMPUTE_EXP;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public OCLExpression getBody() {
return body;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetBody(OCLExpression newBody, NotificationChain msgs) {
OCLExpression oldBody = body;
body = newBody;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ImperativeOCLPackage.COMPUTE_EXP__BODY, oldBody, newBody);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setBody(OCLExpression newBody) {
if (newBody != body) {
NotificationChain msgs = null;
if (body != null)
msgs = ((InternalEObject)body).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ImperativeOCLPackage.COMPUTE_EXP__BODY, null, msgs);
if (newBody != null)
msgs = ((InternalEObject)newBody).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ImperativeOCLPackage.COMPUTE_EXP__BODY, null, msgs);
msgs = basicSetBody(newBody, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ImperativeOCLPackage.COMPUTE_EXP__BODY, newBody, newBody));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Variable getReturnedElement() {
return returnedElement;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetReturnedElement(Variable newReturnedElement, NotificationChain msgs) {
Variable oldReturnedElement = returnedElement;
returnedElement = newReturnedElement;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ImperativeOCLPackage.COMPUTE_EXP__RETURNED_ELEMENT, oldReturnedElement, newReturnedElement);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setReturnedElement(Variable newReturnedElement) {
if (newReturnedElement != returnedElement) {
NotificationChain msgs = null;
if (returnedElement != null)
msgs = ((InternalEObject)returnedElement).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ImperativeOCLPackage.COMPUTE_EXP__RETURNED_ELEMENT, null, msgs);
if (newReturnedElement != null)
msgs = ((InternalEObject)newReturnedElement).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ImperativeOCLPackage.COMPUTE_EXP__RETURNED_ELEMENT, null, msgs);
msgs = basicSetReturnedElement(newReturnedElement, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ImperativeOCLPackage.COMPUTE_EXP__RETURNED_ELEMENT, newReturnedElement, newReturnedElement));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case ImperativeOCLPackage.COMPUTE_EXP__BODY:
return basicSetBody(null, msgs);
case ImperativeOCLPackage.COMPUTE_EXP__RETURNED_ELEMENT:
return basicSetReturnedElement(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 ImperativeOCLPackage.COMPUTE_EXP__BODY:
return getBody();
case ImperativeOCLPackage.COMPUTE_EXP__RETURNED_ELEMENT:
return getReturnedElement();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case ImperativeOCLPackage.COMPUTE_EXP__BODY:
setBody((OCLExpression)newValue);
return;
case ImperativeOCLPackage.COMPUTE_EXP__RETURNED_ELEMENT:
setReturnedElement((Variable)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case ImperativeOCLPackage.COMPUTE_EXP__BODY:
setBody((OCLExpression)null);
return;
case ImperativeOCLPackage.COMPUTE_EXP__RETURNED_ELEMENT:
setReturnedElement((Variable)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case ImperativeOCLPackage.COMPUTE_EXP__BODY:
return body != null;
case ImperativeOCLPackage.COMPUTE_EXP__RETURNED_ELEMENT:
return returnedElement != null;
}
return super.eIsSet(featureID);
}
/**
* @generated NOT
*/
@SuppressWarnings("unchecked")
@Override
public <T, U extends Visitor<T, ?, ?, ?, ?, ?, ?, ?, ?, ?>> T accept(U v) {
if (v instanceof ImperativeOCLVisitor)
return (T) ((ImperativeOCLVisitor) v).visitComputeExp(this);
return super.<T, U>accept(v);
}
} //ComputeExpImpl