| /******************************************************************************* |
| * Copyright (c) 2010, 2019 Willink Transformations 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 |
| * |
| * Contributors: |
| * E.D.Willink - Initial API and implementation |
| *******************************************************************************/ |
| package org.eclipse.ocl.pivot.internal; |
| |
| import java.util.Collection; |
| |
| import org.eclipse.emf.common.notify.Notification; |
| import org.eclipse.emf.common.notify.NotificationChain; |
| 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.EcoreUtil; |
| import org.eclipse.emf.ecore.util.InternalEList; |
| import org.eclipse.jdt.annotation.NonNull; |
| import org.eclipse.ocl.pivot.Comment; |
| import org.eclipse.ocl.pivot.Element; |
| import org.eclipse.ocl.pivot.ElementExtension; |
| import org.eclipse.ocl.pivot.PivotPackage; |
| import org.eclipse.ocl.pivot.TemplateBinding; |
| import org.eclipse.ocl.pivot.TemplateParameter; |
| import org.eclipse.ocl.pivot.TemplateParameterSubstitution; |
| import org.eclipse.ocl.pivot.Type; |
| import org.eclipse.ocl.pivot.WildcardType; |
| import org.eclipse.ocl.pivot.util.Visitor; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Template Parameter Substitution</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.ocl.pivot.internal.TemplateParameterSubstitutionImpl#getActual <em>Actual</em>}</li> |
| * <li>{@link org.eclipse.ocl.pivot.internal.TemplateParameterSubstitutionImpl#getFormal <em>Formal</em>}</li> |
| * <li>{@link org.eclipse.ocl.pivot.internal.TemplateParameterSubstitutionImpl#getOwnedWildcard <em>Owned Wildcard</em>}</li> |
| * <li>{@link org.eclipse.ocl.pivot.internal.TemplateParameterSubstitutionImpl#getOwningBinding <em>Owning Binding</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public class TemplateParameterSubstitutionImpl |
| extends ElementImpl |
| implements TemplateParameterSubstitution { |
| |
| /** |
| * The number of structural features of the '<em>Template Parameter Substitution</em>' class. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| * @ordered |
| */ |
| public static final int TEMPLATE_PARAMETER_SUBSTITUTION_FEATURE_COUNT = ElementImpl.ELEMENT_FEATURE_COUNT + 4; |
| |
| /** |
| * The number of operations of the '<em>Template Parameter Substitution</em>' class. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| * @ordered |
| */ |
| public static final int TEMPLATE_PARAMETER_SUBSTITUTION_OPERATION_COUNT = ElementImpl.ELEMENT_OPERATION_COUNT + 0; |
| |
| /** |
| * The cached value of the '{@link #getActual() <em>Actual</em>}' reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getActual() |
| * @generated |
| * @ordered |
| */ |
| protected Type actual; |
| |
| /** |
| * The cached value of the '{@link #getFormal() <em>Formal</em>}' reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getFormal() |
| * @generated |
| * @ordered |
| */ |
| protected TemplateParameter formal; |
| |
| /** |
| * The cached value of the '{@link #getOwnedWildcard() <em>Owned Wildcard</em>}' containment reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getOwnedWildcard() |
| * @generated |
| * @ordered |
| */ |
| protected WildcardType ownedWildcard; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected TemplateParameterSubstitutionImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return PivotPackage.Literals.TEMPLATE_PARAMETER_SUBSTITUTION; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Type getActual() { |
| if (actual != null && actual.eIsProxy()) |
| { |
| InternalEObject oldActual = (InternalEObject)actual; |
| actual = (Type)eResolveProxy(oldActual); |
| if (actual != oldActual) |
| { |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.RESOLVE, 4, oldActual, actual)); |
| } |
| } |
| return actual; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public Type basicGetActual() { |
| return actual; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setActualGen(Type newActual) |
| { |
| Type oldActual = actual; |
| actual = newActual; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, 4, oldActual, actual)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public TemplateParameter getFormal() { |
| if (formal != null && formal.eIsProxy()) |
| { |
| InternalEObject oldFormal = (InternalEObject)formal; |
| formal = (TemplateParameter)eResolveProxy(oldFormal); |
| if (formal != oldFormal) |
| { |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.RESOLVE, 5, oldFormal, formal)); |
| } |
| } |
| return formal; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public TemplateParameter basicGetFormal() { |
| return formal; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setFormal(TemplateParameter newFormal) { |
| TemplateParameter oldFormal = formal; |
| formal = newFormal; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, 5, oldFormal, formal)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public WildcardType getOwnedWildcard() |
| { |
| return ownedWildcard; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetOwnedWildcard(WildcardType newOwnedWildcard, NotificationChain msgs) |
| { |
| WildcardType oldOwnedWildcard = ownedWildcard; |
| ownedWildcard = newOwnedWildcard; |
| if (eNotificationRequired()) |
| { |
| ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, 6, oldOwnedWildcard, newOwnedWildcard); |
| if (msgs == null) msgs = notification; else msgs.add(notification); |
| } |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setOwnedWildcard(WildcardType newOwnedWildcard) |
| { |
| if (newOwnedWildcard != ownedWildcard) |
| { |
| NotificationChain msgs = null; |
| if (ownedWildcard != null) |
| msgs = ((InternalEObject)ownedWildcard).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - (6), null, msgs); |
| if (newOwnedWildcard != null) |
| msgs = ((InternalEObject)newOwnedWildcard).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - (6), null, msgs); |
| msgs = basicSetOwnedWildcard(newOwnedWildcard, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, 6, newOwnedWildcard, newOwnedWildcard)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public TemplateBinding getOwningBinding() { |
| if (eContainerFeatureID() != (7)) return null; |
| return (TemplateBinding)eInternalContainer(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetOwningBinding(TemplateBinding newOwningBinding, NotificationChain msgs) |
| { |
| msgs = eBasicSetContainer((InternalEObject)newOwningBinding, 7, msgs); |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setOwningBinding(TemplateBinding newOwningBinding) |
| { |
| if (newOwningBinding != eInternalContainer() || (eContainerFeatureID() != (7) && newOwningBinding != null)) |
| { |
| if (EcoreUtil.isAncestor(this, newOwningBinding)) |
| throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); //$NON-NLS-1$ |
| NotificationChain msgs = null; |
| if (eInternalContainer() != null) |
| msgs = eBasicRemoveFromContainer(msgs); |
| if (newOwningBinding != null) |
| msgs = ((InternalEObject)newOwningBinding).eInverseAdd(this, 4, TemplateBinding.class, msgs); |
| msgs = basicSetOwningBinding(newOwningBinding, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, 7, newOwningBinding, newOwningBinding)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @SuppressWarnings("unchecked") |
| @Override |
| public NotificationChain eInverseAdd(InternalEObject otherEnd, |
| int featureID, NotificationChain msgs) { |
| switch (featureID) |
| { |
| case 0: |
| return ((InternalEList<InternalEObject>)(InternalEList<?>)getAnnotatingComments()).basicAdd(otherEnd, msgs); |
| case 2: |
| return ((InternalEList<InternalEObject>)(InternalEList<?>)getOwnedComments()).basicAdd(otherEnd, msgs); |
| case 3: |
| return ((InternalEList<InternalEObject>)(InternalEList<?>)getOwnedExtensions()).basicAdd(otherEnd, msgs); |
| case 7: |
| if (eInternalContainer() != null) |
| msgs = eBasicRemoveFromContainer(msgs); |
| return basicSetOwningBinding((TemplateBinding)otherEnd, msgs); |
| } |
| return eDynamicInverseAdd(otherEnd, featureID, msgs); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseRemove(InternalEObject otherEnd, |
| int featureID, NotificationChain msgs) { |
| switch (featureID) |
| { |
| case 0: |
| return ((InternalEList<?>)getAnnotatingComments()).basicRemove(otherEnd, msgs); |
| case 1: |
| return ((InternalEList<?>)getOwnedAnnotations()).basicRemove(otherEnd, msgs); |
| case 2: |
| return ((InternalEList<?>)getOwnedComments()).basicRemove(otherEnd, msgs); |
| case 3: |
| return ((InternalEList<?>)getOwnedExtensions()).basicRemove(otherEnd, msgs); |
| case 6: |
| return basicSetOwnedWildcard(null, msgs); |
| case 7: |
| return basicSetOwningBinding(null, msgs); |
| } |
| return eDynamicInverseRemove(otherEnd, featureID, msgs); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eBasicRemoveFromContainerFeature( |
| NotificationChain msgs) { |
| switch (eContainerFeatureID()) |
| { |
| case 7: |
| return eInternalContainer().eInverseRemove(this, 4, TemplateBinding.class, msgs); |
| } |
| return eDynamicBasicRemoveFromContainer(msgs); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| switch (featureID) |
| { |
| case 0: |
| return getAnnotatingComments(); |
| case 1: |
| return getOwnedAnnotations(); |
| case 2: |
| return getOwnedComments(); |
| case 3: |
| return getOwnedExtensions(); |
| case 4: |
| if (resolve) return getActual(); |
| return basicGetActual(); |
| case 5: |
| if (resolve) return getFormal(); |
| return basicGetFormal(); |
| case 6: |
| return getOwnedWildcard(); |
| case 7: |
| return getOwningBinding(); |
| } |
| return eDynamicGet(featureID, resolve, coreType); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @SuppressWarnings("unchecked") |
| @Override |
| public void eSet(int featureID, Object newValue) { |
| switch (featureID) |
| { |
| case 0: |
| getAnnotatingComments().clear(); |
| getAnnotatingComments().addAll((Collection<? extends Comment>)newValue); |
| return; |
| case 1: |
| getOwnedAnnotations().clear(); |
| getOwnedAnnotations().addAll((Collection<? extends Element>)newValue); |
| return; |
| case 2: |
| getOwnedComments().clear(); |
| getOwnedComments().addAll((Collection<? extends Comment>)newValue); |
| return; |
| case 3: |
| getOwnedExtensions().clear(); |
| getOwnedExtensions().addAll((Collection<? extends ElementExtension>)newValue); |
| return; |
| case 4: |
| setActual((Type)newValue); |
| return; |
| case 5: |
| setFormal((TemplateParameter)newValue); |
| return; |
| case 6: |
| setOwnedWildcard((WildcardType)newValue); |
| return; |
| case 7: |
| setOwningBinding((TemplateBinding)newValue); |
| return; |
| } |
| eDynamicSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) |
| { |
| case 0: |
| getAnnotatingComments().clear(); |
| return; |
| case 1: |
| getOwnedAnnotations().clear(); |
| return; |
| case 2: |
| getOwnedComments().clear(); |
| return; |
| case 3: |
| getOwnedExtensions().clear(); |
| return; |
| case 4: |
| setActual((Type)null); |
| return; |
| case 5: |
| setFormal((TemplateParameter)null); |
| return; |
| case 6: |
| setOwnedWildcard((WildcardType)null); |
| return; |
| case 7: |
| setOwningBinding((TemplateBinding)null); |
| return; |
| } |
| eDynamicUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) |
| { |
| case 0: |
| return annotatingComments != null && !annotatingComments.isEmpty(); |
| case 1: |
| return ownedAnnotations != null && !ownedAnnotations.isEmpty(); |
| case 2: |
| return ownedComments != null && !ownedComments.isEmpty(); |
| case 3: |
| return ownedExtensions != null && !ownedExtensions.isEmpty(); |
| case 4: |
| return actual != null; |
| case 5: |
| return formal != null; |
| case 6: |
| return ownedWildcard != null; |
| case 7: |
| return getOwningBinding() != null; |
| } |
| return eDynamicIsSet(featureID); |
| } |
| |
| @Override |
| public <R> R accept(@NonNull Visitor<R> visitor) { |
| return visitor.visitTemplateParameterSubstitution(this); |
| } |
| |
| @Override |
| public void setActual(Type newActual) |
| { |
| setActualGen(newActual); |
| setOwnedWildcard(newActual instanceof WildcardType ? (WildcardType)newActual : null); |
| } |
| } //TemplateParameterSubstitutionImpl |