| /** |
| * Copyright (c) 2011, 2017 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany) |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Based on ideas from Xtext, Xtend, Xcore |
| * |
| * Contributors: |
| * Christophe Loetz (Loetz GmbH&Co.KG) - Initial implementation |
| * |
| */ |
| package org.eclipse.osbp.xtext.statemachine.impl; |
| |
| 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; |
| |
| import org.eclipse.osbp.xtext.statemachine.StatemachineControlFieldAttribute; |
| import org.eclipse.osbp.xtext.statemachine.StatemachineDSLPackage; |
| import org.eclipse.osbp.xtext.statemachine.StatemachineOperation; |
| import org.eclipse.osbp.xtext.statemachine.StatemachineState; |
| import org.eclipse.osbp.xtext.statemachine.StatemachineTrigger; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Statemachine State</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * <ul> |
| * <li>{@link org.eclipse.osbp.xtext.statemachine.impl.StatemachineStateImpl#getTriggers <em>Triggers</em>}</li> |
| * <li>{@link org.eclipse.osbp.xtext.statemachine.impl.StatemachineStateImpl#getIdentity <em>Identity</em>}</li> |
| * <li>{@link org.eclipse.osbp.xtext.statemachine.impl.StatemachineStateImpl#getKeystroke <em>Keystroke</em>}</li> |
| * <li>{@link org.eclipse.osbp.xtext.statemachine.impl.StatemachineStateImpl#isHasKeyOperation <em>Has Key Operation</em>}</li> |
| * <li>{@link org.eclipse.osbp.xtext.statemachine.impl.StatemachineStateImpl#getKeyOperation <em>Key Operation</em>}</li> |
| * </ul> |
| * </p> |
| * |
| * @generated |
| */ |
| public class StatemachineStateImpl extends StatemachineBaseImpl implements StatemachineState { |
| /** |
| * The cached value of the '{@link #getTriggers() <em>Triggers</em>}' containment reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getTriggers() |
| * @generated |
| * @ordered |
| */ |
| protected EList<StatemachineTrigger> triggers; |
| |
| /** |
| * The cached value of the '{@link #getIdentity() <em>Identity</em>}' containment reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getIdentity() |
| * @generated |
| * @ordered |
| */ |
| protected StatemachineOperation identity; |
| |
| /** |
| * The cached value of the '{@link #getKeystroke() <em>Keystroke</em>}' reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getKeystroke() |
| * @generated |
| * @ordered |
| */ |
| protected StatemachineControlFieldAttribute keystroke; |
| |
| /** |
| * The default value of the '{@link #isHasKeyOperation() <em>Has Key Operation</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #isHasKeyOperation() |
| * @generated |
| * @ordered |
| */ |
| protected static final boolean HAS_KEY_OPERATION_EDEFAULT = false; |
| |
| /** |
| * The cached value of the '{@link #isHasKeyOperation() <em>Has Key Operation</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #isHasKeyOperation() |
| * @generated |
| * @ordered |
| */ |
| protected boolean hasKeyOperation = HAS_KEY_OPERATION_EDEFAULT; |
| |
| /** |
| * The cached value of the '{@link #getKeyOperation() <em>Key Operation</em>}' containment reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getKeyOperation() |
| * @generated |
| * @ordered |
| */ |
| protected StatemachineOperation keyOperation; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected StatemachineStateImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return StatemachineDSLPackage.Literals.STATEMACHINE_STATE; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EList<StatemachineTrigger> getTriggers() { |
| if (triggers == null) { |
| triggers = new EObjectContainmentEList<StatemachineTrigger>(StatemachineTrigger.class, this, StatemachineDSLPackage.STATEMACHINE_STATE__TRIGGERS); |
| } |
| return triggers; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public StatemachineOperation getIdentity() { |
| return identity; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetIdentity(StatemachineOperation newIdentity, NotificationChain msgs) { |
| StatemachineOperation oldIdentity = identity; |
| identity = newIdentity; |
| if (eNotificationRequired()) { |
| ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, StatemachineDSLPackage.STATEMACHINE_STATE__IDENTITY, oldIdentity, newIdentity); |
| if (msgs == null) msgs = notification; else msgs.add(notification); |
| } |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setIdentity(StatemachineOperation newIdentity) { |
| if (newIdentity != identity) { |
| NotificationChain msgs = null; |
| if (identity != null) |
| msgs = ((InternalEObject)identity).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - StatemachineDSLPackage.STATEMACHINE_STATE__IDENTITY, null, msgs); |
| if (newIdentity != null) |
| msgs = ((InternalEObject)newIdentity).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - StatemachineDSLPackage.STATEMACHINE_STATE__IDENTITY, null, msgs); |
| msgs = basicSetIdentity(newIdentity, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, StatemachineDSLPackage.STATEMACHINE_STATE__IDENTITY, newIdentity, newIdentity)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public StatemachineControlFieldAttribute getKeystroke() { |
| if (keystroke != null && keystroke.eIsProxy()) { |
| InternalEObject oldKeystroke = (InternalEObject)keystroke; |
| keystroke = (StatemachineControlFieldAttribute)eResolveProxy(oldKeystroke); |
| if (keystroke != oldKeystroke) { |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.RESOLVE, StatemachineDSLPackage.STATEMACHINE_STATE__KEYSTROKE, oldKeystroke, keystroke)); |
| } |
| } |
| return keystroke; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public StatemachineControlFieldAttribute basicGetKeystroke() { |
| return keystroke; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setKeystroke(StatemachineControlFieldAttribute newKeystroke) { |
| StatemachineControlFieldAttribute oldKeystroke = keystroke; |
| keystroke = newKeystroke; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, StatemachineDSLPackage.STATEMACHINE_STATE__KEYSTROKE, oldKeystroke, keystroke)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public boolean isHasKeyOperation() { |
| return hasKeyOperation; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setHasKeyOperation(boolean newHasKeyOperation) { |
| boolean oldHasKeyOperation = hasKeyOperation; |
| hasKeyOperation = newHasKeyOperation; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, StatemachineDSLPackage.STATEMACHINE_STATE__HAS_KEY_OPERATION, oldHasKeyOperation, hasKeyOperation)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public StatemachineOperation getKeyOperation() { |
| return keyOperation; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetKeyOperation(StatemachineOperation newKeyOperation, NotificationChain msgs) { |
| StatemachineOperation oldKeyOperation = keyOperation; |
| keyOperation = newKeyOperation; |
| if (eNotificationRequired()) { |
| ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, StatemachineDSLPackage.STATEMACHINE_STATE__KEY_OPERATION, oldKeyOperation, newKeyOperation); |
| if (msgs == null) msgs = notification; else msgs.add(notification); |
| } |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setKeyOperation(StatemachineOperation newKeyOperation) { |
| if (newKeyOperation != keyOperation) { |
| NotificationChain msgs = null; |
| if (keyOperation != null) |
| msgs = ((InternalEObject)keyOperation).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - StatemachineDSLPackage.STATEMACHINE_STATE__KEY_OPERATION, null, msgs); |
| if (newKeyOperation != null) |
| msgs = ((InternalEObject)newKeyOperation).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - StatemachineDSLPackage.STATEMACHINE_STATE__KEY_OPERATION, null, msgs); |
| msgs = basicSetKeyOperation(newKeyOperation, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, StatemachineDSLPackage.STATEMACHINE_STATE__KEY_OPERATION, newKeyOperation, newKeyOperation)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case StatemachineDSLPackage.STATEMACHINE_STATE__TRIGGERS: |
| return ((InternalEList<?>)getTriggers()).basicRemove(otherEnd, msgs); |
| case StatemachineDSLPackage.STATEMACHINE_STATE__IDENTITY: |
| return basicSetIdentity(null, msgs); |
| case StatemachineDSLPackage.STATEMACHINE_STATE__KEY_OPERATION: |
| return basicSetKeyOperation(null, 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 StatemachineDSLPackage.STATEMACHINE_STATE__TRIGGERS: |
| return getTriggers(); |
| case StatemachineDSLPackage.STATEMACHINE_STATE__IDENTITY: |
| return getIdentity(); |
| case StatemachineDSLPackage.STATEMACHINE_STATE__KEYSTROKE: |
| if (resolve) return getKeystroke(); |
| return basicGetKeystroke(); |
| case StatemachineDSLPackage.STATEMACHINE_STATE__HAS_KEY_OPERATION: |
| return isHasKeyOperation(); |
| case StatemachineDSLPackage.STATEMACHINE_STATE__KEY_OPERATION: |
| return getKeyOperation(); |
| } |
| 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 StatemachineDSLPackage.STATEMACHINE_STATE__TRIGGERS: |
| getTriggers().clear(); |
| getTriggers().addAll((Collection<? extends StatemachineTrigger>)newValue); |
| return; |
| case StatemachineDSLPackage.STATEMACHINE_STATE__IDENTITY: |
| setIdentity((StatemachineOperation)newValue); |
| return; |
| case StatemachineDSLPackage.STATEMACHINE_STATE__KEYSTROKE: |
| setKeystroke((StatemachineControlFieldAttribute)newValue); |
| return; |
| case StatemachineDSLPackage.STATEMACHINE_STATE__HAS_KEY_OPERATION: |
| setHasKeyOperation((Boolean)newValue); |
| return; |
| case StatemachineDSLPackage.STATEMACHINE_STATE__KEY_OPERATION: |
| setKeyOperation((StatemachineOperation)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case StatemachineDSLPackage.STATEMACHINE_STATE__TRIGGERS: |
| getTriggers().clear(); |
| return; |
| case StatemachineDSLPackage.STATEMACHINE_STATE__IDENTITY: |
| setIdentity((StatemachineOperation)null); |
| return; |
| case StatemachineDSLPackage.STATEMACHINE_STATE__KEYSTROKE: |
| setKeystroke((StatemachineControlFieldAttribute)null); |
| return; |
| case StatemachineDSLPackage.STATEMACHINE_STATE__HAS_KEY_OPERATION: |
| setHasKeyOperation(HAS_KEY_OPERATION_EDEFAULT); |
| return; |
| case StatemachineDSLPackage.STATEMACHINE_STATE__KEY_OPERATION: |
| setKeyOperation((StatemachineOperation)null); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case StatemachineDSLPackage.STATEMACHINE_STATE__TRIGGERS: |
| return triggers != null && !triggers.isEmpty(); |
| case StatemachineDSLPackage.STATEMACHINE_STATE__IDENTITY: |
| return identity != null; |
| case StatemachineDSLPackage.STATEMACHINE_STATE__KEYSTROKE: |
| return keystroke != null; |
| case StatemachineDSLPackage.STATEMACHINE_STATE__HAS_KEY_OPERATION: |
| return hasKeyOperation != HAS_KEY_OPERATION_EDEFAULT; |
| case StatemachineDSLPackage.STATEMACHINE_STATE__KEY_OPERATION: |
| return keyOperation != null; |
| } |
| 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(" (hasKeyOperation: "); |
| result.append(hasKeyOperation); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| } //StatemachineStateImpl |