/**
* Copyright (c) 2012 BMW Car IT 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
*/
package org.jnario.spec.spec.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.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.xtext.xbase.XExpression;
import org.jnario.spec.spec.Example;
import org.jnario.spec.spec.SpecPackage;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Example</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.jnario.spec.spec.impl.ExampleImpl#getExpr <em>Expr</em>}</li>
* <li>{@link org.jnario.spec.spec.impl.ExampleImpl#isPending <em>Pending</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class ExampleImpl extends TestFunctionImplCustom implements Example
{
/**
* The cached value of the '{@link #getExpr() <em>Expr</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getExpr()
* @generated
* @ordered
*/
protected XExpression expr;
/**
* The default value of the '{@link #isPending() <em>Pending</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #isPending()
* @generated
* @ordered
*/
protected static final boolean PENDING_EDEFAULT = false;
/**
* The cached value of the '{@link #isPending() <em>Pending</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #isPending()
* @generated
* @ordered
*/
protected boolean pending = PENDING_EDEFAULT;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected ExampleImpl()
{
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass()
{
return SpecPackage.Literals.EXAMPLE;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public XExpression getExpr()
{
return expr;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetExpr(XExpression newExpr, NotificationChain msgs)
{
XExpression oldExpr = expr;
expr = newExpr;
if (eNotificationRequired())
{
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SpecPackage.EXAMPLE__EXPR, oldExpr, newExpr);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setExpr(XExpression newExpr)
{
if (newExpr != expr)
{
NotificationChain msgs = null;
if (expr != null)
msgs = ((InternalEObject)expr).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - SpecPackage.EXAMPLE__EXPR, null, msgs);
if (newExpr != null)
msgs = ((InternalEObject)newExpr).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - SpecPackage.EXAMPLE__EXPR, null, msgs);
msgs = basicSetExpr(newExpr, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, SpecPackage.EXAMPLE__EXPR, newExpr, newExpr));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public boolean isPending()
{
return pending;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setPending(boolean newPending)
{
boolean oldPending = pending;
pending = newPending;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, SpecPackage.EXAMPLE__PENDING, oldPending, pending));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
{
switch (featureID)
{
case SpecPackage.EXAMPLE__EXPR:
return basicSetExpr(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 SpecPackage.EXAMPLE__EXPR:
return getExpr();
case SpecPackage.EXAMPLE__PENDING:
return isPending();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue)
{
switch (featureID)
{
case SpecPackage.EXAMPLE__EXPR:
setExpr((XExpression)newValue);
return;
case SpecPackage.EXAMPLE__PENDING:
setPending((Boolean)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID)
{
switch (featureID)
{
case SpecPackage.EXAMPLE__EXPR:
setExpr((XExpression)null);
return;
case SpecPackage.EXAMPLE__PENDING:
setPending(PENDING_EDEFAULT);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID)
{
switch (featureID)
{
case SpecPackage.EXAMPLE__EXPR:
return expr != null;
case SpecPackage.EXAMPLE__PENDING:
return pending != PENDING_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(" (pending: ");
result.append(pending);
result.append(')');
return result.toString();
}
} //ExampleImpl