/** * <copyright> * Copyright (c) 2008, 2009 Open Canarias S.L. 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: * A. Sanchez-Barbudo - initial API and implementation * </copyright> * * $Id: SwitchExpImpl.java,v 1.3 2009/02/06 15:47:30 radvorak Exp $ */ package org.eclipse.m2m.qvt.oml.ecore.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.m2m.qvt.oml.ecore.ImperativeOCL.AltExp; import org.eclipse.m2m.qvt.oml.ecore.ImperativeOCL.ImperativeOCLPackage; import org.eclipse.m2m.qvt.oml.ecore.ImperativeOCL.SwitchExp; import org.eclipse.m2m.qvt.oml.ecore.ImperativeOCL.util.ImperativeOCLVisitor; import org.eclipse.ocl.ecore.OCLExpression; import org.eclipse.ocl.utilities.Visitor; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>Switch Exp</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * <ul> * <li>{@link org.eclipse.m2m.qvt.oml.ecore.ImperativeOCL.impl.SwitchExpImpl#getAlternativePart <em>Alternative Part</em>}</li> * <li>{@link org.eclipse.m2m.qvt.oml.ecore.ImperativeOCL.impl.SwitchExpImpl#getElsePart <em>Else Part</em>}</li> * </ul> * </p> * * @generated */ public class SwitchExpImpl extends ImperativeExpressionImpl implements SwitchExp { /** * The cached value of the '{@link #getAlternativePart() <em>Alternative Part</em>}' containment reference list. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getAlternativePart() * @generated * @ordered */ protected EList<AltExp> alternativePart; /** * The cached value of the '{@link #getElsePart() <em>Else Part</em>}' containment reference. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getElsePart() * @generated * @ordered */ protected OCLExpression elsePart; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected SwitchExpImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return ImperativeOCLPackage.Literals.SWITCH_EXP; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EList<AltExp> getAlternativePart() { if (alternativePart == null) { alternativePart = new EObjectContainmentEList<AltExp>(AltExp.class, this, ImperativeOCLPackage.SWITCH_EXP__ALTERNATIVE_PART); } return alternativePart; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public OCLExpression getElsePart() { return elsePart; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain basicSetElsePart(OCLExpression newElsePart, NotificationChain msgs) { OCLExpression oldElsePart = elsePart; elsePart = newElsePart; if (eNotificationRequired()) { ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ImperativeOCLPackage.SWITCH_EXP__ELSE_PART, oldElsePart, newElsePart); if (msgs == null) msgs = notification; else msgs.add(notification); } return msgs; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setElsePart(OCLExpression newElsePart) { if (newElsePart != elsePart) { NotificationChain msgs = null; if (elsePart != null) msgs = ((InternalEObject)elsePart).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ImperativeOCLPackage.SWITCH_EXP__ELSE_PART, null, msgs); if (newElsePart != null) msgs = ((InternalEObject)newElsePart).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ImperativeOCLPackage.SWITCH_EXP__ELSE_PART, null, msgs); msgs = basicSetElsePart(newElsePart, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, ImperativeOCLPackage.SWITCH_EXP__ELSE_PART, newElsePart, newElsePart)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case ImperativeOCLPackage.SWITCH_EXP__ALTERNATIVE_PART: return ((InternalEList<?>)getAlternativePart()).basicRemove(otherEnd, msgs); case ImperativeOCLPackage.SWITCH_EXP__ELSE_PART: return basicSetElsePart(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 ImperativeOCLPackage.SWITCH_EXP__ALTERNATIVE_PART: return getAlternativePart(); case ImperativeOCLPackage.SWITCH_EXP__ELSE_PART: return getElsePart(); } 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.SWITCH_EXP__ALTERNATIVE_PART: getAlternativePart().clear(); getAlternativePart().addAll((Collection<? extends AltExp>)newValue); return; case ImperativeOCLPackage.SWITCH_EXP__ELSE_PART: setElsePart((OCLExpression)newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case ImperativeOCLPackage.SWITCH_EXP__ALTERNATIVE_PART: getAlternativePart().clear(); return; case ImperativeOCLPackage.SWITCH_EXP__ELSE_PART: setElsePart((OCLExpression)null); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case ImperativeOCLPackage.SWITCH_EXP__ALTERNATIVE_PART: return alternativePart != null && !alternativePart.isEmpty(); case ImperativeOCLPackage.SWITCH_EXP__ELSE_PART: return elsePart != null; } return super.eIsSet(featureID); } /** * @generated NOT */ @SuppressWarnings("unchecked") @Override public <T, U extends Visitor<T, ?, ?, ?, ?, ?, ?, ?, ?, ?>> T accept(U v) { if (v instanceof ImperativeOCLVisitor) return (T) ((ImperativeOCLVisitor) v).visitSwitchExp(this); return super.<T, U>accept(v); } } //SwitchExpImpl