/**
*/
package org.example.smalljava.smallJava.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.example.smalljava.smallJava.SJMethod;
import org.example.smalljava.smallJava.SJMethodBody;
import org.example.smalljava.smallJava.SJParameter;
import org.example.smalljava.smallJava.SmallJavaPackage;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>SJ Method</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.example.smalljava.smallJava.impl.SJMethodImpl#getParams <em>Params</em>}</li>
* <li>{@link org.example.smalljava.smallJava.impl.SJMethodImpl#getBody <em>Body</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class SJMethodImpl extends SJMemberImpl implements SJMethod
{
/**
* The cached value of the '{@link #getParams() <em>Params</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getParams()
* @generated
* @ordered
*/
protected EList<SJParameter> params;
/**
* The cached value of the '{@link #getBody() <em>Body</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getBody()
* @generated
* @ordered
*/
protected SJMethodBody body;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected SJMethodImpl()
{
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass()
{
return SmallJavaPackage.Literals.SJ_METHOD;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<SJParameter> getParams()
{
if (params == null)
{
params = new EObjectContainmentEList<SJParameter>(SJParameter.class, this, SmallJavaPackage.SJ_METHOD__PARAMS);
}
return params;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public SJMethodBody getBody()
{
return body;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetBody(SJMethodBody newBody, NotificationChain msgs)
{
SJMethodBody oldBody = body;
body = newBody;
if (eNotificationRequired())
{
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SmallJavaPackage.SJ_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(SJMethodBody newBody)
{
if (newBody != body)
{
NotificationChain msgs = null;
if (body != null)
msgs = ((InternalEObject)body).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - SmallJavaPackage.SJ_METHOD__BODY, null, msgs);
if (newBody != null)
msgs = ((InternalEObject)newBody).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - SmallJavaPackage.SJ_METHOD__BODY, null, msgs);
msgs = basicSetBody(newBody, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, SmallJavaPackage.SJ_METHOD__BODY, newBody, newBody));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
{
switch (featureID)
{
case SmallJavaPackage.SJ_METHOD__PARAMS:
return ((InternalEList<?>)getParams()).basicRemove(otherEnd, msgs);
case SmallJavaPackage.SJ_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 SmallJavaPackage.SJ_METHOD__PARAMS:
return getParams();
case SmallJavaPackage.SJ_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 SmallJavaPackage.SJ_METHOD__PARAMS:
getParams().clear();
getParams().addAll((Collection<? extends SJParameter>)newValue);
return;
case SmallJavaPackage.SJ_METHOD__BODY:
setBody((SJMethodBody)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID)
{
switch (featureID)
{
case SmallJavaPackage.SJ_METHOD__PARAMS:
getParams().clear();
return;
case SmallJavaPackage.SJ_METHOD__BODY:
setBody((SJMethodBody)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID)
{
switch (featureID)
{
case SmallJavaPackage.SJ_METHOD__PARAMS:
return params != null && !params.isEmpty();
case SmallJavaPackage.SJ_METHOD__BODY:
return body != null;
}
return super.eIsSet(featureID);
}
} //SJMethodImpl