/**
* Copyright (c) 2010-2011 United States Government as represented by the Administrator for The National Aeronautics and Space Administration. All Rights Reserved.
*/
package net.certware.evidence.hugin.instance.impl;
import java.util.Collection;
import net.certware.evidence.hugin.instance.InstancePackage;
import net.certware.evidence.hugin.instance.InstanceState;
import net.certware.evidence.hugin.instance.InstanceVariable;
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.EObjectImpl;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Variable</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link net.certware.evidence.hugin.instance.impl.InstanceVariableImpl#getVariableName <em>Variable Name</em>}</li>
* <li>{@link net.certware.evidence.hugin.instance.impl.InstanceVariableImpl#getStates <em>States</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class InstanceVariableImpl extends EObjectImpl implements InstanceVariable {
/**
* The default value of the '{@link #getVariableName() <em>Variable Name</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getVariableName()
* @generated
* @ordered
*/
protected static final String VARIABLE_NAME_EDEFAULT = null;
/**
* The cached value of the '{@link #getVariableName() <em>Variable Name</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getVariableName()
* @generated
* @ordered
*/
protected String variableName = VARIABLE_NAME_EDEFAULT;
/**
* The cached value of the '{@link #getStates() <em>States</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getStates()
* @generated
* @ordered
*/
protected EList<InstanceState> states;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected InstanceVariableImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return InstancePackage.Literals.INSTANCE_VARIABLE;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getVariableName() {
return variableName;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setVariableName(String newVariableName) {
String oldVariableName = variableName;
variableName = newVariableName;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, InstancePackage.INSTANCE_VARIABLE__VARIABLE_NAME, oldVariableName, variableName));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<InstanceState> getStates() {
if (states == null) {
states = new EObjectContainmentEList<InstanceState>(InstanceState.class, this, InstancePackage.INSTANCE_VARIABLE__STATES);
}
return states;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case InstancePackage.INSTANCE_VARIABLE__STATES:
return ((InternalEList<?>)getStates()).basicRemove(otherEnd, 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 InstancePackage.INSTANCE_VARIABLE__VARIABLE_NAME:
return getVariableName();
case InstancePackage.INSTANCE_VARIABLE__STATES:
return getStates();
}
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 InstancePackage.INSTANCE_VARIABLE__VARIABLE_NAME:
setVariableName((String)newValue);
return;
case InstancePackage.INSTANCE_VARIABLE__STATES:
getStates().clear();
getStates().addAll((Collection<? extends InstanceState>)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case InstancePackage.INSTANCE_VARIABLE__VARIABLE_NAME:
setVariableName(VARIABLE_NAME_EDEFAULT);
return;
case InstancePackage.INSTANCE_VARIABLE__STATES:
getStates().clear();
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case InstancePackage.INSTANCE_VARIABLE__VARIABLE_NAME:
return VARIABLE_NAME_EDEFAULT == null ? variableName != null : !VARIABLE_NAME_EDEFAULT.equals(variableName);
case InstancePackage.INSTANCE_VARIABLE__STATES:
return states != null && !states.isEmpty();
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public String toString() {
if (eIsProxy()) return super.toString();
StringBuffer result = new StringBuffer(super.toString());
result.append(" (variableName: "); //$NON-NLS-1$
result.append(variableName);
result.append(')');
return result.toString();
}
} //InstanceVariableImpl