/** */ 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.ApplicationType; import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage; import hu.bme.mit.inf.dslreasoner.domains.cps.Request; import hu.bme.mit.inf.dslreasoner.domains.cps.Requirement; 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 'Requirement'. * *

* The following features are implemented: *

* * * @generated */ public class RequirementImpl extends MinimalEObjectImpl.Container implements Requirement { /** * The default value of the '{@link #getCount() Count}' attribute. * * * @see #getCount() * @generated * @ordered */ protected static final int COUNT_EDEFAULT = 0; /** * The cached value of the '{@link #getCount() Count}' attribute. * * * @see #getCount() * @generated * @ordered */ protected int count = COUNT_EDEFAULT; /** * The cached value of the '{@link #getType() Type}' reference. * * * @see #getType() * @generated * @ordered */ protected ApplicationType type; /** * The cached value of the '{@link #getInstances() Instances}' reference list. * * * @see #getInstances() * @generated * @ordered */ protected EList instances; /** * * * @generated */ protected RequirementImpl() { super(); } /** * * * @generated */ @Override protected EClass eStaticClass() { return CpsPackage.Literals.REQUIREMENT; } /** * * * @generated */ @Override public Request getRequest() { if (eContainerFeatureID() != CpsPackage.REQUIREMENT__REQUEST) return null; return (Request) eInternalContainer(); } /** * * * @generated */ public NotificationChain basicSetRequest(Request newRequest, NotificationChain msgs) { msgs = eBasicSetContainer((InternalEObject) newRequest, CpsPackage.REQUIREMENT__REQUEST, msgs); return msgs; } /** * * * @generated */ @Override public void setRequest(Request newRequest) { if (newRequest != eInternalContainer() || (eContainerFeatureID() != CpsPackage.REQUIREMENT__REQUEST && newRequest != null)) { if (EcoreUtil.isAncestor(this, newRequest)) throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); NotificationChain msgs = null; if (eInternalContainer() != null) msgs = eBasicRemoveFromContainer(msgs); if (newRequest != null) msgs = ((InternalEObject) newRequest).eInverseAdd(this, CpsPackage.REQUEST__REQUIREMENTS, Request.class, msgs); msgs = basicSetRequest(newRequest, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, CpsPackage.REQUIREMENT__REQUEST, newRequest, newRequest)); } /** * * * @generated */ @Override public int getCount() { return count; } /** * * * @generated */ @Override public void setCount(int newCount) { int oldCount = count; count = newCount; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, CpsPackage.REQUIREMENT__COUNT, oldCount, count)); } /** * * * @generated */ @Override public ApplicationType getType() { if (type != null && type.eIsProxy()) { InternalEObject oldType = (InternalEObject) type; type = (ApplicationType) eResolveProxy(oldType); if (type != oldType) { if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.RESOLVE, CpsPackage.REQUIREMENT__TYPE, oldType, type)); } } return type; } /** * * * @generated */ public ApplicationType basicGetType() { return type; } /** * * * @generated */ @Override public void setType(ApplicationType newType) { ApplicationType oldType = type; type = newType; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, CpsPackage.REQUIREMENT__TYPE, oldType, type)); } /** * * * @generated */ @Override public EList getInstances() { if (instances == null) { instances = new EObjectWithInverseResolvingEList(ApplicationInstance.class, this, CpsPackage.REQUIREMENT__INSTANCES, CpsPackage.APPLICATION_INSTANCE__REQUIREMENT); } return instances; } /** * * * @generated */ @SuppressWarnings("unchecked") @Override public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case CpsPackage.REQUIREMENT__REQUEST: if (eInternalContainer() != null) msgs = eBasicRemoveFromContainer(msgs); return basicSetRequest((Request) otherEnd, msgs); case CpsPackage.REQUIREMENT__INSTANCES: return ((InternalEList) (InternalEList) getInstances()).basicAdd(otherEnd, msgs); } return super.eInverseAdd(otherEnd, featureID, msgs); } /** * * * @generated */ @Override public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case CpsPackage.REQUIREMENT__REQUEST: return basicSetRequest(null, msgs); case CpsPackage.REQUIREMENT__INSTANCES: return ((InternalEList) getInstances()).basicRemove(otherEnd, msgs); } return super.eInverseRemove(otherEnd, featureID, msgs); } /** * * * @generated */ @Override public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { switch (eContainerFeatureID()) { case CpsPackage.REQUIREMENT__REQUEST: return eInternalContainer().eInverseRemove(this, CpsPackage.REQUEST__REQUIREMENTS, Request.class, msgs); } return super.eBasicRemoveFromContainerFeature(msgs); } /** * * * @generated */ @Override public Object eGet(int featureID, boolean resolve, boolean coreType) { switch (featureID) { case CpsPackage.REQUIREMENT__REQUEST: return getRequest(); case CpsPackage.REQUIREMENT__COUNT: return getCount(); case CpsPackage.REQUIREMENT__TYPE: if (resolve) return getType(); return basicGetType(); case CpsPackage.REQUIREMENT__INSTANCES: return getInstances(); } return super.eGet(featureID, resolve, coreType); } /** * * * @generated */ @SuppressWarnings("unchecked") @Override public void eSet(int featureID, Object newValue) { switch (featureID) { case CpsPackage.REQUIREMENT__REQUEST: setRequest((Request) newValue); return; case CpsPackage.REQUIREMENT__COUNT: setCount((Integer) newValue); return; case CpsPackage.REQUIREMENT__TYPE: setType((ApplicationType) newValue); return; case CpsPackage.REQUIREMENT__INSTANCES: getInstances().clear(); getInstances().addAll((Collection) newValue); return; } super.eSet(featureID, newValue); } /** * * * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case CpsPackage.REQUIREMENT__REQUEST: setRequest((Request) null); return; case CpsPackage.REQUIREMENT__COUNT: setCount(COUNT_EDEFAULT); return; case CpsPackage.REQUIREMENT__TYPE: setType((ApplicationType) null); return; case CpsPackage.REQUIREMENT__INSTANCES: getInstances().clear(); return; } super.eUnset(featureID); } /** * * * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case CpsPackage.REQUIREMENT__REQUEST: return getRequest() != null; case CpsPackage.REQUIREMENT__COUNT: return count != COUNT_EDEFAULT; case CpsPackage.REQUIREMENT__TYPE: return type != null; case CpsPackage.REQUIREMENT__INSTANCES: return instances != null && !instances.isEmpty(); } return super.eIsSet(featureID); } /** * * * @generated */ @Override public String toString() { if (eIsProxy()) return super.toString(); StringBuilder result = new StringBuilder(super.toString()); result.append(" (count: "); result.append(count); result.append(')'); return result.toString(); } } //RequirementImpl