blob: 642790c65139af7d1b3a6cb404cb08cf69e4190c [file] [log] [blame]
/**
* Copyright (c) 2016 Willink Transformations, Univesity 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:
* Adolfo Sanchez-Barbudo Herrera - initial API and implementation
*/
package delphi.impl;
import delphi.DelphiPackage;
import delphi.expression;
import delphi.ifStmt;
import delphi.statement;
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;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>if Stmt</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link delphi.impl.ifStmtImpl#getCondition <em>Condition</em>}</li>
* <li>{@link delphi.impl.ifStmtImpl#getThen <em>Then</em>}</li>
* <li>{@link delphi.impl.ifStmtImpl#getElse <em>Else</em>}</li>
* </ul>
*
* @generated
*/
public class ifStmtImpl extends conditionalStmtImpl implements ifStmt {
/**
* The cached value of the '{@link #getCondition() <em>Condition</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getCondition()
* @generated
* @ordered
*/
protected expression condition;
/**
* The cached value of the '{@link #getThen() <em>Then</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getThen()
* @generated
* @ordered
*/
protected statement then;
/**
* The cached value of the '{@link #getElse() <em>Else</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getElse()
* @generated
* @ordered
*/
protected statement else_;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected ifStmtImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return DelphiPackage.Literals.IF_STMT;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public expression getCondition() {
return condition;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetCondition(expression newCondition, NotificationChain msgs) {
expression oldCondition = condition;
condition = newCondition;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, DelphiPackage.IF_STMT__CONDITION, oldCondition, newCondition);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setCondition(expression newCondition) {
if (newCondition != condition) {
NotificationChain msgs = null;
if (condition != null)
msgs = ((InternalEObject)condition).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - DelphiPackage.IF_STMT__CONDITION, null, msgs);
if (newCondition != null)
msgs = ((InternalEObject)newCondition).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - DelphiPackage.IF_STMT__CONDITION, null, msgs);
msgs = basicSetCondition(newCondition, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, DelphiPackage.IF_STMT__CONDITION, newCondition, newCondition));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public statement getThen() {
return then;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetThen(statement newThen, NotificationChain msgs) {
statement oldThen = then;
then = newThen;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, DelphiPackage.IF_STMT__THEN, oldThen, newThen);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setThen(statement newThen) {
if (newThen != then) {
NotificationChain msgs = null;
if (then != null)
msgs = ((InternalEObject)then).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - DelphiPackage.IF_STMT__THEN, null, msgs);
if (newThen != null)
msgs = ((InternalEObject)newThen).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - DelphiPackage.IF_STMT__THEN, null, msgs);
msgs = basicSetThen(newThen, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, DelphiPackage.IF_STMT__THEN, newThen, newThen));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public statement getElse() {
return else_;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetElse(statement newElse, NotificationChain msgs) {
statement oldElse = else_;
else_ = newElse;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, DelphiPackage.IF_STMT__ELSE, oldElse, newElse);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setElse(statement newElse) {
if (newElse != else_) {
NotificationChain msgs = null;
if (else_ != null)
msgs = ((InternalEObject)else_).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - DelphiPackage.IF_STMT__ELSE, null, msgs);
if (newElse != null)
msgs = ((InternalEObject)newElse).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - DelphiPackage.IF_STMT__ELSE, null, msgs);
msgs = basicSetElse(newElse, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, DelphiPackage.IF_STMT__ELSE, newElse, newElse));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case DelphiPackage.IF_STMT__CONDITION:
return basicSetCondition(null, msgs);
case DelphiPackage.IF_STMT__THEN:
return basicSetThen(null, msgs);
case DelphiPackage.IF_STMT__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 DelphiPackage.IF_STMT__CONDITION:
return getCondition();
case DelphiPackage.IF_STMT__THEN:
return getThen();
case DelphiPackage.IF_STMT__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 DelphiPackage.IF_STMT__CONDITION:
setCondition((expression)newValue);
return;
case DelphiPackage.IF_STMT__THEN:
setThen((statement)newValue);
return;
case DelphiPackage.IF_STMT__ELSE:
setElse((statement)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case DelphiPackage.IF_STMT__CONDITION:
setCondition((expression)null);
return;
case DelphiPackage.IF_STMT__THEN:
setThen((statement)null);
return;
case DelphiPackage.IF_STMT__ELSE:
setElse((statement)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case DelphiPackage.IF_STMT__CONDITION:
return condition != null;
case DelphiPackage.IF_STMT__THEN:
return then != null;
case DelphiPackage.IF_STMT__ELSE:
return else_ != null;
}
return super.eIsSet(featureID);
}
} //ifStmtImpl