/** * generated by Xtext 2.10.0 */ package com.arm.cmsis.pack.debugseq.debugSeq.impl; import com.arm.cmsis.pack.debugseq.debugSeq.CodeBlock; import com.arm.cmsis.pack.debugseq.debugSeq.Control; import com.arm.cmsis.pack.debugseq.debugSeq.DebugSeqPackage; import com.arm.cmsis.pack.debugseq.debugSeq.Expression; 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; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>Control</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * </p> * <ul> * <li>{@link com.arm.cmsis.pack.debugseq.debugSeq.impl.ControlImpl#getIf <em>If</em>}</li> * <li>{@link com.arm.cmsis.pack.debugseq.debugSeq.impl.ControlImpl#getWhile <em>While</em>}</li> * <li>{@link com.arm.cmsis.pack.debugseq.debugSeq.impl.ControlImpl#getTimeout <em>Timeout</em>}</li> * <li>{@link com.arm.cmsis.pack.debugseq.debugSeq.impl.ControlImpl#getCodeblocks <em>Codeblocks</em>}</li> * </ul> * * @generated */ public class ControlImpl extends CodeBlockImpl implements Control { /** * The cached value of the '{@link #getIf() <em>If</em>}' containment reference. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getIf() * @generated * @ordered */ protected Expression if_; /** * The cached value of the '{@link #getWhile() <em>While</em>}' containment reference. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getWhile() * @generated * @ordered */ protected Expression while_; /** * The default value of the '{@link #getTimeout() <em>Timeout</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getTimeout() * @generated * @ordered */ protected static final long TIMEOUT_EDEFAULT = 0L; /** * The cached value of the '{@link #getTimeout() <em>Timeout</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getTimeout() * @generated * @ordered */ protected long timeout = TIMEOUT_EDEFAULT; /** * The cached value of the '{@link #getCodeblocks() <em>Codeblocks</em>}' containment reference list. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getCodeblocks() * @generated * @ordered */ protected EList<CodeBlock> codeblocks; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected ControlImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return DebugSeqPackage.Literals.CONTROL; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Expression getIf() { return if_; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain basicSetIf(Expression newIf, NotificationChain msgs) { Expression oldIf = if_; if_ = newIf; if (eNotificationRequired()) { ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, DebugSeqPackage.CONTROL__IF, oldIf, newIf); if (msgs == null) msgs = notification; else msgs.add(notification); } return msgs; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setIf(Expression newIf) { if (newIf != if_) { NotificationChain msgs = null; if (if_ != null) msgs = ((InternalEObject)if_).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - DebugSeqPackage.CONTROL__IF, null, msgs); if (newIf != null) msgs = ((InternalEObject)newIf).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - DebugSeqPackage.CONTROL__IF, null, msgs); msgs = basicSetIf(newIf, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, DebugSeqPackage.CONTROL__IF, newIf, newIf)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Expression getWhile() { return while_; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain basicSetWhile(Expression newWhile, NotificationChain msgs) { Expression oldWhile = while_; while_ = newWhile; if (eNotificationRequired()) { ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, DebugSeqPackage.CONTROL__WHILE, oldWhile, newWhile); if (msgs == null) msgs = notification; else msgs.add(notification); } return msgs; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setWhile(Expression newWhile) { if (newWhile != while_) { NotificationChain msgs = null; if (while_ != null) msgs = ((InternalEObject)while_).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - DebugSeqPackage.CONTROL__WHILE, null, msgs); if (newWhile != null) msgs = ((InternalEObject)newWhile).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - DebugSeqPackage.CONTROL__WHILE, null, msgs); msgs = basicSetWhile(newWhile, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, DebugSeqPackage.CONTROL__WHILE, newWhile, newWhile)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public long getTimeout() { return timeout; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setTimeout(long newTimeout) { long oldTimeout = timeout; timeout = newTimeout; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, DebugSeqPackage.CONTROL__TIMEOUT, oldTimeout, timeout)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EList<CodeBlock> getCodeblocks() { if (codeblocks == null) { codeblocks = new EObjectContainmentEList<CodeBlock>(CodeBlock.class, this, DebugSeqPackage.CONTROL__CODEBLOCKS); } return codeblocks; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case DebugSeqPackage.CONTROL__IF: return basicSetIf(null, msgs); case DebugSeqPackage.CONTROL__WHILE: return basicSetWhile(null, msgs); case DebugSeqPackage.CONTROL__CODEBLOCKS: return ((InternalEList<?>)getCodeblocks()).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 DebugSeqPackage.CONTROL__IF: return getIf(); case DebugSeqPackage.CONTROL__WHILE: return getWhile(); case DebugSeqPackage.CONTROL__TIMEOUT: return getTimeout(); case DebugSeqPackage.CONTROL__CODEBLOCKS: return getCodeblocks(); } 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 DebugSeqPackage.CONTROL__IF: setIf((Expression)newValue); return; case DebugSeqPackage.CONTROL__WHILE: setWhile((Expression)newValue); return; case DebugSeqPackage.CONTROL__TIMEOUT: setTimeout((Long)newValue); return; case DebugSeqPackage.CONTROL__CODEBLOCKS: getCodeblocks().clear(); getCodeblocks().addAll((Collection<? extends CodeBlock>)newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case DebugSeqPackage.CONTROL__IF: setIf((Expression)null); return; case DebugSeqPackage.CONTROL__WHILE: setWhile((Expression)null); return; case DebugSeqPackage.CONTROL__TIMEOUT: setTimeout(TIMEOUT_EDEFAULT); return; case DebugSeqPackage.CONTROL__CODEBLOCKS: getCodeblocks().clear(); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case DebugSeqPackage.CONTROL__IF: return if_ != null; case DebugSeqPackage.CONTROL__WHILE: return while_ != null; case DebugSeqPackage.CONTROL__TIMEOUT: return timeout != TIMEOUT_EDEFAULT; case DebugSeqPackage.CONTROL__CODEBLOCKS: return codeblocks != null && !codeblocks.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(" (timeout: "); result.append(timeout); result.append(')'); return result.toString(); } } //ControlImpl