/**
* <copyright>
* Copyright (c) 2008 Open Canarias 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: VarParameterImpl.java,v 1.3 2009/02/19 20:52:04 sboyko Exp $
*/
package org.eclipse.m2m.qvt.oml.ecore.QVTOperational.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.qvt.oml.ecore.QVTOperational.DirectionKind;
import org.eclipse.m2m.qvt.oml.ecore.QVTOperational.ImperativeOperation;
import org.eclipse.m2m.qvt.oml.ecore.QVTOperational.QVTOperationalPackage;
import org.eclipse.m2m.qvt.oml.ecore.QVTOperational.VarParameter;
import org.eclipse.ocl.ecore.impl.VariableImpl;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Var Parameter</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.m2m.qvt.oml.ecore.QVTOperational.impl.VarParameterImpl#getEOperation <em>EOperation</em>}</li>
* <li>{@link org.eclipse.m2m.qvt.oml.ecore.QVTOperational.impl.VarParameterImpl#getCtxOwner <em>Ctx Owner</em>}</li>
* <li>{@link org.eclipse.m2m.qvt.oml.ecore.QVTOperational.impl.VarParameterImpl#getKind <em>Kind</em>}</li>
* <li>{@link org.eclipse.m2m.qvt.oml.ecore.QVTOperational.impl.VarParameterImpl#getResOwner <em>Res Owner</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class VarParameterImpl extends VariableImpl implements VarParameter {
/**
* 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 QVTOperationalPackage.Literals.VAR_PARAMETER;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EOperation getEOperation() {
if (eContainerFeatureID() != QVTOperationalPackage.VAR_PARAMETER__EOPERATION) return null;
return (EOperation)eContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public ImperativeOperation getCtxOwner() {
if (eContainerFeatureID() != QVTOperationalPackage.VAR_PARAMETER__CTX_OWNER) return null;
return (ImperativeOperation)eContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetCtxOwner(ImperativeOperation newCtxOwner, NotificationChain msgs) {
msgs = eBasicSetContainer((InternalEObject)newCtxOwner, QVTOperationalPackage.VAR_PARAMETER__CTX_OWNER, msgs);
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setCtxOwner(ImperativeOperation newCtxOwner) {
if (newCtxOwner != eInternalContainer() || (eContainerFeatureID() != QVTOperationalPackage.VAR_PARAMETER__CTX_OWNER && newCtxOwner != null)) {
if (EcoreUtil.isAncestor(this, newCtxOwner))
throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
NotificationChain msgs = null;
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
if (newCtxOwner != null)
msgs = ((InternalEObject)newCtxOwner).eInverseAdd(this, QVTOperationalPackage.IMPERATIVE_OPERATION__CONTEXT, ImperativeOperation.class, msgs);
msgs = basicSetCtxOwner(newCtxOwner, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, QVTOperationalPackage.VAR_PARAMETER__CTX_OWNER, newCtxOwner, newCtxOwner));
}
/**
* <!-- 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, QVTOperationalPackage.VAR_PARAMETER__KIND, oldKind, kind));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public ImperativeOperation getResOwner() {
if (eContainerFeatureID() != QVTOperationalPackage.VAR_PARAMETER__RES_OWNER) return null;
return (ImperativeOperation)eContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetResOwner(ImperativeOperation newResOwner, NotificationChain msgs) {
msgs = eBasicSetContainer((InternalEObject)newResOwner, QVTOperationalPackage.VAR_PARAMETER__RES_OWNER, msgs);
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setResOwner(ImperativeOperation newResOwner) {
if (newResOwner != eInternalContainer() || (eContainerFeatureID() != QVTOperationalPackage.VAR_PARAMETER__RES_OWNER && newResOwner != null)) {
if (EcoreUtil.isAncestor(this, newResOwner))
throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
NotificationChain msgs = null;
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
if (newResOwner != null)
msgs = ((InternalEObject)newResOwner).eInverseAdd(this, QVTOperationalPackage.IMPERATIVE_OPERATION__RESULT, ImperativeOperation.class, msgs);
msgs = basicSetResOwner(newResOwner, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, QVTOperationalPackage.VAR_PARAMETER__RES_OWNER, newResOwner, newResOwner));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case QVTOperationalPackage.VAR_PARAMETER__EOPERATION:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return eBasicSetContainer(otherEnd, QVTOperationalPackage.VAR_PARAMETER__EOPERATION, msgs);
case QVTOperationalPackage.VAR_PARAMETER__CTX_OWNER:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetCtxOwner((ImperativeOperation)otherEnd, msgs);
case QVTOperationalPackage.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 QVTOperationalPackage.VAR_PARAMETER__EOPERATION:
return eBasicSetContainer(null, QVTOperationalPackage.VAR_PARAMETER__EOPERATION, msgs);
case QVTOperationalPackage.VAR_PARAMETER__CTX_OWNER:
return basicSetCtxOwner(null, msgs);
case QVTOperationalPackage.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 QVTOperationalPackage.VAR_PARAMETER__EOPERATION:
return eInternalContainer().eInverseRemove(this, EcorePackage.EOPERATION__EPARAMETERS, EOperation.class, msgs);
case QVTOperationalPackage.VAR_PARAMETER__CTX_OWNER:
return eInternalContainer().eInverseRemove(this, QVTOperationalPackage.IMPERATIVE_OPERATION__CONTEXT, ImperativeOperation.class, msgs);
case QVTOperationalPackage.VAR_PARAMETER__RES_OWNER:
return eInternalContainer().eInverseRemove(this, QVTOperationalPackage.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 QVTOperationalPackage.VAR_PARAMETER__EOPERATION:
return getEOperation();
case QVTOperationalPackage.VAR_PARAMETER__CTX_OWNER:
return getCtxOwner();
case QVTOperationalPackage.VAR_PARAMETER__KIND:
return getKind();
case QVTOperationalPackage.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 QVTOperationalPackage.VAR_PARAMETER__CTX_OWNER:
setCtxOwner((ImperativeOperation)newValue);
return;
case QVTOperationalPackage.VAR_PARAMETER__KIND:
setKind((DirectionKind)newValue);
return;
case QVTOperationalPackage.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 QVTOperationalPackage.VAR_PARAMETER__CTX_OWNER:
setCtxOwner((ImperativeOperation)null);
return;
case QVTOperationalPackage.VAR_PARAMETER__KIND:
setKind(KIND_EDEFAULT);
return;
case QVTOperationalPackage.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 QVTOperationalPackage.VAR_PARAMETER__EOPERATION:
return getEOperation() != null;
case QVTOperationalPackage.VAR_PARAMETER__CTX_OWNER:
return getCtxOwner() != null;
case QVTOperationalPackage.VAR_PARAMETER__KIND:
return kind != KIND_EDEFAULT;
case QVTOperationalPackage.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 QVTOperationalPackage.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 QVTOperationalPackage.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();
StringBuffer result = new StringBuffer(super.toString());
result.append(" (kind: ");
result.append(kind);
result.append(')');
return result.toString();
}
} //VarParameterImpl