/*
* Copyright (c) 2003- michael lawley and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation
* which accompanies this distribution, and is available by writing to
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Contributors:
* michael lawley
*
*
*/
package tefkat.model.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 tefkat.model.Condition;
import tefkat.model.Expression;
import tefkat.model.TefkatPackage;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Condition</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link tefkat.model.impl.ConditionImpl#getArg <em>Arg</em>}</li>
* <li>{@link tefkat.model.impl.ConditionImpl#getRelation <em>Relation</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class ConditionImpl extends SimpleTermImpl implements Condition {
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public static final String copyright = "Copyright michael lawley Pty Ltd 2003-2007";
/**
* The cached value of the '{@link #getArg() <em>Arg</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getArg()
* @generated
* @ordered
*/
protected EList arg = null;
/**
* The default value of the '{@link #getRelation() <em>Relation</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getRelation()
* @generated
* @ordered
*/
protected static final String RELATION_EDEFAULT = null;
/**
* The cached value of the '{@link #getRelation() <em>Relation</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getRelation()
* @generated
* @ordered
*/
protected String relation = RELATION_EDEFAULT;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected ConditionImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected EClass eStaticClass() {
return TefkatPackage.Literals.CONDITION;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList getArg() {
if (arg == null) {
arg = new EObjectContainmentEList(Expression.class, this, TefkatPackage.CONDITION__ARG);
}
return arg;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getRelation() {
return relation;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setRelation(String newRelation) {
String oldRelation = relation;
relation = newRelation;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, TefkatPackage.CONDITION__RELATION, oldRelation, relation));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case TefkatPackage.CONDITION__ARG:
return ((InternalEList)getArg()).basicRemove(otherEnd, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case TefkatPackage.CONDITION__ARG:
return getArg();
case TefkatPackage.CONDITION__RELATION:
return getRelation();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case TefkatPackage.CONDITION__ARG:
getArg().clear();
getArg().addAll((Collection)newValue);
return;
case TefkatPackage.CONDITION__RELATION:
setRelation((String)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void eUnset(int featureID) {
switch (featureID) {
case TefkatPackage.CONDITION__ARG:
getArg().clear();
return;
case TefkatPackage.CONDITION__RELATION:
setRelation(RELATION_EDEFAULT);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public boolean eIsSet(int featureID) {
switch (featureID) {
case TefkatPackage.CONDITION__ARG:
return arg != null && !arg.isEmpty();
case TefkatPackage.CONDITION__RELATION:
return RELATION_EDEFAULT == null ? relation != null : !RELATION_EDEFAULT.equals(relation);
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
public String toString() {
if (eIsProxy()) return super.toString();
String result;
if (getArg().size() == 1) {
result = relation + "(" + arg.get(0) + ")";
} else if (getArg().size() > 1) {
result = arg.get(0) + relation + arg.get(1);
} else {
result = super.toString();
}
return result;
}
} //ConditionImpl