blob: fbe333088f715ecc8b021f23fa0e64f616021812 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2009, 2019 Xored Software Inc 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
* https://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Xored Software Inc - initial API and implementation and/or initial documentation
*******************************************************************************/
package org.eclipse.rcptt.ecl.core.impl;
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.EObject;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.rcptt.ecl.core.Command;
import org.eclipse.rcptt.ecl.core.CorePackage;
import org.eclipse.rcptt.ecl.core.If;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>If</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.rcptt.ecl.core.impl.IfImpl#getCondition <em>Condition</em>}</li>
* <li>{@link org.eclipse.rcptt.ecl.core.impl.IfImpl#getThen <em>Then</em>}</li>
* <li>{@link org.eclipse.rcptt.ecl.core.impl.IfImpl#getElse <em>Else</em>}</li>
* </ul>
*
* @generated
*/
public class IfImpl extends CommandImpl implements If {
/**
* The cached value of the '{@link #getCondition() <em>Condition</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getCondition()
* @generated
* @ordered
*/
protected EObject condition;
/**
* The cached value of the '{@link #getThen() <em>Then</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getThen()
* @generated
* @ordered
*/
protected Command then;
/**
* The cached value of the '{@link #getElse() <em>Else</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getElse()
* @generated
* @ordered
*/
protected Command else_;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected IfImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return CorePackage.Literals.IF;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public EObject getCondition() {
if (condition != null && condition.eIsProxy()) {
InternalEObject oldCondition = (InternalEObject)condition;
condition = eResolveProxy(oldCondition);
if (condition != oldCondition) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, CorePackage.IF__CONDITION, oldCondition, condition));
}
}
return condition;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EObject basicGetCondition() {
return condition;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setCondition(EObject newCondition) {
EObject oldCondition = condition;
condition = newCondition;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, CorePackage.IF__CONDITION, oldCondition, condition));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Command getThen() {
return then;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetThen(Command newThen, NotificationChain msgs) {
Command oldThen = then;
then = newThen;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CorePackage.IF__THEN, oldThen, newThen);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setThen(Command newThen) {
if (newThen != then) {
NotificationChain msgs = null;
if (then != null)
msgs = ((InternalEObject)then).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CorePackage.IF__THEN, null, msgs);
if (newThen != null)
msgs = ((InternalEObject)newThen).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CorePackage.IF__THEN, null, msgs);
msgs = basicSetThen(newThen, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, CorePackage.IF__THEN, newThen, newThen));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Command getElse() {
return else_;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetElse(Command newElse, NotificationChain msgs) {
Command oldElse = else_;
else_ = newElse;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CorePackage.IF__ELSE, oldElse, newElse);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setElse(Command newElse) {
if (newElse != else_) {
NotificationChain msgs = null;
if (else_ != null)
msgs = ((InternalEObject)else_).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CorePackage.IF__ELSE, null, msgs);
if (newElse != null)
msgs = ((InternalEObject)newElse).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CorePackage.IF__ELSE, null, msgs);
msgs = basicSetElse(newElse, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, CorePackage.IF__ELSE, newElse, newElse));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case CorePackage.IF__THEN:
return basicSetThen(null, msgs);
case CorePackage.IF__ELSE:
return basicSetElse(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 CorePackage.IF__CONDITION:
if (resolve) return getCondition();
return basicGetCondition();
case CorePackage.IF__THEN:
return getThen();
case CorePackage.IF__ELSE:
return getElse();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case CorePackage.IF__CONDITION:
setCondition((EObject)newValue);
return;
case CorePackage.IF__THEN:
setThen((Command)newValue);
return;
case CorePackage.IF__ELSE:
setElse((Command)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case CorePackage.IF__CONDITION:
setCondition((EObject)null);
return;
case CorePackage.IF__THEN:
setThen((Command)null);
return;
case CorePackage.IF__ELSE:
setElse((Command)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case CorePackage.IF__CONDITION:
return condition != null;
case CorePackage.IF__THEN:
return then != null;
case CorePackage.IF__ELSE:
return else_ != null;
}
return super.eIsSet(featureID);
}
} //IfImpl