/******************************************************************************* * Copyright (c) 2004, 2005 IBM Corporation 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: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jem.internal.instantiation.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.EStructuralFeature; 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.jem.internal.instantiation.*; import org.eclipse.jem.internal.instantiation.PTExpression; import org.eclipse.jem.internal.instantiation.InstantiationPackage; import org.eclipse.jem.internal.instantiation.PTMethodInvocation; /** * <!-- 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.jem.internal.instantiation.impl.PTMethodInvocationImpl#getReceiver <em>Receiver</em>}</li> * <li>{@link org.eclipse.jem.internal.instantiation.impl.PTMethodInvocationImpl#getName <em>Name</em>}</li> * <li>{@link org.eclipse.jem.internal.instantiation.impl.PTMethodInvocationImpl#getArguments <em>Arguments</em>}</li> * </ul> * </p> * * @generated */ public class PTMethodInvocationImpl extends PTExpressionImpl implements PTMethodInvocation { /** * The cached value of the '{@link #getReceiver() <em>Receiver</em>}' containment reference. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getReceiver() * @generated * @ordered */ protected PTExpression receiver = null; /** * The default value of the '{@link #getName() <em>Name</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getName() * @generated * @ordered */ protected static final String NAME_EDEFAULT = null; /** * The cached value of the '{@link #getName() <em>Name</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getName() * @generated * @ordered */ protected String name = NAME_EDEFAULT; /** * 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 arguments = null; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected PTMethodInvocationImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected EClass eStaticClass() { return InstantiationPackage.eINSTANCE.getPTMethodInvocation(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public PTExpression getReceiver() { return receiver; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain basicSetReceiver(PTExpression newReceiver, NotificationChain msgs) { PTExpression oldReceiver = receiver; receiver = newReceiver; if (eNotificationRequired()) { ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, InstantiationPackage.PT_METHOD_INVOCATION__RECEIVER, oldReceiver, newReceiver); if (msgs == null) msgs = notification; else msgs.add(notification); } return msgs; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setReceiver(PTExpression newReceiver) { if (newReceiver != receiver) { NotificationChain msgs = null; if (receiver != null) msgs = ((InternalEObject)receiver).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - InstantiationPackage.PT_METHOD_INVOCATION__RECEIVER, null, msgs); if (newReceiver != null) msgs = ((InternalEObject)newReceiver).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - InstantiationPackage.PT_METHOD_INVOCATION__RECEIVER, null, msgs); msgs = basicSetReceiver(newReceiver, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, InstantiationPackage.PT_METHOD_INVOCATION__RECEIVER, newReceiver, newReceiver)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public String getName() { return name; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setName(String newName) { String oldName = name; name = newName; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, InstantiationPackage.PT_METHOD_INVOCATION__NAME, oldName, name)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EList getArguments() { if (arguments == null) { arguments = new EObjectContainmentEList(PTExpression.class, this, InstantiationPackage.PT_METHOD_INVOCATION__ARGUMENTS); } return arguments; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) { if (featureID >= 0) { switch (eDerivedStructuralFeatureID(featureID, baseClass)) { case InstantiationPackage.PT_METHOD_INVOCATION__RECEIVER: return basicSetReceiver(null, msgs); case InstantiationPackage.PT_METHOD_INVOCATION__ARGUMENTS: return ((InternalEList)getArguments()).basicRemove(otherEnd, msgs); default: return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs); } } return eBasicSetContainer(null, featureID, msgs); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Object eGet(EStructuralFeature eFeature, boolean resolve) { switch (eDerivedStructuralFeatureID(eFeature)) { case InstantiationPackage.PT_METHOD_INVOCATION__RECEIVER: return getReceiver(); case InstantiationPackage.PT_METHOD_INVOCATION__NAME: return getName(); case InstantiationPackage.PT_METHOD_INVOCATION__ARGUMENTS: return getArguments(); } return eDynamicGet(eFeature, resolve); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void eSet(EStructuralFeature eFeature, Object newValue) { switch (eDerivedStructuralFeatureID(eFeature)) { case InstantiationPackage.PT_METHOD_INVOCATION__RECEIVER: setReceiver((PTExpression)newValue); return; case InstantiationPackage.PT_METHOD_INVOCATION__NAME: setName((String)newValue); return; case InstantiationPackage.PT_METHOD_INVOCATION__ARGUMENTS: getArguments().clear(); getArguments().addAll((Collection)newValue); return; } eDynamicSet(eFeature, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void eUnset(EStructuralFeature eFeature) { switch (eDerivedStructuralFeatureID(eFeature)) { case InstantiationPackage.PT_METHOD_INVOCATION__RECEIVER: setReceiver((PTExpression)null); return; case InstantiationPackage.PT_METHOD_INVOCATION__NAME: setName(NAME_EDEFAULT); return; case InstantiationPackage.PT_METHOD_INVOCATION__ARGUMENTS: getArguments().clear(); return; } eDynamicUnset(eFeature); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public boolean eIsSet(EStructuralFeature eFeature) { switch (eDerivedStructuralFeatureID(eFeature)) { case InstantiationPackage.PT_METHOD_INVOCATION__RECEIVER: return receiver != null; case InstantiationPackage.PT_METHOD_INVOCATION__NAME: return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); case InstantiationPackage.PT_METHOD_INVOCATION__ARGUMENTS: return arguments != null && !arguments.isEmpty(); } return eDynamicIsSet(eFeature); } public String toString() { return super.toString(); // Really want toString to be final at PTExpression, but EMF doesn't allow it. } /* * (non-Javadoc) * @see org.eclipse.jem.internal.instantiation.impl.ExpressionImpl#accept0(org.eclipse.jem.internal.instantiation.ParseVisitor) */ protected void accept0(ParseVisitor visitor) { boolean visitChildren = visitor.visit(this); if (visitChildren) { // visit children in normal left to right reading order acceptChild(visitor, getReceiver()); acceptChildren(visitor, arguments); } visitor.endVisit(this); } } //MethodInvocationImpl