| /** |
| * Copyright (c) 2010 xored software, Inc. |
| * |
| * This program and the accompanying materials are made available under the |
| * terms of the Eclipse Public License v. 2.0 which is available at |
| * http://www.eclipse.org/legal/epl-2.0. |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Contributors: |
| * xored software, Inc. - initial API and Implementation (Alex Panchenko) |
| * |
| * $Id: MethodImpl.java,v 1.5 2012/06/08 14:34:53 apanchenk Exp $ |
| */ |
| package org.eclipse.dltk.javascript.typeinfo.model.impl; |
| |
| import java.util.Collection; |
| |
| import org.eclipse.dltk.javascript.typeinfo.model.Method; |
| import org.eclipse.dltk.javascript.typeinfo.model.Parameter; |
| import org.eclipse.dltk.javascript.typeinfo.model.ParameterKind; |
| import org.eclipse.dltk.javascript.typeinfo.model.TypeInfoModelPackage; |
| 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; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Method</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * <ul> |
| * <li>{@link org.eclipse.dltk.javascript.typeinfo.model.impl.MethodImpl#getParameters <em>Parameters</em>}</li> |
| * <li>{@link org.eclipse.dltk.javascript.typeinfo.model.impl.MethodImpl#isAbstract <em>Abstract</em>}</li> |
| * </ul> |
| * </p> |
| * |
| * @generated |
| */ |
| public class MethodImpl extends MemberImpl implements Method { |
| /** |
| * The cached value of the '{@link #getParameters() <em>Parameters</em>}' containment reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getParameters() |
| * @generated |
| * @ordered |
| */ |
| protected EList<Parameter> parameters; |
| |
| /** |
| * The default value of the '{@link #isAbstract() <em>Abstract</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #isAbstract() |
| * @generated |
| * @ordered |
| */ |
| protected static final boolean ABSTRACT_EDEFAULT = false; |
| /** |
| * The cached value of the '{@link #isAbstract() <em>Abstract</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #isAbstract() |
| * @generated |
| * @ordered |
| */ |
| protected boolean abstract_ = ABSTRACT_EDEFAULT; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected MethodImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return TypeInfoModelPackage.Literals.METHOD; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EList<Parameter> getParameters() { |
| if (parameters == null) { |
| parameters = new EObjectContainmentEList<Parameter>(Parameter.class, this, TypeInfoModelPackage.METHOD__PARAMETERS); |
| } |
| return parameters; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public boolean isAbstract() { |
| return abstract_; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setAbstract(boolean newAbstract) { |
| boolean oldAbstract = abstract_; |
| abstract_ = newAbstract; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, TypeInfoModelPackage.METHOD__ABSTRACT, oldAbstract, abstract_)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * |
| * @generated NOT |
| */ |
| public Parameter getParameter(String name) { |
| for (Parameter parameter : getParameters()) { |
| if (name.equals(parameter.getName())) { |
| return parameter; |
| } |
| } |
| return null; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * |
| * @generated NOT |
| */ |
| public Parameter getParameterFor(int position) { |
| if (position < 0) { |
| return null; |
| } |
| final EList<Parameter> params = getParameters(); |
| if (position < params.size()) { |
| return params.get(position); |
| } else if (!params.isEmpty()) { |
| final Parameter last = params.get(params.size() - 1); |
| if (last.getKind() == ParameterKind.VARARGS) { |
| return last; |
| } |
| } |
| return null; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case TypeInfoModelPackage.METHOD__PARAMETERS: |
| return ((InternalEList<?>)getParameters()).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 TypeInfoModelPackage.METHOD__PARAMETERS: |
| return getParameters(); |
| case TypeInfoModelPackage.METHOD__ABSTRACT: |
| return isAbstract(); |
| } |
| 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 TypeInfoModelPackage.METHOD__PARAMETERS: |
| getParameters().clear(); |
| getParameters().addAll((Collection<? extends Parameter>)newValue); |
| return; |
| case TypeInfoModelPackage.METHOD__ABSTRACT: |
| setAbstract((Boolean)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case TypeInfoModelPackage.METHOD__PARAMETERS: |
| getParameters().clear(); |
| return; |
| case TypeInfoModelPackage.METHOD__ABSTRACT: |
| setAbstract(ABSTRACT_EDEFAULT); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case TypeInfoModelPackage.METHOD__PARAMETERS: |
| return parameters != null && !parameters.isEmpty(); |
| case TypeInfoModelPackage.METHOD__ABSTRACT: |
| return abstract_ != ABSTRACT_EDEFAULT; |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public String toString() { |
| if (eIsProxy()) return super.toString(); |
| |
| StringBuffer result = new StringBuffer(super.toString()); |
| result.append(" (abstract: "); //$NON-NLS-1$ |
| result.append(abstract_); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| } //MethodImpl |