/** */ package ftp.impl; import ftp.ComposedComponent; import ftp.FaultTreeContext; import ftp.FtpPackage; import ftp.Observation; 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.EObjectContainmentEList; import org.eclipse.emf.ecore.util.InternalEList; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>Fault Tree Context</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * </p> * <ul> * <li>{@link ftp.impl.FaultTreeContextImpl#getComposition <em>Composition</em>}</li> * <li>{@link ftp.impl.FaultTreeContextImpl#getObservations <em>Observations</em>}</li> * </ul> * * @generated */ public class FaultTreeContextImpl extends MinimalEObjectImpl.Container implements FaultTreeContext { /** * The cached value of the '{@link #getComposition() <em>Composition</em>}' containment reference. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getComposition() * @generated * @ordered */ protected ComposedComponent composition; /** * The cached value of the '{@link #getObservations() <em>Observations</em>}' containment reference list. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getObservations() * @generated * @ordered */ protected EList<Observation> observations; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected FaultTreeContextImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return FtpPackage.Literals.FAULT_TREE_CONTEXT; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public ComposedComponent getComposition() { return composition; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain basicSetComposition(ComposedComponent newComposition, NotificationChain msgs) { ComposedComponent oldComposition = composition; composition = newComposition; if (eNotificationRequired()) { ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, FtpPackage.FAULT_TREE_CONTEXT__COMPOSITION, oldComposition, newComposition); if (msgs == null) msgs = notification; else msgs.add(notification); } return msgs; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setComposition(ComposedComponent newComposition) { if (newComposition != composition) { NotificationChain msgs = null; if (composition != null) msgs = ((InternalEObject)composition).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - FtpPackage.FAULT_TREE_CONTEXT__COMPOSITION, null, msgs); if (newComposition != null) msgs = ((InternalEObject)newComposition).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - FtpPackage.FAULT_TREE_CONTEXT__COMPOSITION, null, msgs); msgs = basicSetComposition(newComposition, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, FtpPackage.FAULT_TREE_CONTEXT__COMPOSITION, newComposition, newComposition)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EList<Observation> getObservations() { if (observations == null) { observations = new EObjectContainmentEList<Observation>(Observation.class, this, FtpPackage.FAULT_TREE_CONTEXT__OBSERVATIONS); } return observations; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case FtpPackage.FAULT_TREE_CONTEXT__COMPOSITION: return basicSetComposition(null, msgs); case FtpPackage.FAULT_TREE_CONTEXT__OBSERVATIONS: return ((InternalEList<?>)getObservations()).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 FtpPackage.FAULT_TREE_CONTEXT__COMPOSITION: return getComposition(); case FtpPackage.FAULT_TREE_CONTEXT__OBSERVATIONS: return getObservations(); } 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 FtpPackage.FAULT_TREE_CONTEXT__COMPOSITION: setComposition((ComposedComponent)newValue); return; case FtpPackage.FAULT_TREE_CONTEXT__OBSERVATIONS: getObservations().clear(); getObservations().addAll((Collection<? extends Observation>)newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case FtpPackage.FAULT_TREE_CONTEXT__COMPOSITION: setComposition((ComposedComponent)null); return; case FtpPackage.FAULT_TREE_CONTEXT__OBSERVATIONS: getObservations().clear(); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case FtpPackage.FAULT_TREE_CONTEXT__COMPOSITION: return composition != null; case FtpPackage.FAULT_TREE_CONTEXT__OBSERVATIONS: return observations != null && !observations.isEmpty(); } return super.eIsSet(featureID); } } //FaultTreeContextImpl