blob: 8e108ef08bcafa4d11dedc3dcf2e20250cbd9af9 [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 org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EOperation;
import org.eclipse.emf.ecore.EParameter;
import org.eclipse.emf.ecore.EcorePackage;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.m2m.internal.qvt.oml.expressions.DirectionKind;
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.VarParameter;
import org.eclipse.ocl.ecore.impl.VariableImpl;
import org.eclipse.ocl.utilities.Visitor;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Var Parameter</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.m2m.internal.qvt.oml.expressions.impl.VarParameterImpl#getEOperation <em>EOperation</em>}</li>
* <li>{@link org.eclipse.m2m.internal.qvt.oml.expressions.impl.VarParameterImpl#getCtxOwner <em>Ctx Owner</em>}</li>
* <li>{@link org.eclipse.m2m.internal.qvt.oml.expressions.impl.VarParameterImpl#getKind <em>Kind</em>}</li>
* <li>{@link org.eclipse.m2m.internal.qvt.oml.expressions.impl.VarParameterImpl#getResOwner <em>Res Owner</em>}</li>
* </ul>
*
* @generated
*/
public class VarParameterImpl extends VariableImpl implements VarParameter {
/**
* <!-- 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 #getKind() <em>Kind</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getKind()
* @generated
* @ordered
*/
protected static final DirectionKind KIND_EDEFAULT = DirectionKind.IN;
/**
* The cached value of the '{@link #getKind() <em>Kind</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getKind()
* @generated
* @ordered
*/
protected DirectionKind kind = KIND_EDEFAULT;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected VarParameterImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return ExpressionsPackage.Literals.VAR_PARAMETER;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EOperation getEOperation() {
if (eContainerFeatureID() != ExpressionsPackage.VAR_PARAMETER__EOPERATION) return null;
return (EOperation)eInternalContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public ImperativeOperation getCtxOwner() {
if (eContainerFeatureID() != ExpressionsPackage.VAR_PARAMETER__CTX_OWNER) return null;
return (ImperativeOperation)eInternalContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetCtxOwner(ImperativeOperation newCtxOwner, NotificationChain msgs) {
msgs = eBasicSetContainer((InternalEObject)newCtxOwner, ExpressionsPackage.VAR_PARAMETER__CTX_OWNER, msgs);
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setCtxOwner(ImperativeOperation newCtxOwner) {
if (newCtxOwner != eInternalContainer() || (eContainerFeatureID() != ExpressionsPackage.VAR_PARAMETER__CTX_OWNER && newCtxOwner != null)) {
if (EcoreUtil.isAncestor(this, newCtxOwner))
throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); //$NON-NLS-1$
NotificationChain msgs = null;
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
if (newCtxOwner != null)
msgs = ((InternalEObject)newCtxOwner).eInverseAdd(this, ExpressionsPackage.IMPERATIVE_OPERATION__CONTEXT, ImperativeOperation.class, msgs);
msgs = basicSetCtxOwner(newCtxOwner, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ExpressionsPackage.VAR_PARAMETER__CTX_OWNER, newCtxOwner, newCtxOwner));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public ImperativeOperation getResOwner() {
if (eContainerFeatureID() != ExpressionsPackage.VAR_PARAMETER__RES_OWNER) return null;
return (ImperativeOperation)eInternalContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetResOwner(ImperativeOperation newResOwner, NotificationChain msgs) {
msgs = eBasicSetContainer((InternalEObject)newResOwner, ExpressionsPackage.VAR_PARAMETER__RES_OWNER, msgs);
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setResOwner(ImperativeOperation newResOwner) {
if (newResOwner != eInternalContainer() || (eContainerFeatureID() != ExpressionsPackage.VAR_PARAMETER__RES_OWNER && newResOwner != null)) {
if (EcoreUtil.isAncestor(this, newResOwner))
throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); //$NON-NLS-1$
NotificationChain msgs = null;
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
if (newResOwner != null)
msgs = ((InternalEObject)newResOwner).eInverseAdd(this, ExpressionsPackage.IMPERATIVE_OPERATION__RESULT, ImperativeOperation.class, msgs);
msgs = basicSetResOwner(newResOwner, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ExpressionsPackage.VAR_PARAMETER__RES_OWNER, newResOwner, newResOwner));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public DirectionKind getKind() {
return kind;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setKind(DirectionKind newKind) {
DirectionKind oldKind = kind;
kind = newKind == null ? KIND_EDEFAULT : newKind;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ExpressionsPackage.VAR_PARAMETER__KIND, oldKind, kind));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
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.visitVarParameter(this);
}
return org.eclipse.m2m.internal.qvt.oml.expressions.util.ForeignVisitorDefaultValue.getDefaultValueForVisitor(v);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case ExpressionsPackage.VAR_PARAMETER__EOPERATION:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return eBasicSetContainer(otherEnd, ExpressionsPackage.VAR_PARAMETER__EOPERATION, msgs);
case ExpressionsPackage.VAR_PARAMETER__CTX_OWNER:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetCtxOwner((ImperativeOperation)otherEnd, msgs);
case ExpressionsPackage.VAR_PARAMETER__RES_OWNER:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetResOwner((ImperativeOperation)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.VAR_PARAMETER__EOPERATION:
return eBasicSetContainer(null, ExpressionsPackage.VAR_PARAMETER__EOPERATION, msgs);
case ExpressionsPackage.VAR_PARAMETER__CTX_OWNER:
return basicSetCtxOwner(null, msgs);
case ExpressionsPackage.VAR_PARAMETER__RES_OWNER:
return basicSetResOwner(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
switch (eContainerFeatureID()) {
case ExpressionsPackage.VAR_PARAMETER__EOPERATION:
return eInternalContainer().eInverseRemove(this, EcorePackage.EOPERATION__EPARAMETERS, EOperation.class, msgs);
case ExpressionsPackage.VAR_PARAMETER__CTX_OWNER:
return eInternalContainer().eInverseRemove(this, ExpressionsPackage.IMPERATIVE_OPERATION__CONTEXT, ImperativeOperation.class, msgs);
case ExpressionsPackage.VAR_PARAMETER__RES_OWNER:
return eInternalContainer().eInverseRemove(this, ExpressionsPackage.IMPERATIVE_OPERATION__RESULT, ImperativeOperation.class, msgs);
}
return super.eBasicRemoveFromContainerFeature(msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case ExpressionsPackage.VAR_PARAMETER__EOPERATION:
return getEOperation();
case ExpressionsPackage.VAR_PARAMETER__CTX_OWNER:
return getCtxOwner();
case ExpressionsPackage.VAR_PARAMETER__KIND:
return getKind();
case ExpressionsPackage.VAR_PARAMETER__RES_OWNER:
return getResOwner();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case ExpressionsPackage.VAR_PARAMETER__CTX_OWNER:
setCtxOwner((ImperativeOperation)newValue);
return;
case ExpressionsPackage.VAR_PARAMETER__KIND:
setKind((DirectionKind)newValue);
return;
case ExpressionsPackage.VAR_PARAMETER__RES_OWNER:
setResOwner((ImperativeOperation)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case ExpressionsPackage.VAR_PARAMETER__CTX_OWNER:
setCtxOwner((ImperativeOperation)null);
return;
case ExpressionsPackage.VAR_PARAMETER__KIND:
setKind(KIND_EDEFAULT);
return;
case ExpressionsPackage.VAR_PARAMETER__RES_OWNER:
setResOwner((ImperativeOperation)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case ExpressionsPackage.VAR_PARAMETER__EOPERATION:
return getEOperation() != null;
case ExpressionsPackage.VAR_PARAMETER__CTX_OWNER:
return getCtxOwner() != null;
case ExpressionsPackage.VAR_PARAMETER__KIND:
return kind != KIND_EDEFAULT;
case ExpressionsPackage.VAR_PARAMETER__RES_OWNER:
return getResOwner() != null;
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) {
if (baseClass == EParameter.class) {
switch (derivedFeatureID) {
case ExpressionsPackage.VAR_PARAMETER__EOPERATION: return EcorePackage.EPARAMETER__EOPERATION;
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 == EParameter.class) {
switch (baseFeatureID) {
case EcorePackage.EPARAMETER__EOPERATION: return ExpressionsPackage.VAR_PARAMETER__EOPERATION;
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(" (kind: "); //$NON-NLS-1$
result.append(kind);
result.append(')');
return result.toString();
}
} //VarParameterImpl