blob: b306214d34c1ea41a6b97078c8fe772c8092458b [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2007, 2018 Borland Software Corporation 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:
* Borland Software Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.m2m.internal.qvt.oml.expressions.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.impl.EOperationImpl;
import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.m2m.internal.qvt.oml.expressions.ExpressionsPackage;
import org.eclipse.m2m.internal.qvt.oml.expressions.ImperativeOperation;
import org.eclipse.m2m.internal.qvt.oml.expressions.OperationBody;
import org.eclipse.m2m.internal.qvt.oml.expressions.VarParameter;
import org.eclipse.m2m.internal.qvt.oml.expressions.VisitableASTNode;
import org.eclipse.ocl.utilities.ASTNode;
import org.eclipse.ocl.utilities.UtilitiesPackage;
import org.eclipse.ocl.utilities.Visitable;
import org.eclipse.ocl.utilities.Visitor;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Imperative Operation</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.m2m.internal.qvt.oml.expressions.impl.ImperativeOperationImpl#getStartPosition <em>Start Position</em>}</li>
* <li>{@link org.eclipse.m2m.internal.qvt.oml.expressions.impl.ImperativeOperationImpl#getEndPosition <em>End Position</em>}</li>
* <li>{@link org.eclipse.m2m.internal.qvt.oml.expressions.impl.ImperativeOperationImpl#getBody <em>Body</em>}</li>
* <li>{@link org.eclipse.m2m.internal.qvt.oml.expressions.impl.ImperativeOperationImpl#getContext <em>Context</em>}</li>
* <li>{@link org.eclipse.m2m.internal.qvt.oml.expressions.impl.ImperativeOperationImpl#isIsBlackbox <em>Is Blackbox</em>}</li>
* <li>{@link org.eclipse.m2m.internal.qvt.oml.expressions.impl.ImperativeOperationImpl#getOverridden <em>Overridden</em>}</li>
* <li>{@link org.eclipse.m2m.internal.qvt.oml.expressions.impl.ImperativeOperationImpl#getResult <em>Result</em>}</li>
* </ul>
*
* @generated
*/
public class ImperativeOperationImpl extends EOperationImpl implements ImperativeOperation {
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public static final String copyright = "Copyright (c) 2007 Borland Software Corporation\r\n\r\nAll rights reserved. This program and the accompanying materials\r\nare made available under the terms of the Eclipse Public License v2.0\r\nwhich accompanies this distribution, and is available at\r\nhttp://www.eclipse.org/legal/epl-v20.html\r\n \r\nContributors:\r\n Borland Software Corporation - initial API and implementation"; //$NON-NLS-1$
/**
* The default value of the '{@link #getStartPosition() <em>Start Position</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getStartPosition()
* @generated
* @ordered
*/
protected static final int START_POSITION_EDEFAULT = -1;
/**
* The cached value of the '{@link #getStartPosition() <em>Start Position</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getStartPosition()
* @generated
* @ordered
*/
protected int startPosition = START_POSITION_EDEFAULT;
/**
* The default value of the '{@link #getEndPosition() <em>End Position</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getEndPosition()
* @generated
* @ordered
*/
protected static final int END_POSITION_EDEFAULT = -1;
/**
* The cached value of the '{@link #getEndPosition() <em>End Position</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getEndPosition()
* @generated
* @ordered
*/
protected int endPosition = END_POSITION_EDEFAULT;
/**
* The cached value of the '{@link #getBody() <em>Body</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getBody()
* @generated
* @ordered
*/
protected OperationBody body;
/**
* The cached value of the '{@link #getContext() <em>Context</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getContext()
* @generated
* @ordered
*/
protected VarParameter context;
/**
* The default value of the '{@link #isIsBlackbox() <em>Is Blackbox</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #isIsBlackbox()
* @generated
* @ordered
*/
protected static final boolean IS_BLACKBOX_EDEFAULT = false;
/**
* The flag representing the value of the '{@link #isIsBlackbox() <em>Is Blackbox</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #isIsBlackbox()
* @generated
* @ordered
*/
protected static final int IS_BLACKBOX_EFLAG = 1 << 10;
/**
* The cached value of the '{@link #getOverridden() <em>Overridden</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getOverridden()
* @generated
* @ordered
*/
protected ImperativeOperation overridden;
/**
* The cached value of the '{@link #getResult() <em>Result</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getResult()
* @generated
* @ordered
*/
protected EList<VarParameter> result;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected ImperativeOperationImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return ExpressionsPackage.Literals.IMPERATIVE_OPERATION;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public int getStartPosition() {
return startPosition;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setStartPosition(int newStartPosition) {
int oldStartPosition = startPosition;
startPosition = newStartPosition;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ExpressionsPackage.IMPERATIVE_OPERATION__START_POSITION, oldStartPosition, startPosition));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public int getEndPosition() {
return endPosition;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setEndPosition(int newEndPosition) {
int oldEndPosition = endPosition;
endPosition = newEndPosition;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ExpressionsPackage.IMPERATIVE_OPERATION__END_POSITION, oldEndPosition, endPosition));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public VarParameter getContext() {
return context;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetContext(VarParameter newContext, NotificationChain msgs) {
VarParameter oldContext = context;
context = newContext;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ExpressionsPackage.IMPERATIVE_OPERATION__CONTEXT, oldContext, newContext);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setContext(VarParameter newContext) {
if (newContext != context) {
NotificationChain msgs = null;
if (context != null)
msgs = ((InternalEObject)context).eInverseRemove(this, ExpressionsPackage.VAR_PARAMETER__CTX_OWNER, VarParameter.class, msgs);
if (newContext != null)
msgs = ((InternalEObject)newContext).eInverseAdd(this, ExpressionsPackage.VAR_PARAMETER__CTX_OWNER, VarParameter.class, msgs);
msgs = basicSetContext(newContext, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ExpressionsPackage.IMPERATIVE_OPERATION__CONTEXT, newContext, newContext));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<VarParameter> getResult() {
if (result == null) {
result = new EObjectContainmentWithInverseEList<VarParameter>(VarParameter.class, this, ExpressionsPackage.IMPERATIVE_OPERATION__RESULT, ExpressionsPackage.VAR_PARAMETER__RES_OWNER);
}
return result;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public OperationBody getBody() {
return body;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetBody(OperationBody newBody, NotificationChain msgs) {
OperationBody oldBody = body;
body = newBody;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ExpressionsPackage.IMPERATIVE_OPERATION__BODY, oldBody, newBody);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setBody(OperationBody newBody) {
if (newBody != body) {
NotificationChain msgs = null;
if (body != null)
msgs = ((InternalEObject)body).eInverseRemove(this, ExpressionsPackage.OPERATION_BODY__OPERATION, OperationBody.class, msgs);
if (newBody != null)
msgs = ((InternalEObject)newBody).eInverseAdd(this, ExpressionsPackage.OPERATION_BODY__OPERATION, OperationBody.class, msgs);
msgs = basicSetBody(newBody, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ExpressionsPackage.IMPERATIVE_OPERATION__BODY, newBody, newBody));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public boolean isIsBlackbox() {
return (eFlags & IS_BLACKBOX_EFLAG) != 0;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setIsBlackbox(boolean newIsBlackbox) {
boolean oldIsBlackbox = (eFlags & IS_BLACKBOX_EFLAG) != 0;
if (newIsBlackbox) eFlags |= IS_BLACKBOX_EFLAG; else eFlags &= ~IS_BLACKBOX_EFLAG;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ExpressionsPackage.IMPERATIVE_OPERATION__IS_BLACKBOX, oldIsBlackbox, newIsBlackbox));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public ImperativeOperation getOverridden() {
if (overridden != null && overridden.eIsProxy()) {
InternalEObject oldOverridden = (InternalEObject)overridden;
overridden = (ImperativeOperation)eResolveProxy(oldOverridden);
if (overridden != oldOverridden) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, ExpressionsPackage.IMPERATIVE_OPERATION__OVERRIDDEN, oldOverridden, overridden));
}
}
return overridden;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public ImperativeOperation basicGetOverridden() {
return overridden;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setOverridden(ImperativeOperation newOverridden) {
ImperativeOperation oldOverridden = overridden;
overridden = newOverridden;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ExpressionsPackage.IMPERATIVE_OPERATION__OVERRIDDEN, oldOverridden, overridden));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public <T, U extends Visitor<T, ?, ?, ?, ?, ?, ?, ?, ?, ?>> T accept(final U v) {
if(v instanceof org.eclipse.m2m.internal.qvt.oml.expressions.util.QVTOperationalVisitor) {
@SuppressWarnings("unchecked")
org.eclipse.m2m.internal.qvt.oml.expressions.util.QVTOperationalVisitor<T> visitorExt = (org.eclipse.m2m.internal.qvt.oml.expressions.util.QVTOperationalVisitor) v;
return visitorExt.visitImperativeOperation(this);
}
return org.eclipse.m2m.internal.qvt.oml.expressions.util.ForeignVisitorDefaultValue.getDefaultValueForVisitor(v);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case ExpressionsPackage.IMPERATIVE_OPERATION__BODY:
if (body != null)
msgs = ((InternalEObject)body).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ExpressionsPackage.IMPERATIVE_OPERATION__BODY, null, msgs);
return basicSetBody((OperationBody)otherEnd, msgs);
case ExpressionsPackage.IMPERATIVE_OPERATION__CONTEXT:
if (context != null)
msgs = ((InternalEObject)context).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ExpressionsPackage.IMPERATIVE_OPERATION__CONTEXT, null, msgs);
return basicSetContext((VarParameter)otherEnd, msgs);
case ExpressionsPackage.IMPERATIVE_OPERATION__RESULT:
return ((InternalEList<InternalEObject>)(InternalEList<?>)getResult()).basicAdd(otherEnd, msgs);
}
return super.eInverseAdd(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case ExpressionsPackage.IMPERATIVE_OPERATION__BODY:
return basicSetBody(null, msgs);
case ExpressionsPackage.IMPERATIVE_OPERATION__CONTEXT:
return basicSetContext(null, msgs);
case ExpressionsPackage.IMPERATIVE_OPERATION__RESULT:
return ((InternalEList<?>)getResult()).basicRemove(otherEnd, 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 ExpressionsPackage.IMPERATIVE_OPERATION__START_POSITION:
return getStartPosition();
case ExpressionsPackage.IMPERATIVE_OPERATION__END_POSITION:
return getEndPosition();
case ExpressionsPackage.IMPERATIVE_OPERATION__BODY:
return getBody();
case ExpressionsPackage.IMPERATIVE_OPERATION__CONTEXT:
return getContext();
case ExpressionsPackage.IMPERATIVE_OPERATION__IS_BLACKBOX:
return isIsBlackbox();
case ExpressionsPackage.IMPERATIVE_OPERATION__OVERRIDDEN:
if (resolve) return getOverridden();
return basicGetOverridden();
case ExpressionsPackage.IMPERATIVE_OPERATION__RESULT:
return getResult();
}
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 ExpressionsPackage.IMPERATIVE_OPERATION__START_POSITION:
setStartPosition((Integer)newValue);
return;
case ExpressionsPackage.IMPERATIVE_OPERATION__END_POSITION:
setEndPosition((Integer)newValue);
return;
case ExpressionsPackage.IMPERATIVE_OPERATION__BODY:
setBody((OperationBody)newValue);
return;
case ExpressionsPackage.IMPERATIVE_OPERATION__CONTEXT:
setContext((VarParameter)newValue);
return;
case ExpressionsPackage.IMPERATIVE_OPERATION__IS_BLACKBOX:
setIsBlackbox((Boolean)newValue);
return;
case ExpressionsPackage.IMPERATIVE_OPERATION__OVERRIDDEN:
setOverridden((ImperativeOperation)newValue);
return;
case ExpressionsPackage.IMPERATIVE_OPERATION__RESULT:
getResult().clear();
getResult().addAll((Collection<? extends VarParameter>)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case ExpressionsPackage.IMPERATIVE_OPERATION__START_POSITION:
setStartPosition(START_POSITION_EDEFAULT);
return;
case ExpressionsPackage.IMPERATIVE_OPERATION__END_POSITION:
setEndPosition(END_POSITION_EDEFAULT);
return;
case ExpressionsPackage.IMPERATIVE_OPERATION__BODY:
setBody((OperationBody)null);
return;
case ExpressionsPackage.IMPERATIVE_OPERATION__CONTEXT:
setContext((VarParameter)null);
return;
case ExpressionsPackage.IMPERATIVE_OPERATION__IS_BLACKBOX:
setIsBlackbox(IS_BLACKBOX_EDEFAULT);
return;
case ExpressionsPackage.IMPERATIVE_OPERATION__OVERRIDDEN:
setOverridden((ImperativeOperation)null);
return;
case ExpressionsPackage.IMPERATIVE_OPERATION__RESULT:
getResult().clear();
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case ExpressionsPackage.IMPERATIVE_OPERATION__START_POSITION:
return startPosition != START_POSITION_EDEFAULT;
case ExpressionsPackage.IMPERATIVE_OPERATION__END_POSITION:
return endPosition != END_POSITION_EDEFAULT;
case ExpressionsPackage.IMPERATIVE_OPERATION__BODY:
return body != null;
case ExpressionsPackage.IMPERATIVE_OPERATION__CONTEXT:
return context != null;
case ExpressionsPackage.IMPERATIVE_OPERATION__IS_BLACKBOX:
return ((eFlags & IS_BLACKBOX_EFLAG) != 0) != IS_BLACKBOX_EDEFAULT;
case ExpressionsPackage.IMPERATIVE_OPERATION__OVERRIDDEN:
return overridden != null;
case ExpressionsPackage.IMPERATIVE_OPERATION__RESULT:
return result != null && !result.isEmpty();
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) {
if (baseClass == Visitable.class) {
switch (derivedFeatureID) {
default: return -1;
}
}
if (baseClass == ASTNode.class) {
switch (derivedFeatureID) {
case ExpressionsPackage.IMPERATIVE_OPERATION__START_POSITION: return UtilitiesPackage.AST_NODE__START_POSITION;
case ExpressionsPackage.IMPERATIVE_OPERATION__END_POSITION: return UtilitiesPackage.AST_NODE__END_POSITION;
default: return -1;
}
}
if (baseClass == VisitableASTNode.class) {
switch (derivedFeatureID) {
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 == Visitable.class) {
switch (baseFeatureID) {
default: return -1;
}
}
if (baseClass == ASTNode.class) {
switch (baseFeatureID) {
case UtilitiesPackage.AST_NODE__START_POSITION: return ExpressionsPackage.IMPERATIVE_OPERATION__START_POSITION;
case UtilitiesPackage.AST_NODE__END_POSITION: return ExpressionsPackage.IMPERATIVE_OPERATION__END_POSITION;
default: return -1;
}
}
if (baseClass == VisitableASTNode.class) {
switch (baseFeatureID) {
default: return -1;
}
}
return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public String toString() {
if (eIsProxy()) return super.toString();
StringBuilder result = new StringBuilder(super.toString());
result.append(" (startPosition: "); //$NON-NLS-1$
result.append(startPosition);
result.append(", endPosition: "); //$NON-NLS-1$
result.append(endPosition);
result.append(", isBlackbox: "); //$NON-NLS-1$
result.append((eFlags & IS_BLACKBOX_EFLAG) != 0);
result.append(')');
return result.toString();
}
} //ImperativeOperationImpl