/**
* generated by Xtext 2.21.0
*/
package org.eclipse.viatra.solver.language.solverLanguage.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.viatra.solver.language.solverLanguage.Expression;
import org.eclipse.viatra.solver.language.solverLanguage.MetricDefinition;
import org.eclipse.viatra.solver.language.solverLanguage.MetricType;
import org.eclipse.viatra.solver.language.solverLanguage.SolverLanguagePackage;
/**
*
* An implementation of the model object 'Metric Definition'.
*
*
* The following features are implemented:
*
*
* - {@link org.eclipse.viatra.solver.language.solverLanguage.impl.MetricDefinitionImpl#getHead Head}
* - {@link org.eclipse.viatra.solver.language.solverLanguage.impl.MetricDefinitionImpl#getBody Body}
* - {@link org.eclipse.viatra.solver.language.solverLanguage.impl.MetricDefinitionImpl#getType Type}
*
*
* @generated
*/
public class MetricDefinitionImpl extends StatementImpl implements MetricDefinition
{
/**
* The cached value of the '{@link #getHead() Head}' containment reference.
*
*
* @see #getHead()
* @generated
* @ordered
*/
protected Expression head;
/**
* The cached value of the '{@link #getBody() Body}' containment reference.
*
*
* @see #getBody()
* @generated
* @ordered
*/
protected Expression body;
/**
* The default value of the '{@link #getType() Type}' attribute.
*
*
* @see #getType()
* @generated
* @ordered
*/
protected static final MetricType TYPE_EDEFAULT = MetricType.INT;
/**
* The cached value of the '{@link #getType() Type}' attribute.
*
*
* @see #getType()
* @generated
* @ordered
*/
protected MetricType type = TYPE_EDEFAULT;
/**
*
*
* @generated
*/
protected MetricDefinitionImpl()
{
super();
}
/**
*
*
* @generated
*/
@Override
protected EClass eStaticClass()
{
return SolverLanguagePackage.Literals.METRIC_DEFINITION;
}
/**
*
*
* @generated
*/
@Override
public Expression getHead()
{
return head;
}
/**
*
*
* @generated
*/
public NotificationChain basicSetHead(Expression newHead, NotificationChain msgs)
{
Expression oldHead = head;
head = newHead;
if (eNotificationRequired())
{
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SolverLanguagePackage.METRIC_DEFINITION__HEAD, oldHead, newHead);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
*
*
* @generated
*/
@Override
public void setHead(Expression newHead)
{
if (newHead != head)
{
NotificationChain msgs = null;
if (head != null)
msgs = ((InternalEObject)head).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - SolverLanguagePackage.METRIC_DEFINITION__HEAD, null, msgs);
if (newHead != null)
msgs = ((InternalEObject)newHead).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - SolverLanguagePackage.METRIC_DEFINITION__HEAD, null, msgs);
msgs = basicSetHead(newHead, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, SolverLanguagePackage.METRIC_DEFINITION__HEAD, newHead, newHead));
}
/**
*
*
* @generated
*/
@Override
public Expression getBody()
{
return body;
}
/**
*
*
* @generated
*/
public NotificationChain basicSetBody(Expression newBody, NotificationChain msgs)
{
Expression oldBody = body;
body = newBody;
if (eNotificationRequired())
{
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SolverLanguagePackage.METRIC_DEFINITION__BODY, oldBody, newBody);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
*
*
* @generated
*/
@Override
public void setBody(Expression newBody)
{
if (newBody != body)
{
NotificationChain msgs = null;
if (body != null)
msgs = ((InternalEObject)body).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - SolverLanguagePackage.METRIC_DEFINITION__BODY, null, msgs);
if (newBody != null)
msgs = ((InternalEObject)newBody).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - SolverLanguagePackage.METRIC_DEFINITION__BODY, null, msgs);
msgs = basicSetBody(newBody, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, SolverLanguagePackage.METRIC_DEFINITION__BODY, newBody, newBody));
}
/**
*
*
* @generated
*/
@Override
public MetricType getType()
{
return type;
}
/**
*
*
* @generated
*/
@Override
public void setType(MetricType newType)
{
MetricType oldType = type;
type = newType == null ? TYPE_EDEFAULT : newType;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, SolverLanguagePackage.METRIC_DEFINITION__TYPE, oldType, type));
}
/**
*
*
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
{
switch (featureID)
{
case SolverLanguagePackage.METRIC_DEFINITION__HEAD:
return basicSetHead(null, msgs);
case SolverLanguagePackage.METRIC_DEFINITION__BODY:
return basicSetBody(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
*
*
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType)
{
switch (featureID)
{
case SolverLanguagePackage.METRIC_DEFINITION__HEAD:
return getHead();
case SolverLanguagePackage.METRIC_DEFINITION__BODY:
return getBody();
case SolverLanguagePackage.METRIC_DEFINITION__TYPE:
return getType();
}
return super.eGet(featureID, resolve, coreType);
}
/**
*
*
* @generated
*/
@Override
public void eSet(int featureID, Object newValue)
{
switch (featureID)
{
case SolverLanguagePackage.METRIC_DEFINITION__HEAD:
setHead((Expression)newValue);
return;
case SolverLanguagePackage.METRIC_DEFINITION__BODY:
setBody((Expression)newValue);
return;
case SolverLanguagePackage.METRIC_DEFINITION__TYPE:
setType((MetricType)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
*
*
* @generated
*/
@Override
public void eUnset(int featureID)
{
switch (featureID)
{
case SolverLanguagePackage.METRIC_DEFINITION__HEAD:
setHead((Expression)null);
return;
case SolverLanguagePackage.METRIC_DEFINITION__BODY:
setBody((Expression)null);
return;
case SolverLanguagePackage.METRIC_DEFINITION__TYPE:
setType(TYPE_EDEFAULT);
return;
}
super.eUnset(featureID);
}
/**
*
*
* @generated
*/
@Override
public boolean eIsSet(int featureID)
{
switch (featureID)
{
case SolverLanguagePackage.METRIC_DEFINITION__HEAD:
return head != null;
case SolverLanguagePackage.METRIC_DEFINITION__BODY:
return body != null;
case SolverLanguagePackage.METRIC_DEFINITION__TYPE:
return type != TYPE_EDEFAULT;
}
return super.eIsSet(featureID);
}
/**
*
*
* @generated
*/
@Override
public String toString()
{
if (eIsProxy()) return super.toString();
StringBuilder result = new StringBuilder(super.toString());
result.append(" (type: ");
result.append(type);
result.append(')');
return result.toString();
}
} //MetricDefinitionImpl