/** * <copyright> * Copyright (c) 2013 Willink Transformations, University of York, 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 * Adolfo Sanchez-Barbudo (University of York) - Bug397429 * </copyright> */ package org.eclipse.qvto.examples.pivot.imperativeocl.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.ocl.pivot.OCLExpression; import org.eclipse.ocl.pivot.util.Visitor; import org.eclipse.qvto.examples.pivot.imperativeocl.AssignExp; import org.eclipse.qvto.examples.pivot.imperativeocl.ImperativeOCLPackage; import org.eclipse.qvto.examples.pivot.imperativeocl.util.ImperativeOCLVisitor; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>Assign Exp</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * </p> * <ul> * <li>{@link org.eclipse.qvto.examples.pivot.imperativeocl.impl.AssignExpImpl#getDefaultValue <em>Default Value</em>}</li> * <li>{@link org.eclipse.qvto.examples.pivot.imperativeocl.impl.AssignExpImpl#isIsReset <em>Is Reset</em>}</li> * <li>{@link org.eclipse.qvto.examples.pivot.imperativeocl.impl.AssignExpImpl#getLeft <em>Left</em>}</li> * <li>{@link org.eclipse.qvto.examples.pivot.imperativeocl.impl.AssignExpImpl#getValue <em>Value</em>}</li> * </ul> * * @generated */ public class AssignExpImpl extends ImperativeExpressionImpl implements AssignExp { /** * The cached value of the '{@link #getDefaultValue() <em>Default Value</em>}' containment reference. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getDefaultValue() * @generated * @ordered */ protected OCLExpression defaultValue; /** * The default value of the '{@link #isIsReset() <em>Is Reset</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #isIsReset() * @generated * @ordered */ protected static final boolean IS_RESET_EDEFAULT = false; /** * The cached value of the '{@link #isIsReset() <em>Is Reset</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #isIsReset() * @generated * @ordered */ protected boolean isReset = IS_RESET_EDEFAULT; /** * The cached value of the '{@link #getLeft() <em>Left</em>}' containment reference. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getLeft() * @generated * @ordered */ protected OCLExpression left; /** * The cached value of the '{@link #getValue() <em>Value</em>}' containment reference list. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getValue() * @generated * @ordered */ protected EList<OCLExpression> value; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected AssignExpImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return ImperativeOCLPackage.Literals.ASSIGN_EXP; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public OCLExpression getDefaultValue() { return defaultValue; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain basicSetDefaultValue(OCLExpression newDefaultValue, NotificationChain msgs) { OCLExpression oldDefaultValue = defaultValue; defaultValue = newDefaultValue; if (eNotificationRequired()) { ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ImperativeOCLPackage.ASSIGN_EXP__DEFAULT_VALUE, oldDefaultValue, newDefaultValue); if (msgs == null) msgs = notification; else msgs.add(notification); } return msgs; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setDefaultValue(OCLExpression newDefaultValue) { if (newDefaultValue != defaultValue) { NotificationChain msgs = null; if (defaultValue != null) msgs = ((InternalEObject)defaultValue).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ImperativeOCLPackage.ASSIGN_EXP__DEFAULT_VALUE, null, msgs); if (newDefaultValue != null) msgs = ((InternalEObject)newDefaultValue).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ImperativeOCLPackage.ASSIGN_EXP__DEFAULT_VALUE, null, msgs); msgs = basicSetDefaultValue(newDefaultValue, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, ImperativeOCLPackage.ASSIGN_EXP__DEFAULT_VALUE, newDefaultValue, newDefaultValue)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public boolean isIsReset() { return isReset; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setIsReset(boolean newIsReset) { boolean oldIsReset = isReset; isReset = newIsReset; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, ImperativeOCLPackage.ASSIGN_EXP__IS_RESET, oldIsReset, isReset)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public OCLExpression getLeft() { return left; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain basicSetLeft(OCLExpression newLeft, NotificationChain msgs) { OCLExpression oldLeft = left; left = newLeft; if (eNotificationRequired()) { ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ImperativeOCLPackage.ASSIGN_EXP__LEFT, oldLeft, newLeft); if (msgs == null) msgs = notification; else msgs.add(notification); } return msgs; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setLeft(OCLExpression newLeft) { if (newLeft != left) { NotificationChain msgs = null; if (left != null) msgs = ((InternalEObject)left).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ImperativeOCLPackage.ASSIGN_EXP__LEFT, null, msgs); if (newLeft != null) msgs = ((InternalEObject)newLeft).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ImperativeOCLPackage.ASSIGN_EXP__LEFT, null, msgs); msgs = basicSetLeft(newLeft, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, ImperativeOCLPackage.ASSIGN_EXP__LEFT, newLeft, newLeft)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EList<OCLExpression> getValue() { if (value == null) { value = new EObjectContainmentEList<OCLExpression>(OCLExpression.class, this, ImperativeOCLPackage.ASSIGN_EXP__VALUE); } return value; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case ImperativeOCLPackage.ASSIGN_EXP__DEFAULT_VALUE: return basicSetDefaultValue(null, msgs); case ImperativeOCLPackage.ASSIGN_EXP__LEFT: return basicSetLeft(null, msgs); case ImperativeOCLPackage.ASSIGN_EXP__VALUE: return ((InternalEList<?>)getValue()).basicRemove(otherEnd, 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 ImperativeOCLPackage.ASSIGN_EXP__DEFAULT_VALUE: return getDefaultValue(); case ImperativeOCLPackage.ASSIGN_EXP__IS_RESET: return isIsReset(); case ImperativeOCLPackage.ASSIGN_EXP__LEFT: return getLeft(); case ImperativeOCLPackage.ASSIGN_EXP__VALUE: return getValue(); } 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 ImperativeOCLPackage.ASSIGN_EXP__DEFAULT_VALUE: setDefaultValue((OCLExpression)newValue); return; case ImperativeOCLPackage.ASSIGN_EXP__IS_RESET: setIsReset((Boolean)newValue); return; case ImperativeOCLPackage.ASSIGN_EXP__LEFT: setLeft((OCLExpression)newValue); return; case ImperativeOCLPackage.ASSIGN_EXP__VALUE: getValue().clear(); getValue().addAll((Collection<? extends OCLExpression>)newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case ImperativeOCLPackage.ASSIGN_EXP__DEFAULT_VALUE: setDefaultValue((OCLExpression)null); return; case ImperativeOCLPackage.ASSIGN_EXP__IS_RESET: setIsReset(IS_RESET_EDEFAULT); return; case ImperativeOCLPackage.ASSIGN_EXP__LEFT: setLeft((OCLExpression)null); return; case ImperativeOCLPackage.ASSIGN_EXP__VALUE: getValue().clear(); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case ImperativeOCLPackage.ASSIGN_EXP__DEFAULT_VALUE: return defaultValue != null; case ImperativeOCLPackage.ASSIGN_EXP__IS_RESET: return isReset != IS_RESET_EDEFAULT; case ImperativeOCLPackage.ASSIGN_EXP__LEFT: return left != null; case ImperativeOCLPackage.ASSIGN_EXP__VALUE: return value != null && !value.isEmpty(); } return super.eIsSet(featureID); } @Override public String toString() { return super.toString(); } /** * {@inheritDoc} * @generated */ @SuppressWarnings("unchecked") @Override public <R> R accept(Visitor<R> visitor) { return (R) ((ImperativeOCLVisitor<?>)visitor).visitAssignExp(this); } } //AssignExpImpl