| /** |
| * <copyright> |
| * |
| * Copyright (c) 2013, 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 |
| * |
| * </copyright> |
| */ |
| package org.eclipse.qvtd.pivot.qvtcore.impl; |
| |
| 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.jdt.annotation.NonNull; |
| |
| import org.eclipse.ocl.pivot.OperationCallExp; |
| |
| import org.eclipse.ocl.pivot.internal.ElementImpl; |
| |
| import org.eclipse.ocl.pivot.util.Visitor; |
| |
| import org.eclipse.qvtd.pivot.qvtbase.impl.PatternImpl; |
| import org.eclipse.qvtd.pivot.qvtcore.BottomPattern; |
| import org.eclipse.qvtd.pivot.qvtcore.EnforcementMode; |
| import org.eclipse.qvtd.pivot.qvtcore.EnforcementOperation; |
| import org.eclipse.qvtd.pivot.qvtcore.QVTcorePackage; |
| |
| import org.eclipse.qvtd.pivot.qvtcore.util.QVTcoreVisitor; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Enforcement Operation</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.qvtd.pivot.qvtcore.impl.EnforcementOperationImpl#getEnforcementMode <em>Enforcement Mode</em>}</li> |
| * <li>{@link org.eclipse.qvtd.pivot.qvtcore.impl.EnforcementOperationImpl#getBottomPattern <em>Bottom Pattern</em>}</li> |
| * <li>{@link org.eclipse.qvtd.pivot.qvtcore.impl.EnforcementOperationImpl#getOperationCallExp <em>Operation Call Exp</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public class EnforcementOperationImpl extends ElementImpl implements EnforcementOperation { |
| /** |
| * The number of structural features of the '<em>Enforcement Operation</em>' class. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| * @ordered |
| */ |
| public static final int ENFORCEMENT_OPERATION_FEATURE_COUNT = ElementImpl.ELEMENT_FEATURE_COUNT + 3; |
| |
| /** |
| * The number of operations of the '<em>Enforcement Operation</em>' class. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| * @ordered |
| */ |
| public static final int ENFORCEMENT_OPERATION_OPERATION_COUNT = ElementImpl.ELEMENT_OPERATION_COUNT + 0; |
| |
| /** |
| * The default value of the '{@link #getEnforcementMode() <em>Enforcement Mode</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getEnforcementMode() |
| * @generated |
| * @ordered |
| */ |
| protected static final EnforcementMode ENFORCEMENT_MODE_EDEFAULT = EnforcementMode.CREATION; |
| |
| /** |
| * The cached value of the '{@link #getEnforcementMode() <em>Enforcement Mode</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getEnforcementMode() |
| * @generated |
| * @ordered |
| */ |
| protected EnforcementMode enforcementMode = ENFORCEMENT_MODE_EDEFAULT; |
| |
| /** |
| * The cached value of the '{@link #getOperationCallExp() <em>Operation Call Exp</em>}' containment reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getOperationCallExp() |
| * @generated |
| * @ordered |
| */ |
| protected OperationCallExp operationCallExp; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected EnforcementOperationImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return QVTcorePackage.Literals.ENFORCEMENT_OPERATION; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public EnforcementMode getEnforcementMode() { |
| return enforcementMode; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setEnforcementMode(EnforcementMode newEnforcementMode) { |
| EnforcementMode oldEnforcementMode = enforcementMode; |
| enforcementMode = newEnforcementMode == null ? ENFORCEMENT_MODE_EDEFAULT : newEnforcementMode; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, ElementImpl.ELEMENT_FEATURE_COUNT + 0, oldEnforcementMode, enforcementMode)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public BottomPattern getBottomPattern() { |
| if (eContainerFeatureID() != (ElementImpl.ELEMENT_FEATURE_COUNT + 1)) return null; |
| return (BottomPattern)eInternalContainer(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetBottomPattern(BottomPattern newBottomPattern, NotificationChain msgs) { |
| msgs = eBasicSetContainer((InternalEObject)newBottomPattern, ElementImpl.ELEMENT_FEATURE_COUNT + 1, msgs); |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setBottomPattern(BottomPattern newBottomPattern) { |
| if (newBottomPattern != eInternalContainer() || (eContainerFeatureID() != (ElementImpl.ELEMENT_FEATURE_COUNT + 1) && newBottomPattern != null)) { |
| if (EcoreUtil.isAncestor(this, newBottomPattern)) |
| throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); |
| NotificationChain msgs = null; |
| if (eInternalContainer() != null) |
| msgs = eBasicRemoveFromContainer(msgs); |
| if (newBottomPattern != null) |
| msgs = ((InternalEObject)newBottomPattern).eInverseAdd(this, PatternImpl.PATTERN_FEATURE_COUNT + 3, BottomPattern.class, msgs); |
| msgs = basicSetBottomPattern(newBottomPattern, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, ElementImpl.ELEMENT_FEATURE_COUNT + 1, newBottomPattern, newBottomPattern)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public OperationCallExp getOperationCallExp() { |
| return operationCallExp; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetOperationCallExp(OperationCallExp newOperationCallExp, NotificationChain msgs) { |
| OperationCallExp oldOperationCallExp = operationCallExp; |
| operationCallExp = newOperationCallExp; |
| if (eNotificationRequired()) { |
| ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ElementImpl.ELEMENT_FEATURE_COUNT + 2, oldOperationCallExp, newOperationCallExp); |
| if (msgs == null) msgs = notification; else msgs.add(notification); |
| } |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setOperationCallExp(OperationCallExp newOperationCallExp) { |
| if (newOperationCallExp != operationCallExp) { |
| NotificationChain msgs = null; |
| if (operationCallExp != null) |
| msgs = ((InternalEObject)operationCallExp).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - (ElementImpl.ELEMENT_FEATURE_COUNT + 2), null, msgs); |
| if (newOperationCallExp != null) |
| msgs = ((InternalEObject)newOperationCallExp).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - (ElementImpl.ELEMENT_FEATURE_COUNT + 2), null, msgs); |
| msgs = basicSetOperationCallExp(newOperationCallExp, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, ElementImpl.ELEMENT_FEATURE_COUNT + 2, newOperationCallExp, newOperationCallExp)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated NOT |
| */ |
| @Override |
| public String toString() { |
| return super.toString(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case ElementImpl.ELEMENT_FEATURE_COUNT + 1: |
| if (eInternalContainer() != null) |
| msgs = eBasicRemoveFromContainer(msgs); |
| return basicSetBottomPattern((BottomPattern)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 ElementImpl.ELEMENT_FEATURE_COUNT + 1: |
| return basicSetBottomPattern(null, msgs); |
| case ElementImpl.ELEMENT_FEATURE_COUNT + 2: |
| return basicSetOperationCallExp(null, msgs); |
| } |
| return super.eInverseRemove(otherEnd, featureID, msgs); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { |
| switch (eContainerFeatureID()) { |
| case ElementImpl.ELEMENT_FEATURE_COUNT + 1: |
| return eInternalContainer().eInverseRemove(this, PatternImpl.PATTERN_FEATURE_COUNT + 3, BottomPattern.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 ElementImpl.ELEMENT_FEATURE_COUNT + 0: |
| return getEnforcementMode(); |
| case ElementImpl.ELEMENT_FEATURE_COUNT + 1: |
| return getBottomPattern(); |
| case ElementImpl.ELEMENT_FEATURE_COUNT + 2: |
| return getOperationCallExp(); |
| } |
| return super.eGet(featureID, resolve, coreType); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eSet(int featureID, Object newValue) { |
| switch (featureID) { |
| case ElementImpl.ELEMENT_FEATURE_COUNT + 0: |
| setEnforcementMode((EnforcementMode)newValue); |
| return; |
| case ElementImpl.ELEMENT_FEATURE_COUNT + 1: |
| setBottomPattern((BottomPattern)newValue); |
| return; |
| case ElementImpl.ELEMENT_FEATURE_COUNT + 2: |
| setOperationCallExp((OperationCallExp)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case ElementImpl.ELEMENT_FEATURE_COUNT + 0: |
| setEnforcementMode(ENFORCEMENT_MODE_EDEFAULT); |
| return; |
| case ElementImpl.ELEMENT_FEATURE_COUNT + 1: |
| setBottomPattern((BottomPattern)null); |
| return; |
| case ElementImpl.ELEMENT_FEATURE_COUNT + 2: |
| setOperationCallExp((OperationCallExp)null); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case ElementImpl.ELEMENT_FEATURE_COUNT + 0: |
| return enforcementMode != ENFORCEMENT_MODE_EDEFAULT; |
| case ElementImpl.ELEMENT_FEATURE_COUNT + 1: |
| return getBottomPattern() != null; |
| case ElementImpl.ELEMENT_FEATURE_COUNT + 2: |
| return operationCallExp != null; |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| /** |
| * {@inheritDoc} |
| * @generated |
| */ |
| @SuppressWarnings("unchecked") |
| @Override |
| public <R> R accept(@NonNull Visitor<R> visitor) { |
| if (visitor instanceof QVTcoreVisitor) { |
| return (R) ((QVTcoreVisitor<?>)visitor).visitEnforcementOperation(this); |
| } |
| else { |
| return super.accept(visitor); |
| } |
| } |
| |
| } //EnforcementOperationImpl |