/**
*/
package hu.bme.mit.inf.dslreasoner.domains.cps.impl;
import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance;
import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage;
import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance;
import hu.bme.mit.inf.dslreasoner.domains.cps.HostType;
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.EObjectWithInverseResolvingEList;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.util.InternalEList;
/**
*
* An implementation of the model object 'Host Instance'.
*
*
* The following features are implemented:
*
*
* - {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostInstanceImpl#getType Type}
* - {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostInstanceImpl#getApplications Applications}
*
*
* @generated
*/
public class HostInstanceImpl extends MinimalEObjectImpl.Container implements HostInstance {
/**
* The cached value of the '{@link #getApplications() Applications}' reference list.
*
*
* @see #getApplications()
* @generated
* @ordered
*/
protected EList applications;
/**
*
*
* @generated
*/
protected HostInstanceImpl() {
super();
}
/**
*
*
* @generated
*/
@Override
protected EClass eStaticClass() {
return CpsPackage.Literals.HOST_INSTANCE;
}
/**
*
*
* @generated
*/
@Override
public HostType getType() {
if (eContainerFeatureID() != CpsPackage.HOST_INSTANCE__TYPE)
return null;
return (HostType) eInternalContainer();
}
/**
*
*
* @generated
*/
public NotificationChain basicSetType(HostType newType, NotificationChain msgs) {
msgs = eBasicSetContainer((InternalEObject) newType, CpsPackage.HOST_INSTANCE__TYPE, msgs);
return msgs;
}
/**
*
*
* @generated
*/
@Override
public void setType(HostType newType) {
if (newType != eInternalContainer()
|| (eContainerFeatureID() != CpsPackage.HOST_INSTANCE__TYPE && newType != null)) {
if (EcoreUtil.isAncestor(this, newType))
throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
NotificationChain msgs = null;
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
if (newType != null)
msgs = ((InternalEObject) newType).eInverseAdd(this, CpsPackage.HOST_TYPE__INSTANCES, HostType.class,
msgs);
msgs = basicSetType(newType, msgs);
if (msgs != null)
msgs.dispatch();
} else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, CpsPackage.HOST_INSTANCE__TYPE, newType, newType));
}
/**
*
*
* @generated
*/
@Override
public EList getApplications() {
if (applications == null) {
applications = new EObjectWithInverseResolvingEList(ApplicationInstance.class, this,
CpsPackage.HOST_INSTANCE__APPLICATIONS, CpsPackage.APPLICATION_INSTANCE__ALLOCATED_TO);
}
return applications;
}
/**
*
*
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case CpsPackage.HOST_INSTANCE__TYPE:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetType((HostType) otherEnd, msgs);
case CpsPackage.HOST_INSTANCE__APPLICATIONS:
return ((InternalEList) (InternalEList>) getApplications()).basicAdd(otherEnd, msgs);
}
return super.eInverseAdd(otherEnd, featureID, msgs);
}
/**
*
*
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case CpsPackage.HOST_INSTANCE__TYPE:
return basicSetType(null, msgs);
case CpsPackage.HOST_INSTANCE__APPLICATIONS:
return ((InternalEList>) getApplications()).basicRemove(otherEnd, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
*
*
* @generated
*/
@Override
public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
switch (eContainerFeatureID()) {
case CpsPackage.HOST_INSTANCE__TYPE:
return eInternalContainer().eInverseRemove(this, CpsPackage.HOST_TYPE__INSTANCES, HostType.class, msgs);
}
return super.eBasicRemoveFromContainerFeature(msgs);
}
/**
*
*
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case CpsPackage.HOST_INSTANCE__TYPE:
return getType();
case CpsPackage.HOST_INSTANCE__APPLICATIONS:
return getApplications();
}
return super.eGet(featureID, resolve, coreType);
}
/**
*
*
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case CpsPackage.HOST_INSTANCE__TYPE:
setType((HostType) newValue);
return;
case CpsPackage.HOST_INSTANCE__APPLICATIONS:
getApplications().clear();
getApplications().addAll((Collection extends ApplicationInstance>) newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
*
*
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case CpsPackage.HOST_INSTANCE__TYPE:
setType((HostType) null);
return;
case CpsPackage.HOST_INSTANCE__APPLICATIONS:
getApplications().clear();
return;
}
super.eUnset(featureID);
}
/**
*
*
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case CpsPackage.HOST_INSTANCE__TYPE:
return getType() != null;
case CpsPackage.HOST_INSTANCE__APPLICATIONS:
return applications != null && !applications.isEmpty();
}
return super.eIsSet(featureID);
}
} //HostInstanceImpl