| /******************************************************************************* |
| * 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.xtext.completeoclcs.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.InternalEList; |
| import org.eclipse.jdt.annotation.NonNull; |
| import org.eclipse.ocl.pivot.Operation; |
| import org.eclipse.ocl.pivot.utilities.PivotConstants; |
| import org.eclipse.ocl.xtext.basecs.ConstraintCS; |
| import org.eclipse.ocl.xtext.basecs.ParameterCS; |
| import org.eclipse.ocl.xtext.basecs.TemplateSignatureCS; |
| import org.eclipse.ocl.xtext.basecs.TemplateableElementCS; |
| import org.eclipse.ocl.xtext.basecs.impl.ModelElementCSImpl; |
| import org.eclipse.ocl.xtext.basecs.util.BaseCSVisitor; |
| import org.eclipse.ocl.xtext.completeoclcs.CompleteOCLCSPackage; |
| import org.eclipse.ocl.xtext.completeoclcs.OperationContextDeclCS; |
| import org.eclipse.ocl.xtext.completeoclcs.util.CompleteOCLCSVisitor; |
| import org.eclipse.ocl.xtext.essentialoclcs.EssentialOCLCSFactory; |
| import org.eclipse.ocl.xtext.essentialoclcs.ExpSpecificationCS; |
| import org.eclipse.ocl.xtext.essentialoclcs.VariableCS; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Operation Context Decl CS</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.ocl.xtext.completeoclcs.impl.OperationContextDeclCSImpl#getOwnedSignature <em>Owned Signature</em>}</li> |
| * <li>{@link org.eclipse.ocl.xtext.completeoclcs.impl.OperationContextDeclCSImpl#getOwnedBodies <em>Owned Bodies</em>}</li> |
| * <li>{@link org.eclipse.ocl.xtext.completeoclcs.impl.OperationContextDeclCSImpl#getOwnedParameters <em>Owned Parameters</em>}</li> |
| * <li>{@link org.eclipse.ocl.xtext.completeoclcs.impl.OperationContextDeclCSImpl#getOwnedPostconditions <em>Owned Postconditions</em>}</li> |
| * <li>{@link org.eclipse.ocl.xtext.completeoclcs.impl.OperationContextDeclCSImpl#getOwnedPreconditions <em>Owned Preconditions</em>}</li> |
| * <li>{@link org.eclipse.ocl.xtext.completeoclcs.impl.OperationContextDeclCSImpl#getOwnedResult <em>Owned Result</em>}</li> |
| * <li>{@link org.eclipse.ocl.xtext.completeoclcs.impl.OperationContextDeclCSImpl#getReferredOperation <em>Referred Operation</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public class OperationContextDeclCSImpl |
| extends FeatureContextDeclCSImpl |
| implements OperationContextDeclCS { |
| |
| /** |
| * The number of structural features of the '<em>Operation Context Decl CS</em>' class. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| * @ordered |
| */ |
| public static final int OPERATION_CONTEXT_DECL_CS_FEATURE_COUNT = FeatureContextDeclCSImpl.FEATURE_CONTEXT_DECL_CS_FEATURE_COUNT + 7; |
| |
| /** |
| * The cached value of the '{@link #getOwnedSignature() <em>Owned Signature</em>}' containment reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getOwnedSignature() |
| * @generated |
| * @ordered |
| */ |
| protected TemplateSignatureCS ownedSignature; |
| |
| /** |
| * The cached value of the '{@link #getOwnedBodies() <em>Owned Bodies</em>}' containment reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getOwnedBodies() |
| * @generated |
| * @ordered |
| */ |
| protected EList<ExpSpecificationCS> ownedBodies; |
| |
| /** |
| * The cached value of the '{@link #getOwnedParameters() <em>Owned Parameters</em>}' containment reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getOwnedParameters() |
| * @generated |
| * @ordered |
| */ |
| protected EList<ParameterCS> ownedParameters; |
| |
| /** |
| * The cached value of the '{@link #getOwnedPostconditions() <em>Owned Postconditions</em>}' containment reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getOwnedPostconditions() |
| * @generated |
| * @ordered |
| */ |
| protected EList<ConstraintCS> ownedPostconditions; |
| |
| /** |
| * The cached value of the '{@link #getOwnedPreconditions() <em>Owned Preconditions</em>}' containment reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getOwnedPreconditions() |
| * @generated |
| * @ordered |
| */ |
| protected EList<ConstraintCS> ownedPreconditions; |
| |
| /** |
| * The cached value of the '{@link #getOwnedResult() <em>Owned Result</em>}' containment reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getOwnedResult() |
| * @generated |
| * @ordered |
| */ |
| protected VariableCS ownedResult; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected OperationContextDeclCSImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return CompleteOCLCSPackage.Literals.OPERATION_CONTEXT_DECL_CS; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public TemplateSignatureCS getOwnedSignature() |
| { |
| return ownedSignature; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetOwnedSignature(TemplateSignatureCS newOwnedSignature, NotificationChain msgs) |
| { |
| TemplateSignatureCS oldOwnedSignature = ownedSignature; |
| ownedSignature = newOwnedSignature; |
| if (eNotificationRequired()) |
| { |
| ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 2, oldOwnedSignature, newOwnedSignature); |
| if (msgs == null) msgs = notification; else msgs.add(notification); |
| } |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setOwnedSignature(TemplateSignatureCS newOwnedSignature) |
| { |
| if (newOwnedSignature != ownedSignature) |
| { |
| NotificationChain msgs = null; |
| if (ownedSignature != null) |
| msgs = ((InternalEObject)ownedSignature).eInverseRemove(this, 6, TemplateSignatureCS.class, msgs); |
| if (newOwnedSignature != null) |
| msgs = ((InternalEObject)newOwnedSignature).eInverseAdd(this, 6, TemplateSignatureCS.class, msgs); |
| msgs = basicSetOwnedSignature(newOwnedSignature, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 2, newOwnedSignature, newOwnedSignature)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public EList<ParameterCS> getOwnedParameters() { |
| if (ownedParameters == null) |
| { |
| ownedParameters = new EObjectContainmentEList<ParameterCS>(ParameterCS.class, this, ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 4); |
| } |
| return ownedParameters; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated NOT |
| */ |
| @Override |
| public VariableCS getOwnedResult() { |
| if (ownedResult == null) { |
| VariableCS resultVariable = EssentialOCLCSFactory.eINSTANCE |
| .createVariableCS(); |
| resultVariable.setName(PivotConstants.RESULT_NAME); |
| // FIXME resultVariable.setType(getType()); |
| setOwnedResult(resultVariable); |
| } |
| return ownedResult; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetOwnedResult(VariableCS newOwnedResult, NotificationChain msgs) |
| { |
| VariableCS oldOwnedResult = ownedResult; |
| ownedResult = newOwnedResult; |
| if (eNotificationRequired()) |
| { |
| ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 7, oldOwnedResult, newOwnedResult); |
| if (msgs == null) msgs = notification; else msgs.add(notification); |
| } |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setOwnedResult(VariableCS newOwnedResult) { |
| if (newOwnedResult != ownedResult) |
| { |
| NotificationChain msgs = null; |
| if (ownedResult != null) |
| msgs = ((InternalEObject)ownedResult).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - (ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 7), null, msgs); |
| if (newOwnedResult != null) |
| msgs = ((InternalEObject)newOwnedResult).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - (ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 7), null, msgs); |
| msgs = basicSetOwnedResult(newOwnedResult, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 7, newOwnedResult, newOwnedResult)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public EList<ConstraintCS> getOwnedPreconditions() { |
| if (ownedPreconditions == null) |
| { |
| ownedPreconditions = new EObjectContainmentEList<ConstraintCS>(ConstraintCS.class, this, ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 6); |
| } |
| return ownedPreconditions; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public EList<ConstraintCS> getOwnedPostconditions() { |
| if (ownedPostconditions == null) |
| { |
| ownedPostconditions = new EObjectContainmentEList<ConstraintCS>(ConstraintCS.class, this, ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 5); |
| } |
| return ownedPostconditions; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public EList<ExpSpecificationCS> getOwnedBodies() { |
| if (ownedBodies == null) |
| { |
| ownedBodies = new EObjectContainmentEList<ExpSpecificationCS>(ExpSpecificationCS.class, this, ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 3); |
| } |
| return ownedBodies; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) |
| { |
| switch (featureID) |
| { |
| case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 2: |
| if (ownedSignature != null) |
| msgs = ((InternalEObject)ownedSignature).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - (ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 2), null, msgs); |
| return basicSetOwnedSignature((TemplateSignatureCS)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 ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 2: |
| return basicSetOwnedSignature(null, msgs); |
| case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 3: |
| return ((InternalEList<?>)getOwnedBodies()).basicRemove(otherEnd, msgs); |
| case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 4: |
| return ((InternalEList<?>)getOwnedParameters()).basicRemove(otherEnd, msgs); |
| case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 5: |
| return ((InternalEList<?>)getOwnedPostconditions()).basicRemove(otherEnd, msgs); |
| case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 6: |
| return ((InternalEList<?>)getOwnedPreconditions()).basicRemove(otherEnd, msgs); |
| case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 7: |
| return basicSetOwnedResult(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 ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 2: |
| return getOwnedSignature(); |
| case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 3: |
| return getOwnedBodies(); |
| case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 4: |
| return getOwnedParameters(); |
| case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 5: |
| return getOwnedPostconditions(); |
| case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 6: |
| return getOwnedPreconditions(); |
| case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 7: |
| return getOwnedResult(); |
| case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 8: |
| return getReferredOperation(); |
| } |
| 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 ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 2: |
| setOwnedSignature((TemplateSignatureCS)newValue); |
| return; |
| case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 3: |
| getOwnedBodies().clear(); |
| getOwnedBodies().addAll((Collection<? extends ExpSpecificationCS>)newValue); |
| return; |
| case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 4: |
| getOwnedParameters().clear(); |
| getOwnedParameters().addAll((Collection<? extends ParameterCS>)newValue); |
| return; |
| case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 5: |
| getOwnedPostconditions().clear(); |
| getOwnedPostconditions().addAll((Collection<? extends ConstraintCS>)newValue); |
| return; |
| case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 6: |
| getOwnedPreconditions().clear(); |
| getOwnedPreconditions().addAll((Collection<? extends ConstraintCS>)newValue); |
| return; |
| case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 7: |
| setOwnedResult((VariableCS)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) |
| { |
| case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 2: |
| setOwnedSignature((TemplateSignatureCS)null); |
| return; |
| case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 3: |
| getOwnedBodies().clear(); |
| return; |
| case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 4: |
| getOwnedParameters().clear(); |
| return; |
| case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 5: |
| getOwnedPostconditions().clear(); |
| return; |
| case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 6: |
| getOwnedPreconditions().clear(); |
| return; |
| case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 7: |
| setOwnedResult((VariableCS)null); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) |
| { |
| case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 2: |
| return ownedSignature != null; |
| case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 3: |
| return ownedBodies != null && !ownedBodies.isEmpty(); |
| case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 4: |
| return ownedParameters != null && !ownedParameters.isEmpty(); |
| case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 5: |
| return ownedPostconditions != null && !ownedPostconditions.isEmpty(); |
| case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 6: |
| return ownedPreconditions != null && !ownedPreconditions.isEmpty(); |
| case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 7: |
| return ownedResult != null; |
| case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 8: |
| return getReferredOperation() != null; |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) |
| { |
| if (baseClass == TemplateableElementCS.class) |
| { |
| switch (derivedFeatureID) |
| { |
| case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 2: return 2; |
| 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 == TemplateableElementCS.class) |
| { |
| switch (baseFeatureID) |
| { |
| case 2: return ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 2; |
| default: return -1; |
| } |
| } |
| return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); |
| } |
| |
| /** |
| * {@inheritDoc} |
| * @generated |
| */ |
| @SuppressWarnings("unchecked") |
| @Override |
| public <R> R accept(@NonNull BaseCSVisitor<R> visitor) { |
| if (visitor instanceof CompleteOCLCSVisitor) { |
| return (R) ((CompleteOCLCSVisitor<?>)visitor).visitOperationContextDeclCS(this); |
| } |
| else { |
| return super.accept(visitor); |
| } |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated NOT |
| */ |
| @Override |
| public Operation getReferredOperation() { |
| if (ownedPathName == null) { |
| return null; |
| } |
| return (Operation) ownedPathName.getReferredElement(); |
| } |
| } //OperationContextDeclCSImpl |