blob: 0ce70f2385bc1bf31410e4d1082f7aadcbe02e91 [file] [log] [blame]
/**
* *******************************************************************************
* Copyright (c) 2009 Mia-Software.
* 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:
*
* Fabien Giquel (Mia-Software) - initial API and implementation
* *******************************************************************************
*
* $Id$
*/
package org.eclipse.gmt.modisco.java.emf.classic.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.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.gmt.modisco.java.AbstractMethodDeclaration;
import org.eclipse.gmt.modisco.java.AbstractMethodInvocation;
import org.eclipse.gmt.modisco.java.Expression;
import org.eclipse.gmt.modisco.java.MethodInvocation;
import org.eclipse.gmt.modisco.java.TypeAccess;
import org.eclipse.gmt.modisco.java.emf.classic.JavaPackage;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Method Invocation</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.gmt.modisco.java.emf.classic.impl.MethodInvocationImpl#getMethod <em>Method</em>}</li>
* <li>{@link org.eclipse.gmt.modisco.java.emf.classic.impl.MethodInvocationImpl#getArguments <em>Arguments</em>}</li>
* <li>{@link org.eclipse.gmt.modisco.java.emf.classic.impl.MethodInvocationImpl#getTypeArguments <em>Type Arguments</em>}</li>
* <li>{@link org.eclipse.gmt.modisco.java.emf.classic.impl.MethodInvocationImpl#getExpression <em>Expression</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class MethodInvocationImpl extends ExpressionImpl implements MethodInvocation {
/**
* The cached value of the '{@link #getMethod() <em>Method</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getMethod()
* @generated
* @ordered
*/
protected AbstractMethodDeclaration method;
/**
* The cached value of the '{@link #getArguments() <em>Arguments</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getArguments()
* @generated
* @ordered
*/
protected EList<Expression> arguments;
/**
* The cached value of the '{@link #getTypeArguments() <em>Type Arguments</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getTypeArguments()
* @generated
* @ordered
*/
protected EList<TypeAccess> typeArguments;
/**
* The cached value of the '{@link #getExpression() <em>Expression</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getExpression()
* @generated
* @ordered
*/
protected Expression expression;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected MethodInvocationImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return JavaPackage.eINSTANCE.getMethodInvocation();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public AbstractMethodDeclaration getMethod() {
if (method != null && method.eIsProxy()) {
InternalEObject oldMethod = (InternalEObject)method;
method = (AbstractMethodDeclaration)eResolveProxy(oldMethod);
if (method != oldMethod) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, JavaPackage.METHOD_INVOCATION__METHOD, oldMethod, method));
}
}
return method;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public AbstractMethodDeclaration basicGetMethod() {
return method;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetMethod(AbstractMethodDeclaration newMethod, NotificationChain msgs) {
AbstractMethodDeclaration oldMethod = method;
method = newMethod;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, JavaPackage.METHOD_INVOCATION__METHOD, oldMethod, newMethod);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setMethod(AbstractMethodDeclaration newMethod) {
if (newMethod != method) {
NotificationChain msgs = null;
if (method != null)
msgs = ((InternalEObject)method).eInverseRemove(this, JavaPackage.ABSTRACT_METHOD_DECLARATION__USAGES, AbstractMethodDeclaration.class, msgs);
if (newMethod != null)
msgs = ((InternalEObject)newMethod).eInverseAdd(this, JavaPackage.ABSTRACT_METHOD_DECLARATION__USAGES, AbstractMethodDeclaration.class, msgs);
msgs = basicSetMethod(newMethod, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, JavaPackage.METHOD_INVOCATION__METHOD, newMethod, newMethod));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<Expression> getArguments() {
if (arguments == null) {
arguments = new EObjectContainmentEList<Expression>(Expression.class, this, JavaPackage.METHOD_INVOCATION__ARGUMENTS);
}
return arguments;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<TypeAccess> getTypeArguments() {
if (typeArguments == null) {
typeArguments = new EObjectContainmentEList<TypeAccess>(TypeAccess.class, this, JavaPackage.METHOD_INVOCATION__TYPE_ARGUMENTS);
}
return typeArguments;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Expression getExpression() {
return expression;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetExpression(Expression newExpression, NotificationChain msgs) {
Expression oldExpression = expression;
expression = newExpression;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, JavaPackage.METHOD_INVOCATION__EXPRESSION, oldExpression, newExpression);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setExpression(Expression newExpression) {
if (newExpression != expression) {
NotificationChain msgs = null;
if (expression != null)
msgs = ((InternalEObject)expression).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - JavaPackage.METHOD_INVOCATION__EXPRESSION, null, msgs);
if (newExpression != null)
msgs = ((InternalEObject)newExpression).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - JavaPackage.METHOD_INVOCATION__EXPRESSION, null, msgs);
msgs = basicSetExpression(newExpression, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, JavaPackage.METHOD_INVOCATION__EXPRESSION, newExpression, newExpression));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case JavaPackage.METHOD_INVOCATION__METHOD:
if (method != null)
msgs = ((InternalEObject)method).eInverseRemove(this, JavaPackage.ABSTRACT_METHOD_DECLARATION__USAGES, AbstractMethodDeclaration.class, msgs);
return basicSetMethod((AbstractMethodDeclaration)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 JavaPackage.METHOD_INVOCATION__METHOD:
return basicSetMethod(null, msgs);
case JavaPackage.METHOD_INVOCATION__ARGUMENTS:
return ((InternalEList<?>)getArguments()).basicRemove(otherEnd, msgs);
case JavaPackage.METHOD_INVOCATION__TYPE_ARGUMENTS:
return ((InternalEList<?>)getTypeArguments()).basicRemove(otherEnd, msgs);
case JavaPackage.METHOD_INVOCATION__EXPRESSION:
return basicSetExpression(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 JavaPackage.METHOD_INVOCATION__METHOD:
if (resolve) return getMethod();
return basicGetMethod();
case JavaPackage.METHOD_INVOCATION__ARGUMENTS:
return getArguments();
case JavaPackage.METHOD_INVOCATION__TYPE_ARGUMENTS:
return getTypeArguments();
case JavaPackage.METHOD_INVOCATION__EXPRESSION:
return getExpression();
}
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 JavaPackage.METHOD_INVOCATION__METHOD:
setMethod((AbstractMethodDeclaration)newValue);
return;
case JavaPackage.METHOD_INVOCATION__ARGUMENTS:
getArguments().clear();
getArguments().addAll((Collection<? extends Expression>)newValue);
return;
case JavaPackage.METHOD_INVOCATION__TYPE_ARGUMENTS:
getTypeArguments().clear();
getTypeArguments().addAll((Collection<? extends TypeAccess>)newValue);
return;
case JavaPackage.METHOD_INVOCATION__EXPRESSION:
setExpression((Expression)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case JavaPackage.METHOD_INVOCATION__METHOD:
setMethod((AbstractMethodDeclaration)null);
return;
case JavaPackage.METHOD_INVOCATION__ARGUMENTS:
getArguments().clear();
return;
case JavaPackage.METHOD_INVOCATION__TYPE_ARGUMENTS:
getTypeArguments().clear();
return;
case JavaPackage.METHOD_INVOCATION__EXPRESSION:
setExpression((Expression)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case JavaPackage.METHOD_INVOCATION__METHOD:
return method != null;
case JavaPackage.METHOD_INVOCATION__ARGUMENTS:
return arguments != null && !arguments.isEmpty();
case JavaPackage.METHOD_INVOCATION__TYPE_ARGUMENTS:
return typeArguments != null && !typeArguments.isEmpty();
case JavaPackage.METHOD_INVOCATION__EXPRESSION:
return expression != null;
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) {
if (baseClass == AbstractMethodInvocation.class) {
switch (derivedFeatureID) {
case JavaPackage.METHOD_INVOCATION__METHOD: return JavaPackage.ABSTRACT_METHOD_INVOCATION__METHOD;
case JavaPackage.METHOD_INVOCATION__ARGUMENTS: return JavaPackage.ABSTRACT_METHOD_INVOCATION__ARGUMENTS;
case JavaPackage.METHOD_INVOCATION__TYPE_ARGUMENTS: return JavaPackage.ABSTRACT_METHOD_INVOCATION__TYPE_ARGUMENTS;
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 == AbstractMethodInvocation.class) {
switch (baseFeatureID) {
case JavaPackage.ABSTRACT_METHOD_INVOCATION__METHOD: return JavaPackage.METHOD_INVOCATION__METHOD;
case JavaPackage.ABSTRACT_METHOD_INVOCATION__ARGUMENTS: return JavaPackage.METHOD_INVOCATION__ARGUMENTS;
case JavaPackage.ABSTRACT_METHOD_INVOCATION__TYPE_ARGUMENTS: return JavaPackage.METHOD_INVOCATION__TYPE_ARGUMENTS;
default: return -1;
}
}
return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass);
}
} //MethodInvocationImpl