/** | |
* ******************************************************************************* | |
* Copyright (c) 2009 Mia-Software. | |
* 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: | |
* | |
* Sebastien Minguet (Mia-Software) - initial API and implementation | |
* Frederic Madiot (Mia-Software) - initial API and implementation | |
* Fabien Giquel (Mia-Software) - initial API and implementation | |
* Gabriel Barbier (Mia-Software) - initial API and implementation | |
* Erwan Breton (Sodifrance) - initial API and implementation | |
* Romain Dervaux (Mia-Software) - initial API and implementation | |
* ******************************************************************************* | |
* | |
* $Id$ | |
*/ | |
package org.eclipse.modisco.java.emf.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.modisco.java.Expression; | |
import org.eclipse.modisco.java.InfixExpression; | |
import org.eclipse.modisco.java.InfixExpressionKind; | |
import org.eclipse.modisco.java.emf.JavaPackage; | |
/** | |
* <!-- begin-user-doc --> | |
* An implementation of the model object '<em><b>Infix Expression</b></em>'. | |
* <!-- end-user-doc --> | |
* <p> | |
* The following features are implemented: | |
* <ul> | |
* <li>{@link org.eclipse.modisco.java.emf.impl.InfixExpressionImpl#getOperator <em>Operator</em>}</li> | |
* <li>{@link org.eclipse.modisco.java.emf.impl.InfixExpressionImpl#getRightOperand <em>Right Operand</em>}</li> | |
* <li>{@link org.eclipse.modisco.java.emf.impl.InfixExpressionImpl#getLeftOperand <em>Left Operand</em>}</li> | |
* <li>{@link org.eclipse.modisco.java.emf.impl.InfixExpressionImpl#getExtendedOperands <em>Extended Operands</em>}</li> | |
* </ul> | |
* </p> | |
* | |
* @generated | |
*/ | |
public class InfixExpressionImpl extends ExpressionImpl implements InfixExpression { | |
/** | |
* The default value of the '{@link #getOperator() <em>Operator</em>}' attribute. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getOperator() | |
* @generated | |
* @ordered | |
*/ | |
protected static final InfixExpressionKind OPERATOR_EDEFAULT = InfixExpressionKind.TIMES; | |
/** | |
* The cached value of the '{@link #getOperator() <em>Operator</em>}' attribute. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getOperator() | |
* @generated | |
* @ordered | |
*/ | |
protected InfixExpressionKind operator = OPERATOR_EDEFAULT; | |
/** | |
* The cached value of the '{@link #getRightOperand() <em>Right Operand</em>}' containment reference. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getRightOperand() | |
* @generated | |
* @ordered | |
*/ | |
protected Expression rightOperand; | |
/** | |
* The cached value of the '{@link #getLeftOperand() <em>Left Operand</em>}' containment reference. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getLeftOperand() | |
* @generated | |
* @ordered | |
*/ | |
protected Expression leftOperand; | |
/** | |
* The cached value of the '{@link #getExtendedOperands() <em>Extended Operands</em>}' containment reference list. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getExtendedOperands() | |
* @generated | |
* @ordered | |
*/ | |
protected EList<Expression> extendedOperands; | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
protected InfixExpressionImpl() { | |
super(); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
protected EClass eStaticClass() { | |
return JavaPackage.eINSTANCE.getInfixExpression(); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public InfixExpressionKind getOperator() { | |
return operator; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public void setOperator(InfixExpressionKind newOperator) { | |
InfixExpressionKind oldOperator = operator; | |
operator = newOperator == null ? OPERATOR_EDEFAULT : newOperator; | |
if (eNotificationRequired()) | |
eNotify(new ENotificationImpl(this, Notification.SET, JavaPackage.INFIX_EXPRESSION__OPERATOR, oldOperator, operator)); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public Expression getRightOperand() { | |
return rightOperand; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public NotificationChain basicSetRightOperand(Expression newRightOperand, NotificationChain msgs) { | |
Expression oldRightOperand = rightOperand; | |
rightOperand = newRightOperand; | |
if (eNotificationRequired()) { | |
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, JavaPackage.INFIX_EXPRESSION__RIGHT_OPERAND, oldRightOperand, newRightOperand); | |
if (msgs == null) msgs = notification; else msgs.add(notification); | |
} | |
return msgs; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public void setRightOperand(Expression newRightOperand) { | |
if (newRightOperand != rightOperand) { | |
NotificationChain msgs = null; | |
if (rightOperand != null) | |
msgs = ((InternalEObject)rightOperand).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - JavaPackage.INFIX_EXPRESSION__RIGHT_OPERAND, null, msgs); | |
if (newRightOperand != null) | |
msgs = ((InternalEObject)newRightOperand).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - JavaPackage.INFIX_EXPRESSION__RIGHT_OPERAND, null, msgs); | |
msgs = basicSetRightOperand(newRightOperand, msgs); | |
if (msgs != null) msgs.dispatch(); | |
} | |
else if (eNotificationRequired()) | |
eNotify(new ENotificationImpl(this, Notification.SET, JavaPackage.INFIX_EXPRESSION__RIGHT_OPERAND, newRightOperand, newRightOperand)); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public Expression getLeftOperand() { | |
return leftOperand; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public NotificationChain basicSetLeftOperand(Expression newLeftOperand, NotificationChain msgs) { | |
Expression oldLeftOperand = leftOperand; | |
leftOperand = newLeftOperand; | |
if (eNotificationRequired()) { | |
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, JavaPackage.INFIX_EXPRESSION__LEFT_OPERAND, oldLeftOperand, newLeftOperand); | |
if (msgs == null) msgs = notification; else msgs.add(notification); | |
} | |
return msgs; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public void setLeftOperand(Expression newLeftOperand) { | |
if (newLeftOperand != leftOperand) { | |
NotificationChain msgs = null; | |
if (leftOperand != null) | |
msgs = ((InternalEObject)leftOperand).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - JavaPackage.INFIX_EXPRESSION__LEFT_OPERAND, null, msgs); | |
if (newLeftOperand != null) | |
msgs = ((InternalEObject)newLeftOperand).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - JavaPackage.INFIX_EXPRESSION__LEFT_OPERAND, null, msgs); | |
msgs = basicSetLeftOperand(newLeftOperand, msgs); | |
if (msgs != null) msgs.dispatch(); | |
} | |
else if (eNotificationRequired()) | |
eNotify(new ENotificationImpl(this, Notification.SET, JavaPackage.INFIX_EXPRESSION__LEFT_OPERAND, newLeftOperand, newLeftOperand)); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public EList<Expression> getExtendedOperands() { | |
if (extendedOperands == null) { | |
extendedOperands = new EObjectContainmentEList<Expression>(Expression.class, this, JavaPackage.INFIX_EXPRESSION__EXTENDED_OPERANDS); | |
} | |
return extendedOperands; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { | |
switch (featureID) { | |
case JavaPackage.INFIX_EXPRESSION__RIGHT_OPERAND: | |
return basicSetRightOperand(null, msgs); | |
case JavaPackage.INFIX_EXPRESSION__LEFT_OPERAND: | |
return basicSetLeftOperand(null, msgs); | |
case JavaPackage.INFIX_EXPRESSION__EXTENDED_OPERANDS: | |
return ((InternalEList<?>)getExtendedOperands()).basicRemove(otherEnd, 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 JavaPackage.INFIX_EXPRESSION__OPERATOR: | |
return getOperator(); | |
case JavaPackage.INFIX_EXPRESSION__RIGHT_OPERAND: | |
return getRightOperand(); | |
case JavaPackage.INFIX_EXPRESSION__LEFT_OPERAND: | |
return getLeftOperand(); | |
case JavaPackage.INFIX_EXPRESSION__EXTENDED_OPERANDS: | |
return getExtendedOperands(); | |
} | |
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 JavaPackage.INFIX_EXPRESSION__OPERATOR: | |
setOperator((InfixExpressionKind)newValue); | |
return; | |
case JavaPackage.INFIX_EXPRESSION__RIGHT_OPERAND: | |
setRightOperand((Expression)newValue); | |
return; | |
case JavaPackage.INFIX_EXPRESSION__LEFT_OPERAND: | |
setLeftOperand((Expression)newValue); | |
return; | |
case JavaPackage.INFIX_EXPRESSION__EXTENDED_OPERANDS: | |
getExtendedOperands().clear(); | |
getExtendedOperands().addAll((Collection<? extends Expression>)newValue); | |
return; | |
} | |
super.eSet(featureID, newValue); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public void eUnset(int featureID) { | |
switch (featureID) { | |
case JavaPackage.INFIX_EXPRESSION__OPERATOR: | |
setOperator(OPERATOR_EDEFAULT); | |
return; | |
case JavaPackage.INFIX_EXPRESSION__RIGHT_OPERAND: | |
setRightOperand((Expression)null); | |
return; | |
case JavaPackage.INFIX_EXPRESSION__LEFT_OPERAND: | |
setLeftOperand((Expression)null); | |
return; | |
case JavaPackage.INFIX_EXPRESSION__EXTENDED_OPERANDS: | |
getExtendedOperands().clear(); | |
return; | |
} | |
super.eUnset(featureID); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public boolean eIsSet(int featureID) { | |
switch (featureID) { | |
case JavaPackage.INFIX_EXPRESSION__OPERATOR: | |
return operator != OPERATOR_EDEFAULT; | |
case JavaPackage.INFIX_EXPRESSION__RIGHT_OPERAND: | |
return rightOperand != null; | |
case JavaPackage.INFIX_EXPRESSION__LEFT_OPERAND: | |
return leftOperand != null; | |
case JavaPackage.INFIX_EXPRESSION__EXTENDED_OPERANDS: | |
return extendedOperands != null && !extendedOperands.isEmpty(); | |
} | |
return super.eIsSet(featureID); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public String toString() { | |
if (eIsProxy()) return super.toString(); | |
StringBuffer result = new StringBuffer(super.toString()); | |
result.append(" (operator: "); //$NON-NLS-1$ | |
result.append(operator); | |
result.append(')'); | |
return result.toString(); | |
} | |
} //InfixExpressionImpl |