| /******************************************************************************* |
| * 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 java.util.List; |
| |
| 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.Comment; |
| import org.eclipse.ocl.pivot.Constraint; |
| import org.eclipse.ocl.pivot.Element; |
| import org.eclipse.ocl.pivot.ElementExtension; |
| import org.eclipse.ocl.pivot.ExpressionInOCL; |
| import org.eclipse.ocl.pivot.OCLExpression; |
| import org.eclipse.ocl.pivot.PivotPackage; |
| import org.eclipse.ocl.pivot.Type; |
| import org.eclipse.ocl.pivot.Variable; |
| import org.eclipse.ocl.pivot.util.Visitor; |
| import org.eclipse.ocl.pivot.utilities.PivotConstants; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Expression In Ocl</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.ocl.pivot.internal.ExpressionInOCLImpl#getOwnedBody <em>Owned Body</em>}</li> |
| * <li>{@link org.eclipse.ocl.pivot.internal.ExpressionInOCLImpl#getOwnedContext <em>Owned Context</em>}</li> |
| * <li>{@link org.eclipse.ocl.pivot.internal.ExpressionInOCLImpl#getOwnedParameters <em>Owned Parameters</em>}</li> |
| * <li>{@link org.eclipse.ocl.pivot.internal.ExpressionInOCLImpl#getOwnedResult <em>Owned Result</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public class ExpressionInOCLImpl |
| extends LanguageExpressionImpl |
| implements ExpressionInOCL { |
| |
| /** |
| * The number of structural features of the '<em>Expression In OCL</em>' class. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| * @ordered |
| */ |
| public static final int EXPRESSION_IN_OCL_FEATURE_COUNT = LanguageExpressionImpl.LANGUAGE_EXPRESSION_FEATURE_COUNT + 4; |
| |
| /** |
| * The number of operations of the '<em>Expression In OCL</em>' class. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| * @ordered |
| */ |
| public static final int EXPRESSION_IN_OCL_OPERATION_COUNT = LanguageExpressionImpl.LANGUAGE_EXPRESSION_OPERATION_COUNT + 0; |
| |
| /** |
| * The cached value of the '{@link #getOwnedBody() <em>Owned Body</em>}' containment reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getOwnedBody() |
| * @generated |
| * @ordered |
| */ |
| protected OCLExpression ownedBody; |
| |
| /** |
| * The cached value of the '{@link #getOwnedContext() <em>Owned Context</em>}' containment reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getOwnedContext() |
| * @generated |
| * @ordered |
| */ |
| protected Variable ownedContext; |
| |
| /** |
| * 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<Variable> ownedParameters; |
| |
| /** |
| * The cached value of the '{@link #getOwnedResult() <em>Owned Result</em>}' containment reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getOwnedResult() |
| * @generated |
| * @ordered |
| */ |
| protected Variable ownedResult; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected ExpressionInOCLImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return PivotPackage.Literals.EXPRESSION_IN_OCL; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public OCLExpression getOwnedBody() { |
| return ownedBody; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetOwnedBody(OCLExpression newOwnedBody, NotificationChain msgs) |
| { |
| OCLExpression oldOwnedBody = ownedBody; |
| ownedBody = newOwnedBody; |
| if (eNotificationRequired()) |
| { |
| ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, 11, oldOwnedBody, newOwnedBody); |
| if (msgs == null) msgs = notification; else msgs.add(notification); |
| } |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setOwnedBody(OCLExpression newOwnedBody) { |
| if (newOwnedBody != ownedBody) |
| { |
| NotificationChain msgs = null; |
| if (ownedBody != null) |
| msgs = ((InternalEObject)ownedBody).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - (11), null, msgs); |
| if (newOwnedBody != null) |
| msgs = ((InternalEObject)newOwnedBody).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - (11), null, msgs); |
| msgs = basicSetOwnedBody(newOwnedBody, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, 11, newOwnedBody, newOwnedBody)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Variable getOwnedContext() { |
| return ownedContext; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetOwnedContext(Variable newOwnedContext, NotificationChain msgs) |
| { |
| Variable oldOwnedContext = ownedContext; |
| ownedContext = newOwnedContext; |
| if (eNotificationRequired()) |
| { |
| ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, 12, oldOwnedContext, newOwnedContext); |
| if (msgs == null) msgs = notification; else msgs.add(notification); |
| } |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setOwnedContext(Variable newOwnedContext) { |
| if (newOwnedContext != ownedContext) |
| { |
| NotificationChain msgs = null; |
| if (ownedContext != null) |
| msgs = ((InternalEObject)ownedContext).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - (12), null, msgs); |
| if (newOwnedContext != null) |
| msgs = ((InternalEObject)newOwnedContext).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - (12), null, msgs); |
| msgs = basicSetOwnedContext(newOwnedContext, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, 12, newOwnedContext, newOwnedContext)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Variable getOwnedResult() { |
| return ownedResult; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetOwnedResult(Variable newOwnedResult, NotificationChain msgs) |
| { |
| Variable oldOwnedResult = ownedResult; |
| ownedResult = newOwnedResult; |
| if (eNotificationRequired()) |
| { |
| ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, 14, oldOwnedResult, newOwnedResult); |
| if (msgs == null) msgs = notification; else msgs.add(notification); |
| } |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setOwnedResult(Variable newOwnedResult) { |
| if (newOwnedResult != ownedResult) |
| { |
| NotificationChain msgs = null; |
| if (ownedResult != null) |
| msgs = ((InternalEObject)ownedResult).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - (14), null, msgs); |
| if (newOwnedResult != null) |
| msgs = ((InternalEObject)newOwnedResult).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - (14), null, msgs); |
| msgs = basicSetOwnedResult(newOwnedResult, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, 14, newOwnedResult, newOwnedResult)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| @SuppressWarnings("null") |
| public @NonNull List<Variable> getOwnedParameters() |
| { |
| if (ownedParameters == null) |
| { |
| ownedParameters = new EObjectContainmentEList<Variable>(Variable.class, this, 13); |
| } |
| return ownedParameters; |
| } |
| |
| /** |
| * <!-- 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 10: |
| return basicSetOwningConstraint(null, msgs); |
| case 11: |
| return basicSetOwnedBody(null, msgs); |
| case 12: |
| return basicSetOwnedContext(null, msgs); |
| case 13: |
| return ((InternalEList<?>)getOwnedParameters()).basicRemove(otherEnd, msgs); |
| case 14: |
| return basicSetOwnedResult(null, msgs); |
| } |
| return eDynamicInverseRemove(otherEnd, featureID, 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: |
| return getName(); |
| case 5: |
| return isIsMany(); |
| case 6: |
| return isIsRequired(); |
| case 7: |
| if (resolve) return getType(); |
| return basicGetType(); |
| case 8: |
| return getBody(); |
| case 9: |
| return getLanguage(); |
| case 10: |
| return getOwningConstraint(); |
| case 11: |
| return getOwnedBody(); |
| case 12: |
| return getOwnedContext(); |
| case 13: |
| return getOwnedParameters(); |
| case 14: |
| return getOwnedResult(); |
| } |
| 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: |
| setName((String)newValue); |
| return; |
| case 6: |
| setIsRequired((Boolean)newValue); |
| return; |
| case 7: |
| setType((Type)newValue); |
| return; |
| case 8: |
| setBody((String)newValue); |
| return; |
| case 10: |
| setOwningConstraint((Constraint)newValue); |
| return; |
| case 11: |
| setOwnedBody((OCLExpression)newValue); |
| return; |
| case 12: |
| setOwnedContext((Variable)newValue); |
| return; |
| case 13: |
| getOwnedParameters().clear(); |
| getOwnedParameters().addAll((Collection<? extends Variable>)newValue); |
| return; |
| case 14: |
| setOwnedResult((Variable)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: |
| setName(NAME_EDEFAULT); |
| return; |
| case 6: |
| setIsRequired(IS_REQUIRED_EDEFAULT); |
| return; |
| case 7: |
| setType((Type)null); |
| return; |
| case 8: |
| setBody(BODY_EDEFAULT); |
| return; |
| case 10: |
| setOwningConstraint((Constraint)null); |
| return; |
| case 11: |
| setOwnedBody((OCLExpression)null); |
| return; |
| case 12: |
| setOwnedContext((Variable)null); |
| return; |
| case 13: |
| getOwnedParameters().clear(); |
| return; |
| case 14: |
| setOwnedResult((Variable)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 NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); |
| case 5: |
| return isIsMany() != IS_MANY_EDEFAULT; |
| case 6: |
| return ((eFlags & IS_REQUIRED_EFLAG) != 0) != IS_REQUIRED_EDEFAULT; |
| case 7: |
| return type != null; |
| case 8: |
| return BODY_EDEFAULT == null ? body != null : !BODY_EDEFAULT.equals(body); |
| case 9: |
| return LANGUAGE_EDEFAULT == null ? getLanguage() != null : !LANGUAGE_EDEFAULT.equals(getLanguage()); |
| case 10: |
| return getOwningConstraint() != null; |
| case 11: |
| return ownedBody != null; |
| case 12: |
| return ownedContext != null; |
| case 13: |
| return ownedParameters != null && !ownedParameters.isEmpty(); |
| case 14: |
| return ownedResult != null; |
| } |
| return eDynamicIsSet(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated NOT |
| */ |
| @Override |
| public String toString() { |
| return super.toString(); |
| } |
| |
| @Override |
| public <R> R accept(@NonNull Visitor<R> visitor) { |
| return visitor.visitExpressionInOCL(this); |
| } |
| |
| @Override |
| public String getLanguage() { |
| return PivotConstants.OCL_LANGUAGE; |
| } |
| } //ExpressionInOCLImpl |