/**
*/
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.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.EObjectResolvingEList;
import org.eclipse.viatra.solver.language.model.problem.Atom;
import org.eclipse.viatra.solver.language.model.problem.ProblemPackage;
import org.eclipse.viatra.solver.language.model.problem.Relation;
import org.eclipse.viatra.solver.language.model.problem.Variable;
/**
*
* An implementation of the model object 'Atom'.
*
*
* The following features are implemented:
*
*
* - {@link org.eclipse.viatra.solver.language.model.problem.impl.AtomImpl#getRelation Relation}
* - {@link org.eclipse.viatra.solver.language.model.problem.impl.AtomImpl#getArguments Arguments}
* - {@link org.eclipse.viatra.solver.language.model.problem.impl.AtomImpl#isTransitiveClosure Transitive Closure}
*
*
* @generated
*/
public class AtomImpl extends LiteralImpl implements Atom {
/**
* The cached value of the '{@link #getRelation() Relation}' reference.
*
*
* @see #getRelation()
* @generated
* @ordered
*/
protected Relation relation;
/**
* The cached value of the '{@link #getArguments() Arguments}' reference list.
*
*
* @see #getArguments()
* @generated
* @ordered
*/
protected EList arguments;
/**
* The default value of the '{@link #isTransitiveClosure() Transitive Closure}' attribute.
*
*
* @see #isTransitiveClosure()
* @generated
* @ordered
*/
protected static final boolean TRANSITIVE_CLOSURE_EDEFAULT = false;
/**
* The cached value of the '{@link #isTransitiveClosure() Transitive Closure}' attribute.
*
*
* @see #isTransitiveClosure()
* @generated
* @ordered
*/
protected boolean transitiveClosure = TRANSITIVE_CLOSURE_EDEFAULT;
/**
*
*
* @generated
*/
protected AtomImpl() {
super();
}
/**
*
*
* @generated
*/
@Override
protected EClass eStaticClass() {
return ProblemPackage.Literals.ATOM;
}
/**
*
*
* @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.ATOM__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.ATOM__RELATION, oldRelation,
relation));
}
/**
*
*
* @generated
*/
public EList getArguments() {
if (arguments == null) {
arguments = new EObjectResolvingEList(Variable.class, this, ProblemPackage.ATOM__ARGUMENTS);
}
return arguments;
}
/**
*
*
* @generated
*/
public boolean isTransitiveClosure() {
return transitiveClosure;
}
/**
*
*
* @generated
*/
public void setTransitiveClosure(boolean newTransitiveClosure) {
boolean oldTransitiveClosure = transitiveClosure;
transitiveClosure = newTransitiveClosure;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ProblemPackage.ATOM__TRANSITIVE_CLOSURE,
oldTransitiveClosure, transitiveClosure));
}
/**
*
*
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case ProblemPackage.ATOM__RELATION:
if (resolve)
return getRelation();
return basicGetRelation();
case ProblemPackage.ATOM__ARGUMENTS:
return getArguments();
case ProblemPackage.ATOM__TRANSITIVE_CLOSURE:
return isTransitiveClosure();
}
return super.eGet(featureID, resolve, coreType);
}
/**
*
*
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case ProblemPackage.ATOM__RELATION:
setRelation((Relation) newValue);
return;
case ProblemPackage.ATOM__ARGUMENTS:
getArguments().clear();
getArguments().addAll((Collection extends Variable>) newValue);
return;
case ProblemPackage.ATOM__TRANSITIVE_CLOSURE:
setTransitiveClosure((Boolean) newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
*
*
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case ProblemPackage.ATOM__RELATION:
setRelation((Relation) null);
return;
case ProblemPackage.ATOM__ARGUMENTS:
getArguments().clear();
return;
case ProblemPackage.ATOM__TRANSITIVE_CLOSURE:
setTransitiveClosure(TRANSITIVE_CLOSURE_EDEFAULT);
return;
}
super.eUnset(featureID);
}
/**
*
*
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case ProblemPackage.ATOM__RELATION:
return relation != null;
case ProblemPackage.ATOM__ARGUMENTS:
return arguments != null && !arguments.isEmpty();
case ProblemPackage.ATOM__TRANSITIVE_CLOSURE:
return transitiveClosure != TRANSITIVE_CLOSURE_EDEFAULT;
}
return super.eIsSet(featureID);
}
/**
*
*
* @generated
*/
@Override
public String toString() {
if (eIsProxy())
return super.toString();
StringBuilder result = new StringBuilder(super.toString());
result.append(" (transitiveClosure: ");
result.append(transitiveClosure);
result.append(')');
return result.toString();
}
} //AtomImpl