| /** |
| * <copyright> |
| * |
| * Copyright (c) 2007, 2008 E.D.Willink 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: |
| * E.D.Willink - initial API and implementation |
| * |
| * </copyright> |
| * |
| * $Id: OperationImpl.java,v 1.1 2008/07/23 09:55:18 qglineur Exp $ |
| */ |
| package org.eclipse.qvt.declarative.emof.EMOF.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.EObjectContainmentWithInverseEList; |
| import org.eclipse.emf.ecore.util.EObjectResolvingEList; |
| import org.eclipse.emf.ecore.util.EcoreUtil; |
| import org.eclipse.emf.ecore.util.InternalEList; |
| |
| import org.eclipse.qvt.declarative.emof.EMOF.EMOFPackage; |
| import org.eclipse.qvt.declarative.emof.EMOF.MultiplicityElement; |
| import org.eclipse.qvt.declarative.emof.EMOF.Operation; |
| import org.eclipse.qvt.declarative.emof.EMOF.Parameter; |
| import org.eclipse.qvt.declarative.emof.EMOF.Type; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Operation</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * <ul> |
| * <li>{@link org.eclipse.qvt.declarative.emof.EMOF.impl.OperationImpl#getIsOrdered <em>Is Ordered</em>}</li> |
| * <li>{@link org.eclipse.qvt.declarative.emof.EMOF.impl.OperationImpl#getIsUnique <em>Is Unique</em>}</li> |
| * <li>{@link org.eclipse.qvt.declarative.emof.EMOF.impl.OperationImpl#getLower <em>Lower</em>}</li> |
| * <li>{@link org.eclipse.qvt.declarative.emof.EMOF.impl.OperationImpl#getUpper <em>Upper</em>}</li> |
| * <li>{@link org.eclipse.qvt.declarative.emof.EMOF.impl.OperationImpl#getClass_ <em>Class</em>}</li> |
| * <li>{@link org.eclipse.qvt.declarative.emof.EMOF.impl.OperationImpl#getOwnedParameter <em>Owned Parameter</em>}</li> |
| * <li>{@link org.eclipse.qvt.declarative.emof.EMOF.impl.OperationImpl#getRaisedException <em>Raised Exception</em>}</li> |
| * </ul> |
| * </p> |
| * |
| * @generated |
| */ |
| public class OperationImpl extends TypedElementImpl implements Operation { |
| /** |
| * The default value of the '{@link #getIsOrdered() <em>Is Ordered</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getIsOrdered() |
| * @generated |
| * @ordered |
| */ |
| protected static final Boolean IS_ORDERED_EDEFAULT = Boolean.FALSE; |
| |
| /** |
| * The cached value of the '{@link #getIsOrdered() <em>Is Ordered</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getIsOrdered() |
| * @generated |
| * @ordered |
| */ |
| protected Boolean isOrdered = IS_ORDERED_EDEFAULT; |
| |
| /** |
| * The default value of the '{@link #getIsUnique() <em>Is Unique</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getIsUnique() |
| * @generated |
| * @ordered |
| */ |
| protected static final Boolean IS_UNIQUE_EDEFAULT = Boolean.TRUE; |
| |
| /** |
| * The cached value of the '{@link #getIsUnique() <em>Is Unique</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getIsUnique() |
| * @generated |
| * @ordered |
| */ |
| protected Boolean isUnique = IS_UNIQUE_EDEFAULT; |
| |
| /** |
| * The default value of the '{@link #getLower() <em>Lower</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getLower() |
| * @generated |
| * @ordered |
| */ |
| protected static final Integer LOWER_EDEFAULT = new Integer(1); |
| |
| /** |
| * The cached value of the '{@link #getLower() <em>Lower</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getLower() |
| * @generated |
| * @ordered |
| */ |
| protected Integer lower = LOWER_EDEFAULT; |
| |
| /** |
| * The default value of the '{@link #getUpper() <em>Upper</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getUpper() |
| * @generated |
| * @ordered |
| */ |
| protected static final Integer UPPER_EDEFAULT = new Integer(1); |
| |
| /** |
| * The cached value of the '{@link #getUpper() <em>Upper</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getUpper() |
| * @generated |
| * @ordered |
| */ |
| protected Integer upper = UPPER_EDEFAULT; |
| |
| /** |
| * The cached value of the '{@link #getOwnedParameter() <em>Owned Parameter</em>}' containment reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getOwnedParameter() |
| * @generated |
| * @ordered |
| */ |
| protected EList<Parameter> ownedParameter; |
| |
| /** |
| * The cached value of the '{@link #getRaisedException() <em>Raised Exception</em>}' reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getRaisedException() |
| * @generated |
| * @ordered |
| */ |
| protected EList<Type> raisedException; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected OperationImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return EMOFPackage.Literals.OPERATION; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public Boolean getIsOrdered() { |
| return isOrdered; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setIsOrdered(Boolean newIsOrdered) { |
| Boolean oldIsOrdered = isOrdered; |
| isOrdered = newIsOrdered; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, EMOFPackage.OPERATION__IS_ORDERED, oldIsOrdered, isOrdered)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public Boolean getIsUnique() { |
| return isUnique; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setIsUnique(Boolean newIsUnique) { |
| Boolean oldIsUnique = isUnique; |
| isUnique = newIsUnique; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, EMOFPackage.OPERATION__IS_UNIQUE, oldIsUnique, isUnique)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public Integer getLower() { |
| return lower; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setLower(Integer newLower) { |
| Integer oldLower = lower; |
| lower = newLower; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, EMOFPackage.OPERATION__LOWER, oldLower, lower)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public Integer getUpper() { |
| return upper; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setUpper(Integer newUpper) { |
| Integer oldUpper = upper; |
| upper = newUpper; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, EMOFPackage.OPERATION__UPPER, oldUpper, upper)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public org.eclipse.qvt.declarative.emof.EMOF.Class getClass_() { |
| if (eContainerFeatureID != EMOFPackage.OPERATION__CLASS) return null; |
| return (org.eclipse.qvt.declarative.emof.EMOF.Class)eContainer(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetClass(org.eclipse.qvt.declarative.emof.EMOF.Class newClass, NotificationChain msgs) { |
| msgs = eBasicSetContainer((InternalEObject)newClass, EMOFPackage.OPERATION__CLASS, msgs); |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setClass(org.eclipse.qvt.declarative.emof.EMOF.Class newClass) { |
| if (newClass != eInternalContainer() || (eContainerFeatureID != EMOFPackage.OPERATION__CLASS && newClass != null)) { |
| if (EcoreUtil.isAncestor(this, newClass)) |
| throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); |
| NotificationChain msgs = null; |
| if (eInternalContainer() != null) |
| msgs = eBasicRemoveFromContainer(msgs); |
| if (newClass != null) |
| msgs = ((InternalEObject)newClass).eInverseAdd(this, EMOFPackage.CLASS__OWNED_OPERATION, org.eclipse.qvt.declarative.emof.EMOF.Class.class, msgs); |
| msgs = basicSetClass(newClass, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, EMOFPackage.OPERATION__CLASS, newClass, newClass)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EList<Parameter> getOwnedParameter() { |
| if (ownedParameter == null) { |
| ownedParameter = new EObjectContainmentWithInverseEList<Parameter>(Parameter.class, this, EMOFPackage.OPERATION__OWNED_PARAMETER, EMOFPackage.PARAMETER__OPERATION); |
| } |
| return ownedParameter; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EList<Type> getRaisedException() { |
| if (raisedException == null) { |
| raisedException = new EObjectResolvingEList<Type>(Type.class, this, EMOFPackage.OPERATION__RAISED_EXCEPTION); |
| } |
| return raisedException; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @SuppressWarnings("unchecked") |
| @Override |
| public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case EMOFPackage.OPERATION__CLASS: |
| if (eInternalContainer() != null) |
| msgs = eBasicRemoveFromContainer(msgs); |
| return basicSetClass((org.eclipse.qvt.declarative.emof.EMOF.Class)otherEnd, msgs); |
| case EMOFPackage.OPERATION__OWNED_PARAMETER: |
| return ((InternalEList<InternalEObject>)(InternalEList<?>)getOwnedParameter()).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 EMOFPackage.OPERATION__CLASS: |
| return basicSetClass(null, msgs); |
| case EMOFPackage.OPERATION__OWNED_PARAMETER: |
| return ((InternalEList<?>)getOwnedParameter()).basicRemove(otherEnd, msgs); |
| } |
| return super.eInverseRemove(otherEnd, featureID, msgs); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { |
| switch (eContainerFeatureID) { |
| case EMOFPackage.OPERATION__CLASS: |
| return eInternalContainer().eInverseRemove(this, EMOFPackage.CLASS__OWNED_OPERATION, org.eclipse.qvt.declarative.emof.EMOF.Class.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 EMOFPackage.OPERATION__IS_ORDERED: |
| return getIsOrdered(); |
| case EMOFPackage.OPERATION__IS_UNIQUE: |
| return getIsUnique(); |
| case EMOFPackage.OPERATION__LOWER: |
| return getLower(); |
| case EMOFPackage.OPERATION__UPPER: |
| return getUpper(); |
| case EMOFPackage.OPERATION__CLASS: |
| return getClass_(); |
| case EMOFPackage.OPERATION__OWNED_PARAMETER: |
| return getOwnedParameter(); |
| case EMOFPackage.OPERATION__RAISED_EXCEPTION: |
| return getRaisedException(); |
| } |
| 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 EMOFPackage.OPERATION__IS_ORDERED: |
| setIsOrdered((Boolean)newValue); |
| return; |
| case EMOFPackage.OPERATION__IS_UNIQUE: |
| setIsUnique((Boolean)newValue); |
| return; |
| case EMOFPackage.OPERATION__LOWER: |
| setLower((Integer)newValue); |
| return; |
| case EMOFPackage.OPERATION__UPPER: |
| setUpper((Integer)newValue); |
| return; |
| case EMOFPackage.OPERATION__CLASS: |
| setClass((org.eclipse.qvt.declarative.emof.EMOF.Class)newValue); |
| return; |
| case EMOFPackage.OPERATION__OWNED_PARAMETER: |
| getOwnedParameter().clear(); |
| getOwnedParameter().addAll((Collection<? extends Parameter>)newValue); |
| return; |
| case EMOFPackage.OPERATION__RAISED_EXCEPTION: |
| getRaisedException().clear(); |
| getRaisedException().addAll((Collection<? extends Type>)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case EMOFPackage.OPERATION__IS_ORDERED: |
| setIsOrdered(IS_ORDERED_EDEFAULT); |
| return; |
| case EMOFPackage.OPERATION__IS_UNIQUE: |
| setIsUnique(IS_UNIQUE_EDEFAULT); |
| return; |
| case EMOFPackage.OPERATION__LOWER: |
| setLower(LOWER_EDEFAULT); |
| return; |
| case EMOFPackage.OPERATION__UPPER: |
| setUpper(UPPER_EDEFAULT); |
| return; |
| case EMOFPackage.OPERATION__CLASS: |
| setClass((org.eclipse.qvt.declarative.emof.EMOF.Class)null); |
| return; |
| case EMOFPackage.OPERATION__OWNED_PARAMETER: |
| getOwnedParameter().clear(); |
| return; |
| case EMOFPackage.OPERATION__RAISED_EXCEPTION: |
| getRaisedException().clear(); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case EMOFPackage.OPERATION__IS_ORDERED: |
| return IS_ORDERED_EDEFAULT == null ? isOrdered != null : !IS_ORDERED_EDEFAULT.equals(isOrdered); |
| case EMOFPackage.OPERATION__IS_UNIQUE: |
| return IS_UNIQUE_EDEFAULT == null ? isUnique != null : !IS_UNIQUE_EDEFAULT.equals(isUnique); |
| case EMOFPackage.OPERATION__LOWER: |
| return LOWER_EDEFAULT == null ? lower != null : !LOWER_EDEFAULT.equals(lower); |
| case EMOFPackage.OPERATION__UPPER: |
| return UPPER_EDEFAULT == null ? upper != null : !UPPER_EDEFAULT.equals(upper); |
| case EMOFPackage.OPERATION__CLASS: |
| return getClass_() != null; |
| case EMOFPackage.OPERATION__OWNED_PARAMETER: |
| return ownedParameter != null && !ownedParameter.isEmpty(); |
| case EMOFPackage.OPERATION__RAISED_EXCEPTION: |
| return raisedException != null && !raisedException.isEmpty(); |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) { |
| if (baseClass == MultiplicityElement.class) { |
| switch (derivedFeatureID) { |
| case EMOFPackage.OPERATION__IS_ORDERED: return EMOFPackage.MULTIPLICITY_ELEMENT__IS_ORDERED; |
| case EMOFPackage.OPERATION__IS_UNIQUE: return EMOFPackage.MULTIPLICITY_ELEMENT__IS_UNIQUE; |
| case EMOFPackage.OPERATION__LOWER: return EMOFPackage.MULTIPLICITY_ELEMENT__LOWER; |
| case EMOFPackage.OPERATION__UPPER: return EMOFPackage.MULTIPLICITY_ELEMENT__UPPER; |
| 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 == MultiplicityElement.class) { |
| switch (baseFeatureID) { |
| case EMOFPackage.MULTIPLICITY_ELEMENT__IS_ORDERED: return EMOFPackage.OPERATION__IS_ORDERED; |
| case EMOFPackage.MULTIPLICITY_ELEMENT__IS_UNIQUE: return EMOFPackage.OPERATION__IS_UNIQUE; |
| case EMOFPackage.MULTIPLICITY_ELEMENT__LOWER: return EMOFPackage.OPERATION__LOWER; |
| case EMOFPackage.MULTIPLICITY_ELEMENT__UPPER: return EMOFPackage.OPERATION__UPPER; |
| 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(" (isOrdered: "); |
| result.append(isOrdered); |
| result.append(", isUnique: "); |
| result.append(isUnique); |
| result.append(", lower: "); |
| result.append(lower); |
| result.append(", upper: "); |
| result.append(upper); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| } //OperationImpl |