/**
*/
package org.eclipse.viatra.solver.language.model.problem.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.impl.MinimalEObjectImpl;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.viatra.solver.language.model.problem.Assertion;
import org.eclipse.viatra.solver.language.model.problem.AssertionArgument;
import org.eclipse.viatra.solver.language.model.problem.LogicValue;
import org.eclipse.viatra.solver.language.model.problem.ProblemPackage;
import org.eclipse.viatra.solver.language.model.problem.Relation;
/**
*
* An implementation of the model object 'Assertion'.
*
*
* The following features are implemented:
*
*
* - {@link org.eclipse.viatra.solver.language.model.problem.impl.AssertionImpl#getRelation Relation}
* - {@link org.eclipse.viatra.solver.language.model.problem.impl.AssertionImpl#getValue Value}
* - {@link org.eclipse.viatra.solver.language.model.problem.impl.AssertionImpl#getArguments Arguments}
*
*
* @generated
*/
public class AssertionImpl extends MinimalEObjectImpl.Container implements Assertion {
/**
* The cached value of the '{@link #getRelation() Relation}' reference.
*
*
* @see #getRelation()
* @generated
* @ordered
*/
protected Relation relation;
/**
* The default value of the '{@link #getValue() Value}' attribute.
*
*
* @see #getValue()
* @generated
* @ordered
*/
protected static final LogicValue VALUE_EDEFAULT = LogicValue.TRUE;
/**
* The cached value of the '{@link #getValue() Value}' attribute.
*
*
* @see #getValue()
* @generated
* @ordered
*/
protected LogicValue value = VALUE_EDEFAULT;
/**
* The cached value of the '{@link #getArguments() Arguments}' containment reference list.
*
*
* @see #getArguments()
* @generated
* @ordered
*/
protected EList arguments;
/**
*
*
* @generated
*/
protected AssertionImpl() {
super();
}
/**
*
*
* @generated
*/
@Override
protected EClass eStaticClass() {
return ProblemPackage.Literals.ASSERTION;
}
/**
*
*
* @generated
*/
public Relation getRelation() {
if (relation != null && relation.eIsProxy()) {
InternalEObject oldRelation = (InternalEObject) relation;
relation = (Relation) eResolveProxy(oldRelation);
if (relation != oldRelation) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, ProblemPackage.ASSERTION__RELATION,
oldRelation, relation));
}
}
return relation;
}
/**
*
*
* @generated
*/
public Relation basicGetRelation() {
return relation;
}
/**
*
*
* @generated
*/
public void setRelation(Relation newRelation) {
Relation oldRelation = relation;
relation = newRelation;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ProblemPackage.ASSERTION__RELATION, oldRelation,
relation));
}
/**
*
*
* @generated
*/
public EList getArguments() {
if (arguments == null) {
arguments = new EObjectContainmentEList(AssertionArgument.class, this,
ProblemPackage.ASSERTION__ARGUMENTS);
}
return arguments;
}
/**
*
*
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case ProblemPackage.ASSERTION__ARGUMENTS:
return ((InternalEList>) getArguments()).basicRemove(otherEnd, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
*
*
* @generated
*/
public LogicValue getValue() {
return value;
}
/**
*
*
* @generated
*/
public void setValue(LogicValue newValue) {
LogicValue oldValue = value;
value = newValue == null ? VALUE_EDEFAULT : newValue;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ProblemPackage.ASSERTION__VALUE, oldValue, value));
}
/**
*
*
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case ProblemPackage.ASSERTION__RELATION:
if (resolve)
return getRelation();
return basicGetRelation();
case ProblemPackage.ASSERTION__VALUE:
return getValue();
case ProblemPackage.ASSERTION__ARGUMENTS:
return getArguments();
}
return super.eGet(featureID, resolve, coreType);
}
/**
*
*
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case ProblemPackage.ASSERTION__RELATION:
setRelation((Relation) newValue);
return;
case ProblemPackage.ASSERTION__VALUE:
setValue((LogicValue) newValue);
return;
case ProblemPackage.ASSERTION__ARGUMENTS:
getArguments().clear();
getArguments().addAll((Collection extends AssertionArgument>) newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
*
*
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case ProblemPackage.ASSERTION__RELATION:
setRelation((Relation) null);
return;
case ProblemPackage.ASSERTION__VALUE:
setValue(VALUE_EDEFAULT);
return;
case ProblemPackage.ASSERTION__ARGUMENTS:
getArguments().clear();
return;
}
super.eUnset(featureID);
}
/**
*
*
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case ProblemPackage.ASSERTION__RELATION:
return relation != null;
case ProblemPackage.ASSERTION__VALUE:
return value != VALUE_EDEFAULT;
case ProblemPackage.ASSERTION__ARGUMENTS:
return arguments != null && !arguments.isEmpty();
}
return super.eIsSet(featureID);
}
/**
*
*
* @generated
*/
@Override
public String toString() {
if (eIsProxy())
return super.toString();
StringBuilder result = new StringBuilder(super.toString());
result.append(" (value: ");
result.append(value);
result.append(')');
return result.toString();
}
} //AssertionImpl