| /** |
| * Copyright (c) 2010, 2015 Willink Transformations and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.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.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.OCLExpression; |
| import org.eclipse.ocl.pivot.PatternLiteral; |
| import org.eclipse.ocl.pivot.PivotPackage; |
| import org.eclipse.ocl.pivot.Variable; |
| |
| import org.eclipse.ocl.pivot.util.Visitor; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Pattern Literal</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.ocl.pivot.internal.PatternLiteralImpl#getOwnedExpression <em>Owned Expression</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public class PatternLiteralImpl extends PatternValueImpl implements PatternLiteral |
| { |
| /** |
| * The cached value of the '{@link #getOwnedExpression() <em>Owned Expression</em>}' containment reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getOwnedExpression() |
| * @generated |
| * @ordered |
| */ |
| protected OCLExpression ownedExpression; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected PatternLiteralImpl() |
| { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() |
| { |
| return PivotPackage.Literals.PATTERN_LITERAL; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public OCLExpression getOwnedExpression() |
| { |
| return ownedExpression; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetOwnedExpression(OCLExpression newOwnedExpression, NotificationChain msgs) |
| { |
| OCLExpression oldOwnedExpression = ownedExpression; |
| ownedExpression = newOwnedExpression; |
| if (eNotificationRequired()) |
| { |
| ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, PivotPackage.PATTERN_LITERAL__OWNED_EXPRESSION, oldOwnedExpression, newOwnedExpression); |
| if (msgs == null) msgs = notification; else msgs.add(notification); |
| } |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setOwnedExpression(OCLExpression newOwnedExpression) |
| { |
| if (newOwnedExpression != ownedExpression) |
| { |
| NotificationChain msgs = null; |
| if (ownedExpression != null) |
| msgs = ((InternalEObject)ownedExpression).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - PivotPackage.PATTERN_LITERAL__OWNED_EXPRESSION, null, msgs); |
| if (newOwnedExpression != null) |
| msgs = ((InternalEObject)newOwnedExpression).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - PivotPackage.PATTERN_LITERAL__OWNED_EXPRESSION, null, msgs); |
| msgs = basicSetOwnedExpression(newOwnedExpression, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, PivotPackage.PATTERN_LITERAL__OWNED_EXPRESSION, newOwnedExpression, newOwnedExpression)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) |
| { |
| switch (featureID) |
| { |
| case PivotPackage.PATTERN_LITERAL__ANNOTATING_COMMENTS: |
| return ((InternalEList<?>)getAnnotatingComments()).basicRemove(otherEnd, msgs); |
| case PivotPackage.PATTERN_LITERAL__OWNED_ANNOTATIONS: |
| return ((InternalEList<?>)getOwnedAnnotations()).basicRemove(otherEnd, msgs); |
| case PivotPackage.PATTERN_LITERAL__OWNED_COMMENTS: |
| return ((InternalEList<?>)getOwnedComments()).basicRemove(otherEnd, msgs); |
| case PivotPackage.PATTERN_LITERAL__OWNED_EXTENSIONS: |
| return ((InternalEList<?>)getOwnedExtensions()).basicRemove(otherEnd, msgs); |
| case PivotPackage.PATTERN_LITERAL__OWNED_EXPRESSION: |
| return basicSetOwnedExpression(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 PivotPackage.PATTERN_LITERAL__ANNOTATING_COMMENTS: |
| return getAnnotatingComments(); |
| case PivotPackage.PATTERN_LITERAL__OWNED_ANNOTATIONS: |
| return getOwnedAnnotations(); |
| case PivotPackage.PATTERN_LITERAL__OWNED_COMMENTS: |
| return getOwnedComments(); |
| case PivotPackage.PATTERN_LITERAL__OWNED_EXTENSIONS: |
| return getOwnedExtensions(); |
| case PivotPackage.PATTERN_LITERAL__REFERRED_VARIABLE: |
| if (resolve) return getReferredVariable(); |
| return basicGetReferredVariable(); |
| case PivotPackage.PATTERN_LITERAL__OWNED_EXPRESSION: |
| return getOwnedExpression(); |
| } |
| 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 PivotPackage.PATTERN_LITERAL__ANNOTATING_COMMENTS: |
| getAnnotatingComments().clear(); |
| getAnnotatingComments().addAll((Collection<? extends Comment>)newValue); |
| return; |
| case PivotPackage.PATTERN_LITERAL__OWNED_ANNOTATIONS: |
| getOwnedAnnotations().clear(); |
| getOwnedAnnotations().addAll((Collection<? extends Element>)newValue); |
| return; |
| case PivotPackage.PATTERN_LITERAL__OWNED_COMMENTS: |
| getOwnedComments().clear(); |
| getOwnedComments().addAll((Collection<? extends Comment>)newValue); |
| return; |
| case PivotPackage.PATTERN_LITERAL__OWNED_EXTENSIONS: |
| getOwnedExtensions().clear(); |
| getOwnedExtensions().addAll((Collection<? extends ElementExtension>)newValue); |
| return; |
| case PivotPackage.PATTERN_LITERAL__REFERRED_VARIABLE: |
| setReferredVariable((Variable)newValue); |
| return; |
| case PivotPackage.PATTERN_LITERAL__OWNED_EXPRESSION: |
| setOwnedExpression((OCLExpression)newValue); |
| return; |
| } |
| eDynamicSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) |
| { |
| switch (featureID) |
| { |
| case PivotPackage.PATTERN_LITERAL__ANNOTATING_COMMENTS: |
| getAnnotatingComments().clear(); |
| return; |
| case PivotPackage.PATTERN_LITERAL__OWNED_ANNOTATIONS: |
| getOwnedAnnotations().clear(); |
| return; |
| case PivotPackage.PATTERN_LITERAL__OWNED_COMMENTS: |
| getOwnedComments().clear(); |
| return; |
| case PivotPackage.PATTERN_LITERAL__OWNED_EXTENSIONS: |
| getOwnedExtensions().clear(); |
| return; |
| case PivotPackage.PATTERN_LITERAL__REFERRED_VARIABLE: |
| setReferredVariable((Variable)null); |
| return; |
| case PivotPackage.PATTERN_LITERAL__OWNED_EXPRESSION: |
| setOwnedExpression((OCLExpression)null); |
| return; |
| } |
| eDynamicUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) |
| { |
| switch (featureID) |
| { |
| case PivotPackage.PATTERN_LITERAL__ANNOTATING_COMMENTS: |
| return annotatingComments != null && !annotatingComments.isEmpty(); |
| case PivotPackage.PATTERN_LITERAL__OWNED_ANNOTATIONS: |
| return ownedAnnotations != null && !ownedAnnotations.isEmpty(); |
| case PivotPackage.PATTERN_LITERAL__OWNED_COMMENTS: |
| return ownedComments != null && !ownedComments.isEmpty(); |
| case PivotPackage.PATTERN_LITERAL__OWNED_EXTENSIONS: |
| return ownedExtensions != null && !ownedExtensions.isEmpty(); |
| case PivotPackage.PATTERN_LITERAL__REFERRED_VARIABLE: |
| return referredVariable != null; |
| case PivotPackage.PATTERN_LITERAL__OWNED_EXPRESSION: |
| return ownedExpression != null; |
| } |
| return eDynamicIsSet(featureID); |
| } |
| |
| /** |
| * {@inheritDoc} |
| * @generated |
| */ |
| @Override |
| public <R> R accept(@NonNull Visitor<R> visitor) { |
| return visitor.visitPatternLiteral(this); |
| } |
| |
| } //PatternLiteralImpl |