/**
*/
package no.hal.jex.jextest.jexTest.impl;
import java.util.Collection;
import no.hal.jex.jextest.jexTest.JexTestPackage;
import no.hal.jex.jextest.jexTest.Method;
import no.hal.jex.jextest.jexTest.Parameter;
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.impl.MinimalEObjectImpl;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.xtext.common.types.JvmTypeReference;
import org.eclipse.xtext.xbase.XExpression;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Method</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link no.hal.jex.jextest.jexTest.impl.MethodImpl#isStatic <em>Static</em>}</li>
* <li>{@link no.hal.jex.jextest.jexTest.impl.MethodImpl#getReturnType <em>Return Type</em>}</li>
* <li>{@link no.hal.jex.jextest.jexTest.impl.MethodImpl#getName <em>Name</em>}</li>
* <li>{@link no.hal.jex.jextest.jexTest.impl.MethodImpl#getParameters <em>Parameters</em>}</li>
* <li>{@link no.hal.jex.jextest.jexTest.impl.MethodImpl#getBody <em>Body</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class MethodImpl extends MinimalEObjectImpl.Container implements Method
{
/**
* The default value of the '{@link #isStatic() <em>Static</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #isStatic()
* @generated
* @ordered
*/
protected static final boolean STATIC_EDEFAULT = false;
/**
* The cached value of the '{@link #isStatic() <em>Static</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #isStatic()
* @generated
* @ordered
*/
protected boolean static_ = STATIC_EDEFAULT;
/**
* The cached value of the '{@link #getReturnType() <em>Return Type</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getReturnType()
* @generated
* @ordered
*/
protected JvmTypeReference returnType;
/**
* The default value of the '{@link #getName() <em>Name</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getName()
* @generated
* @ordered
*/
protected static final String NAME_EDEFAULT = null;
/**
* The cached value of the '{@link #getName() <em>Name</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getName()
* @generated
* @ordered
*/
protected String name = NAME_EDEFAULT;
/**
* The cached value of the '{@link #getParameters() <em>Parameters</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getParameters()
* @generated
* @ordered
*/
protected EList<Parameter> parameters;
/**
* The cached value of the '{@link #getBody() <em>Body</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getBody()
* @generated
* @ordered
*/
protected XExpression body;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected MethodImpl()
{
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass()
{
return JexTestPackage.Literals.METHOD;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public boolean isStatic()
{
return static_;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setStatic(boolean newStatic)
{
boolean oldStatic = static_;
static_ = newStatic;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, JexTestPackage.METHOD__STATIC, oldStatic, static_));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public JvmTypeReference getReturnType()
{
return returnType;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetReturnType(JvmTypeReference newReturnType, NotificationChain msgs)
{
JvmTypeReference oldReturnType = returnType;
returnType = newReturnType;
if (eNotificationRequired())
{
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, JexTestPackage.METHOD__RETURN_TYPE, oldReturnType, newReturnType);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setReturnType(JvmTypeReference newReturnType)
{
if (newReturnType != returnType)
{
NotificationChain msgs = null;
if (returnType != null)
msgs = ((InternalEObject)returnType).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - JexTestPackage.METHOD__RETURN_TYPE, null, msgs);
if (newReturnType != null)
msgs = ((InternalEObject)newReturnType).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - JexTestPackage.METHOD__RETURN_TYPE, null, msgs);
msgs = basicSetReturnType(newReturnType, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, JexTestPackage.METHOD__RETURN_TYPE, newReturnType, newReturnType));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getName()
{
return name;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setName(String newName)
{
String oldName = name;
name = newName;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, JexTestPackage.METHOD__NAME, oldName, name));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<Parameter> getParameters()
{
if (parameters == null)
{
parameters = new EObjectContainmentEList<Parameter>(Parameter.class, this, JexTestPackage.METHOD__PARAMETERS);
}
return parameters;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public XExpression getBody()
{
return body;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetBody(XExpression newBody, NotificationChain msgs)
{
XExpression oldBody = body;
body = newBody;
if (eNotificationRequired())
{
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, JexTestPackage.METHOD__BODY, oldBody, newBody);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setBody(XExpression newBody)
{
if (newBody != body)
{
NotificationChain msgs = null;
if (body != null)
msgs = ((InternalEObject)body).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - JexTestPackage.METHOD__BODY, null, msgs);
if (newBody != null)
msgs = ((InternalEObject)newBody).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - JexTestPackage.METHOD__BODY, null, msgs);
msgs = basicSetBody(newBody, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, JexTestPackage.METHOD__BODY, newBody, newBody));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
{
switch (featureID)
{
case JexTestPackage.METHOD__RETURN_TYPE:
return basicSetReturnType(null, msgs);
case JexTestPackage.METHOD__PARAMETERS:
return ((InternalEList<?>)getParameters()).basicRemove(otherEnd, msgs);
case JexTestPackage.METHOD__BODY:
return basicSetBody(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 JexTestPackage.METHOD__STATIC:
return isStatic();
case JexTestPackage.METHOD__RETURN_TYPE:
return getReturnType();
case JexTestPackage.METHOD__NAME:
return getName();
case JexTestPackage.METHOD__PARAMETERS:
return getParameters();
case JexTestPackage.METHOD__BODY:
return getBody();
}
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 JexTestPackage.METHOD__STATIC:
setStatic((Boolean)newValue);
return;
case JexTestPackage.METHOD__RETURN_TYPE:
setReturnType((JvmTypeReference)newValue);
return;
case JexTestPackage.METHOD__NAME:
setName((String)newValue);
return;
case JexTestPackage.METHOD__PARAMETERS:
getParameters().clear();
getParameters().addAll((Collection<? extends Parameter>)newValue);
return;
case JexTestPackage.METHOD__BODY:
setBody((XExpression)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID)
{
switch (featureID)
{
case JexTestPackage.METHOD__STATIC:
setStatic(STATIC_EDEFAULT);
return;
case JexTestPackage.METHOD__RETURN_TYPE:
setReturnType((JvmTypeReference)null);
return;
case JexTestPackage.METHOD__NAME:
setName(NAME_EDEFAULT);
return;
case JexTestPackage.METHOD__PARAMETERS:
getParameters().clear();
return;
case JexTestPackage.METHOD__BODY:
setBody((XExpression)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID)
{
switch (featureID)
{
case JexTestPackage.METHOD__STATIC:
return static_ != STATIC_EDEFAULT;
case JexTestPackage.METHOD__RETURN_TYPE:
return returnType != null;
case JexTestPackage.METHOD__NAME:
return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
case JexTestPackage.METHOD__PARAMETERS:
return parameters != null && !parameters.isEmpty();
case JexTestPackage.METHOD__BODY:
return body != null;
}
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(" (static: ");
result.append(static_);
result.append(", name: ");
result.append(name);
result.append(')');
return result.toString();
}
} //MethodImpl