blob: 620adaa7c6452200db30ac957d863dd1d4098c47 [file] [log] [blame]
/**
* Copyright (c) 2020 CEA LIST.
*
* 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\n\nContributors:
* Arnault Lapitre (CEA LIST) arnault.lapitre@cea.fr
* - Initial API and Implementation
*/
package org.eclipse.efm.ecore.formalml.statement.impl;
import java.util.Collection;
import org.eclipse.efm.ecore.formalml.statement.BlockStatement;
import org.eclipse.efm.ecore.formalml.statement.ConditionalBlockStatement;
import org.eclipse.efm.ecore.formalml.statement.IfStatement;
import org.eclipse.efm.ecore.formalml.statement.StatementPackage;
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;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>If Statement</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.efm.ecore.formalml.statement.impl.IfStatementImpl#getElseifStatement <em>Elseif Statement</em>}</li>
* <li>{@link org.eclipse.efm.ecore.formalml.statement.impl.IfStatementImpl#getElseBlock <em>Else Block</em>}</li>
* </ul>
*
* @generated
*/
public class IfStatementImpl extends ConditionalBlockStatementImpl implements IfStatement {
/**
* The cached value of the '{@link #getElseifStatement() <em>Elseif Statement</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getElseifStatement()
* @generated
* @ordered
*/
protected EList<ConditionalBlockStatement> elseifStatement;
/**
* The cached value of the '{@link #getElseBlock() <em>Else Block</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getElseBlock()
* @generated
* @ordered
*/
protected BlockStatement elseBlock;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected IfStatementImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return StatementPackage.Literals.IF_STATEMENT;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public EList<ConditionalBlockStatement> getElseifStatement() {
if (elseifStatement == null) {
elseifStatement = new EObjectContainmentEList<ConditionalBlockStatement>(ConditionalBlockStatement.class, this, StatementPackage.IF_STATEMENT__ELSEIF_STATEMENT);
}
return elseifStatement;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public BlockStatement getElseBlock() {
return elseBlock;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetElseBlock(BlockStatement newElseBlock, NotificationChain msgs) {
BlockStatement oldElseBlock = elseBlock;
elseBlock = newElseBlock;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, StatementPackage.IF_STATEMENT__ELSE_BLOCK, oldElseBlock, newElseBlock);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setElseBlock(BlockStatement newElseBlock) {
if (newElseBlock != elseBlock) {
NotificationChain msgs = null;
if (elseBlock != null)
msgs = ((InternalEObject)elseBlock).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - StatementPackage.IF_STATEMENT__ELSE_BLOCK, null, msgs);
if (newElseBlock != null)
msgs = ((InternalEObject)newElseBlock).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - StatementPackage.IF_STATEMENT__ELSE_BLOCK, null, msgs);
msgs = basicSetElseBlock(newElseBlock, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, StatementPackage.IF_STATEMENT__ELSE_BLOCK, newElseBlock, newElseBlock));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case StatementPackage.IF_STATEMENT__ELSEIF_STATEMENT:
return ((InternalEList<?>)getElseifStatement()).basicRemove(otherEnd, msgs);
case StatementPackage.IF_STATEMENT__ELSE_BLOCK:
return basicSetElseBlock(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 StatementPackage.IF_STATEMENT__ELSEIF_STATEMENT:
return getElseifStatement();
case StatementPackage.IF_STATEMENT__ELSE_BLOCK:
return getElseBlock();
}
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 StatementPackage.IF_STATEMENT__ELSEIF_STATEMENT:
getElseifStatement().clear();
getElseifStatement().addAll((Collection<? extends ConditionalBlockStatement>)newValue);
return;
case StatementPackage.IF_STATEMENT__ELSE_BLOCK:
setElseBlock((BlockStatement)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case StatementPackage.IF_STATEMENT__ELSEIF_STATEMENT:
getElseifStatement().clear();
return;
case StatementPackage.IF_STATEMENT__ELSE_BLOCK:
setElseBlock((BlockStatement)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case StatementPackage.IF_STATEMENT__ELSEIF_STATEMENT:
return elseifStatement != null && !elseifStatement.isEmpty();
case StatementPackage.IF_STATEMENT__ELSE_BLOCK:
return elseBlock != null;
}
return super.eIsSet(featureID);
}
} //IfStatementImpl