| /******************************************************************************* |
| * Copyright (c) 2014, 2019 CEA LIST 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 (CEA LIST) - 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.Profile; |
| import org.eclipse.ocl.pivot.ProfileApplication; |
| import org.eclipse.ocl.pivot.util.Visitor; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Profile Application</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.ocl.pivot.internal.ProfileApplicationImpl#getAppliedProfile <em>Applied Profile</em>}</li> |
| * <li>{@link org.eclipse.ocl.pivot.internal.ProfileApplicationImpl#isIsStrict <em>Is Strict</em>}</li> |
| * <li>{@link org.eclipse.ocl.pivot.internal.ProfileApplicationImpl#getOwningPackage <em>Owning Package</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public class ProfileApplicationImpl extends ElementImpl implements ProfileApplication |
| { |
| /** |
| * The number of structural features of the '<em>Profile Application</em>' class. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| * @ordered |
| */ |
| public static final int PROFILE_APPLICATION_FEATURE_COUNT = ElementImpl.ELEMENT_FEATURE_COUNT + 3; |
| |
| /** |
| * The number of operations of the '<em>Profile Application</em>' class. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| * @ordered |
| */ |
| public static final int PROFILE_APPLICATION_OPERATION_COUNT = ElementImpl.ELEMENT_OPERATION_COUNT + 0; |
| |
| /** |
| * The cached value of the '{@link #getAppliedProfile() <em>Applied Profile</em>}' reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getAppliedProfile() |
| * @generated |
| * @ordered |
| */ |
| protected Profile appliedProfile; |
| |
| /** |
| * The default value of the '{@link #isIsStrict() <em>Is Strict</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #isIsStrict() |
| * @generated |
| * @ordered |
| */ |
| protected static final boolean IS_STRICT_EDEFAULT = false; |
| |
| /** |
| * The flag representing the value of the '{@link #isIsStrict() <em>Is Strict</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #isIsStrict() |
| * @generated |
| * @ordered |
| */ |
| protected static final int IS_STRICT_EFLAG = 1 << 8; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected ProfileApplicationImpl() |
| { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() |
| { |
| return PivotPackage.Literals.PROFILE_APPLICATION; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Profile getAppliedProfile() |
| { |
| if (appliedProfile != null && appliedProfile.eIsProxy()) |
| { |
| InternalEObject oldAppliedProfile = (InternalEObject)appliedProfile; |
| appliedProfile = (Profile)eResolveProxy(oldAppliedProfile); |
| if (appliedProfile != oldAppliedProfile) |
| { |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.RESOLVE, 4, oldAppliedProfile, appliedProfile)); |
| } |
| } |
| return appliedProfile; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public Profile basicGetAppliedProfile() |
| { |
| return appliedProfile; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetAppliedProfile(Profile newAppliedProfile, NotificationChain msgs) |
| { |
| Profile oldAppliedProfile = appliedProfile; |
| appliedProfile = newAppliedProfile; |
| if (eNotificationRequired()) |
| { |
| ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, 4, oldAppliedProfile, newAppliedProfile); |
| if (msgs == null) msgs = notification; else msgs.add(notification); |
| } |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setAppliedProfile(Profile newAppliedProfile) |
| { |
| if (newAppliedProfile != appliedProfile) |
| { |
| NotificationChain msgs = null; |
| if (appliedProfile != null) |
| msgs = ((InternalEObject)appliedProfile).eInverseRemove(this, 14, Profile.class, msgs); |
| if (newAppliedProfile != null) |
| msgs = ((InternalEObject)newAppliedProfile).eInverseAdd(this, 14, Profile.class, msgs); |
| msgs = basicSetAppliedProfile(newAppliedProfile, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, 4, newAppliedProfile, newAppliedProfile)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean isIsStrict() |
| { |
| return (eFlags & IS_STRICT_EFLAG) != 0; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setIsStrict(boolean newIsStrict) |
| { |
| boolean oldIsStrict = (eFlags & IS_STRICT_EFLAG) != 0; |
| if (newIsStrict) eFlags |= IS_STRICT_EFLAG; else eFlags &= ~IS_STRICT_EFLAG; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, 5, oldIsStrict, newIsStrict)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public org.eclipse.ocl.pivot.Package getOwningPackage() |
| { |
| if (eContainerFeatureID() != (6)) return null; |
| return (org.eclipse.ocl.pivot.Package)eInternalContainer(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetOwningPackage(org.eclipse.ocl.pivot.Package newOwningPackage, NotificationChain msgs) |
| { |
| msgs = eBasicSetContainer((InternalEObject)newOwningPackage, 6, msgs); |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setOwningPackage(org.eclipse.ocl.pivot.Package newOwningPackage) |
| { |
| if (newOwningPackage != eInternalContainer() || (eContainerFeatureID() != (6) && newOwningPackage != null)) |
| { |
| if (EcoreUtil.isAncestor(this, newOwningPackage)) |
| throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); //$NON-NLS-1$ |
| NotificationChain msgs = null; |
| if (eInternalContainer() != null) |
| msgs = eBasicRemoveFromContainer(msgs); |
| if (newOwningPackage != null) |
| msgs = ((InternalEObject)newOwningPackage).eInverseAdd(this, 12, org.eclipse.ocl.pivot.Package.class, msgs); |
| msgs = basicSetOwningPackage(newOwningPackage, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, 6, newOwningPackage, newOwningPackage)); |
| } |
| |
| /** |
| * <!-- 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 4: |
| if (appliedProfile != null) |
| msgs = ((InternalEObject)appliedProfile).eInverseRemove(this, 14, Profile.class, msgs); |
| return basicSetAppliedProfile((Profile)otherEnd, msgs); |
| case 6: |
| if (eInternalContainer() != null) |
| msgs = eBasicRemoveFromContainer(msgs); |
| return basicSetOwningPackage((org.eclipse.ocl.pivot.Package)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 4: |
| return basicSetAppliedProfile(null, msgs); |
| case 6: |
| return basicSetOwningPackage(null, msgs); |
| } |
| return eDynamicInverseRemove(otherEnd, featureID, msgs); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) |
| { |
| switch (eContainerFeatureID()) |
| { |
| case 6: |
| return eInternalContainer().eInverseRemove(this, 12, org.eclipse.ocl.pivot.Package.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 getAppliedProfile(); |
| return basicGetAppliedProfile(); |
| case 5: |
| return isIsStrict(); |
| case 6: |
| return getOwningPackage(); |
| } |
| 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: |
| setAppliedProfile((Profile)newValue); |
| return; |
| case 5: |
| setIsStrict((Boolean)newValue); |
| return; |
| case 6: |
| setOwningPackage((org.eclipse.ocl.pivot.Package)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: |
| setAppliedProfile((Profile)null); |
| return; |
| case 5: |
| setIsStrict(IS_STRICT_EDEFAULT); |
| return; |
| case 6: |
| setOwningPackage((org.eclipse.ocl.pivot.Package)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 appliedProfile != null; |
| case 5: |
| return ((eFlags & IS_STRICT_EFLAG) != 0) != IS_STRICT_EDEFAULT; |
| case 6: |
| return getOwningPackage() != null; |
| } |
| return eDynamicIsSet(featureID); |
| } |
| |
| @Override |
| public <R> R accept(@NonNull Visitor<R> visitor) { |
| return visitor.visitProfileApplication(this); |
| } |
| |
| @Override |
| public String toString() { |
| return super.toString(); |
| } |
| } //ProfileApplicationImpl |