/**
* <copyright>
* </copyright>
*
* $Id: UnaryExpressionImpl.java,v 1.3 2011/04/18 08:29:42 apanchenk Exp $
*/
package org.eclipse.dltk.javascript.core.dom.impl;
import org.eclipse.dltk.javascript.core.dom.DomPackage;
import org.eclipse.dltk.javascript.core.dom.Expression;
import org.eclipse.dltk.javascript.core.dom.UnaryExpression;
import org.eclipse.dltk.javascript.core.dom.UnaryOperator;
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>Unary Expression</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.dltk.javascript.core.dom.impl.UnaryExpressionImpl#getArgument <em>Argument</em>}</li>
* <li>{@link org.eclipse.dltk.javascript.core.dom.impl.UnaryExpressionImpl#getOperation <em>Operation</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class UnaryExpressionImpl extends ExpressionImpl implements UnaryExpression {
/**
* The cached value of the '{@link #getArgument() <em>Argument</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getArgument()
* @generated
* @ordered
*/
protected Expression argument;
/**
* The default value of the '{@link #getOperation() <em>Operation</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getOperation()
* @generated
* @ordered
*/
protected static final UnaryOperator OPERATION_EDEFAULT = UnaryOperator.POSTFIX_INC;
/**
* The cached value of the '{@link #getOperation() <em>Operation</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getOperation()
* @generated
* @ordered
*/
protected UnaryOperator operation = OPERATION_EDEFAULT;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected UnaryExpressionImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return DomPackage.Literals.UNARY_EXPRESSION;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Expression getArgument() {
return argument;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetArgument(Expression newArgument, NotificationChain msgs) {
Expression oldArgument = argument;
argument = newArgument;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, DomPackage.UNARY_EXPRESSION__ARGUMENT, oldArgument, newArgument);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setArgument(Expression newArgument) {
if (newArgument != argument) {
NotificationChain msgs = null;
if (argument != null)
msgs = ((InternalEObject)argument).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - DomPackage.UNARY_EXPRESSION__ARGUMENT, null, msgs);
if (newArgument != null)
msgs = ((InternalEObject)newArgument).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - DomPackage.UNARY_EXPRESSION__ARGUMENT, null, msgs);
msgs = basicSetArgument(newArgument, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, DomPackage.UNARY_EXPRESSION__ARGUMENT, newArgument, newArgument));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public UnaryOperator getOperation() {
return operation;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setOperation(UnaryOperator newOperation) {
UnaryOperator oldOperation = operation;
operation = newOperation == null ? OPERATION_EDEFAULT : newOperation;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, DomPackage.UNARY_EXPRESSION__OPERATION, oldOperation, operation));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case DomPackage.UNARY_EXPRESSION__ARGUMENT:
return basicSetArgument(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 DomPackage.UNARY_EXPRESSION__ARGUMENT:
return getArgument();
case DomPackage.UNARY_EXPRESSION__OPERATION:
return getOperation();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case DomPackage.UNARY_EXPRESSION__ARGUMENT:
setArgument((Expression)newValue);
return;
case DomPackage.UNARY_EXPRESSION__OPERATION:
setOperation((UnaryOperator)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case DomPackage.UNARY_EXPRESSION__ARGUMENT:
setArgument((Expression)null);
return;
case DomPackage.UNARY_EXPRESSION__OPERATION:
setOperation(OPERATION_EDEFAULT);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case DomPackage.UNARY_EXPRESSION__ARGUMENT:
return argument != null;
case DomPackage.UNARY_EXPRESSION__OPERATION:
return operation != OPERATION_EDEFAULT;
}
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(" (operation: ");
result.append(operation);
result.append(')');
return result.toString();
}
} //UnaryExpressionImpl