| /** |
| * Copyright (c) 2011-2012 Eclipse contributors 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 |
| */ |
| package org.eclipse.emf.ecore.xcore.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.EObjectContainmentWithInverseEList; |
| import org.eclipse.emf.ecore.util.InternalEList; |
| |
| import org.eclipse.emf.ecore.xcore.XGenericType; |
| import org.eclipse.emf.ecore.xcore.XOperation; |
| import org.eclipse.emf.ecore.xcore.XParameter; |
| import org.eclipse.emf.ecore.xcore.XTypeParameter; |
| import org.eclipse.emf.ecore.xcore.XcorePackage; |
| |
| import org.eclipse.xtext.xbase.XBlockExpression; |
| |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>XOperation</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.emf.ecore.xcore.impl.XOperationImpl#getTypeParameters <em>Type Parameters</em>}</li> |
| * <li>{@link org.eclipse.emf.ecore.xcore.impl.XOperationImpl#getParameters <em>Parameters</em>}</li> |
| * <li>{@link org.eclipse.emf.ecore.xcore.impl.XOperationImpl#getExceptions <em>Exceptions</em>}</li> |
| * <li>{@link org.eclipse.emf.ecore.xcore.impl.XOperationImpl#getBody <em>Body</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public class XOperationImpl extends XMemberImpl implements XOperation |
| { |
| /** |
| * The cached value of the '{@link #getTypeParameters() <em>Type Parameters</em>}' containment reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getTypeParameters() |
| * @generated |
| * @ordered |
| */ |
| protected EList<XTypeParameter> typeParameters; |
| |
| /** |
| * 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<XParameter> parameters; |
| |
| /** |
| * The cached value of the '{@link #getExceptions() <em>Exceptions</em>}' containment reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getExceptions() |
| * @generated |
| * @ordered |
| */ |
| protected EList<XGenericType> exceptions; |
| |
| /** |
| * The cached value of the '{@link #getBody() <em>Body</em>}' containment reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getBody() |
| * @generated |
| * @ordered |
| */ |
| protected XBlockExpression body; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected XOperationImpl() |
| { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() |
| { |
| return XcorePackage.Literals.XOPERATION; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EList<XTypeParameter> getTypeParameters() |
| { |
| if (typeParameters == null) |
| { |
| typeParameters = new EObjectContainmentEList<XTypeParameter>(XTypeParameter.class, this, XcorePackage.XOPERATION__TYPE_PARAMETERS); |
| } |
| return typeParameters; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EList<XParameter> getParameters() |
| { |
| if (parameters == null) |
| { |
| parameters = new EObjectContainmentWithInverseEList<XParameter>(XParameter.class, this, XcorePackage.XOPERATION__PARAMETERS, XcorePackage.XPARAMETER__OPERATION); |
| } |
| return parameters; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EList<XGenericType> getExceptions() |
| { |
| if (exceptions == null) |
| { |
| exceptions = new EObjectContainmentEList.Unsettable<XGenericType>(XGenericType.class, this, XcorePackage.XOPERATION__EXCEPTIONS); |
| } |
| return exceptions; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void unsetExceptions() |
| { |
| if (exceptions != null) ((InternalEList.Unsettable<?>)exceptions).unset(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public boolean isSetExceptions() |
| { |
| return exceptions != null && ((InternalEList.Unsettable<?>)exceptions).isSet(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public XBlockExpression getBody() |
| { |
| return body; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetBody(XBlockExpression newBody, NotificationChain msgs) |
| { |
| XBlockExpression oldBody = body; |
| body = newBody; |
| if (eNotificationRequired()) |
| { |
| ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, XcorePackage.XOPERATION__BODY, oldBody, newBody); |
| if (msgs == null) msgs = notification; else msgs.add(notification); |
| } |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setBody(XBlockExpression newBody) |
| { |
| if (newBody != body) |
| { |
| NotificationChain msgs = null; |
| if (body != null) |
| msgs = ((InternalEObject)body).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - XcorePackage.XOPERATION__BODY, null, msgs); |
| if (newBody != null) |
| msgs = ((InternalEObject)newBody).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - XcorePackage.XOPERATION__BODY, null, msgs); |
| msgs = basicSetBody(newBody, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, XcorePackage.XOPERATION__BODY, newBody, newBody)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @SuppressWarnings("unchecked") |
| @Override |
| public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) |
| { |
| switch (featureID) |
| { |
| case XcorePackage.XOPERATION__PARAMETERS: |
| return ((InternalEList<InternalEObject>)(InternalEList<?>)getParameters()).basicAdd(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 XcorePackage.XOPERATION__TYPE_PARAMETERS: |
| return ((InternalEList<?>)getTypeParameters()).basicRemove(otherEnd, msgs); |
| case XcorePackage.XOPERATION__PARAMETERS: |
| return ((InternalEList<?>)getParameters()).basicRemove(otherEnd, msgs); |
| case XcorePackage.XOPERATION__EXCEPTIONS: |
| return ((InternalEList<?>)getExceptions()).basicRemove(otherEnd, msgs); |
| case XcorePackage.XOPERATION__BODY: |
| return basicSetBody(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 XcorePackage.XOPERATION__TYPE_PARAMETERS: |
| return getTypeParameters(); |
| case XcorePackage.XOPERATION__PARAMETERS: |
| return getParameters(); |
| case XcorePackage.XOPERATION__EXCEPTIONS: |
| return getExceptions(); |
| case XcorePackage.XOPERATION__BODY: |
| return getBody(); |
| } |
| 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 XcorePackage.XOPERATION__TYPE_PARAMETERS: |
| getTypeParameters().clear(); |
| getTypeParameters().addAll((Collection<? extends XTypeParameter>)newValue); |
| return; |
| case XcorePackage.XOPERATION__PARAMETERS: |
| getParameters().clear(); |
| getParameters().addAll((Collection<? extends XParameter>)newValue); |
| return; |
| case XcorePackage.XOPERATION__EXCEPTIONS: |
| getExceptions().clear(); |
| getExceptions().addAll((Collection<? extends XGenericType>)newValue); |
| return; |
| case XcorePackage.XOPERATION__BODY: |
| setBody((XBlockExpression)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) |
| { |
| switch (featureID) |
| { |
| case XcorePackage.XOPERATION__TYPE_PARAMETERS: |
| getTypeParameters().clear(); |
| return; |
| case XcorePackage.XOPERATION__PARAMETERS: |
| getParameters().clear(); |
| return; |
| case XcorePackage.XOPERATION__EXCEPTIONS: |
| unsetExceptions(); |
| return; |
| case XcorePackage.XOPERATION__BODY: |
| setBody((XBlockExpression)null); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) |
| { |
| switch (featureID) |
| { |
| case XcorePackage.XOPERATION__TYPE_PARAMETERS: |
| return typeParameters != null && !typeParameters.isEmpty(); |
| case XcorePackage.XOPERATION__PARAMETERS: |
| return parameters != null && !parameters.isEmpty(); |
| case XcorePackage.XOPERATION__EXCEPTIONS: |
| return isSetExceptions(); |
| case XcorePackage.XOPERATION__BODY: |
| return body != null; |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| } //XOperationImpl |