blob: fbb2ca6e5e3234235502b23bcc6086cacf299820 [file] [log] [blame]
/**
* <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 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
* 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.AltExp;
import org.eclipse.qvto.examples.pivot.imperativeocl.ImperativeOCLPackage;
import org.eclipse.qvto.examples.pivot.imperativeocl.SwitchExp;
import org.eclipse.qvto.examples.pivot.imperativeocl.util.ImperativeOCLVisitor;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Switch Exp</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.qvto.examples.pivot.imperativeocl.impl.SwitchExpImpl#getAlternativePart <em>Alternative Part</em>}</li>
* <li>{@link org.eclipse.qvto.examples.pivot.imperativeocl.impl.SwitchExpImpl#getElsePart <em>Else Part</em>}</li>
* </ul>
*
* @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);
}
/**
* {@inheritDoc}
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public <R> R accept(Visitor<R> visitor) {
return (R) ((ImperativeOCLVisitor<?>)visitor).visitSwitchExp(this);
}
} //SwitchExpImpl