| /** |
| * 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.EObjectResolvingEList; |
| import org.eclipse.emf.ecore.util.InternalEList; |
| |
| import org.eclipse.osbp.xtext.statemachine.StatemachineAction; |
| import org.eclipse.osbp.xtext.statemachine.StatemachineDSLPackage; |
| import org.eclipse.osbp.xtext.statemachine.StatemachineEvent; |
| import org.eclipse.osbp.xtext.statemachine.StatemachineGuard; |
| 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 Trigger</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * <ul> |
| * <li>{@link org.eclipse.osbp.xtext.statemachine.impl.StatemachineTriggerImpl#isHasTransition <em>Has Transition</em>}</li> |
| * <li>{@link org.eclipse.osbp.xtext.statemachine.impl.StatemachineTriggerImpl#getTransition <em>Transition</em>}</li> |
| * <li>{@link org.eclipse.osbp.xtext.statemachine.impl.StatemachineTriggerImpl#getTriggers <em>Triggers</em>}</li> |
| * <li>{@link org.eclipse.osbp.xtext.statemachine.impl.StatemachineTriggerImpl#getGuards <em>Guards</em>}</li> |
| * <li>{@link org.eclipse.osbp.xtext.statemachine.impl.StatemachineTriggerImpl#getActions <em>Actions</em>}</li> |
| * </ul> |
| * </p> |
| * |
| * @generated |
| */ |
| public class StatemachineTriggerImpl extends StatemachineLazyResolverImpl implements StatemachineTrigger { |
| /** |
| * The default value of the '{@link #isHasTransition() <em>Has Transition</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #isHasTransition() |
| * @generated |
| * @ordered |
| */ |
| protected static final boolean HAS_TRANSITION_EDEFAULT = false; |
| |
| /** |
| * The cached value of the '{@link #isHasTransition() <em>Has Transition</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #isHasTransition() |
| * @generated |
| * @ordered |
| */ |
| protected boolean hasTransition = HAS_TRANSITION_EDEFAULT; |
| |
| /** |
| * The cached value of the '{@link #getTransition() <em>Transition</em>}' reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getTransition() |
| * @generated |
| * @ordered |
| */ |
| protected StatemachineState transition; |
| |
| /** |
| * The cached value of the '{@link #getTriggers() <em>Triggers</em>}' reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getTriggers() |
| * @generated |
| * @ordered |
| */ |
| protected EList<StatemachineEvent> triggers; |
| |
| /** |
| * The cached value of the '{@link #getGuards() <em>Guards</em>}' containment reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getGuards() |
| * @generated |
| * @ordered |
| */ |
| protected EList<StatemachineGuard> guards; |
| |
| /** |
| * The cached value of the '{@link #getActions() <em>Actions</em>}' containment reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getActions() |
| * @generated |
| * @ordered |
| */ |
| protected EList<StatemachineAction> actions; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected StatemachineTriggerImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return StatemachineDSLPackage.Literals.STATEMACHINE_TRIGGER; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public boolean isHasTransition() { |
| return hasTransition; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setHasTransition(boolean newHasTransition) { |
| boolean oldHasTransition = hasTransition; |
| hasTransition = newHasTransition; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, StatemachineDSLPackage.STATEMACHINE_TRIGGER__HAS_TRANSITION, oldHasTransition, hasTransition)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public StatemachineState getTransition() { |
| if (transition != null && transition.eIsProxy()) { |
| InternalEObject oldTransition = (InternalEObject)transition; |
| transition = (StatemachineState)eResolveProxy(oldTransition); |
| if (transition != oldTransition) { |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.RESOLVE, StatemachineDSLPackage.STATEMACHINE_TRIGGER__TRANSITION, oldTransition, transition)); |
| } |
| } |
| return transition; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public StatemachineState basicGetTransition() { |
| return transition; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setTransition(StatemachineState newTransition) { |
| StatemachineState oldTransition = transition; |
| transition = newTransition; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, StatemachineDSLPackage.STATEMACHINE_TRIGGER__TRANSITION, oldTransition, transition)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EList<StatemachineEvent> getTriggers() { |
| if (triggers == null) { |
| triggers = new EObjectResolvingEList<StatemachineEvent>(StatemachineEvent.class, this, StatemachineDSLPackage.STATEMACHINE_TRIGGER__TRIGGERS); |
| } |
| return triggers; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EList<StatemachineGuard> getGuards() { |
| if (guards == null) { |
| guards = new EObjectContainmentEList<StatemachineGuard>(StatemachineGuard.class, this, StatemachineDSLPackage.STATEMACHINE_TRIGGER__GUARDS); |
| } |
| return guards; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EList<StatemachineAction> getActions() { |
| if (actions == null) { |
| actions = new EObjectContainmentEList<StatemachineAction>(StatemachineAction.class, this, StatemachineDSLPackage.STATEMACHINE_TRIGGER__ACTIONS); |
| } |
| return actions; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case StatemachineDSLPackage.STATEMACHINE_TRIGGER__GUARDS: |
| return ((InternalEList<?>)getGuards()).basicRemove(otherEnd, msgs); |
| case StatemachineDSLPackage.STATEMACHINE_TRIGGER__ACTIONS: |
| return ((InternalEList<?>)getActions()).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 StatemachineDSLPackage.STATEMACHINE_TRIGGER__HAS_TRANSITION: |
| return isHasTransition(); |
| case StatemachineDSLPackage.STATEMACHINE_TRIGGER__TRANSITION: |
| if (resolve) return getTransition(); |
| return basicGetTransition(); |
| case StatemachineDSLPackage.STATEMACHINE_TRIGGER__TRIGGERS: |
| return getTriggers(); |
| case StatemachineDSLPackage.STATEMACHINE_TRIGGER__GUARDS: |
| return getGuards(); |
| case StatemachineDSLPackage.STATEMACHINE_TRIGGER__ACTIONS: |
| return getActions(); |
| } |
| 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_TRIGGER__HAS_TRANSITION: |
| setHasTransition((Boolean)newValue); |
| return; |
| case StatemachineDSLPackage.STATEMACHINE_TRIGGER__TRANSITION: |
| setTransition((StatemachineState)newValue); |
| return; |
| case StatemachineDSLPackage.STATEMACHINE_TRIGGER__TRIGGERS: |
| getTriggers().clear(); |
| getTriggers().addAll((Collection<? extends StatemachineEvent>)newValue); |
| return; |
| case StatemachineDSLPackage.STATEMACHINE_TRIGGER__GUARDS: |
| getGuards().clear(); |
| getGuards().addAll((Collection<? extends StatemachineGuard>)newValue); |
| return; |
| case StatemachineDSLPackage.STATEMACHINE_TRIGGER__ACTIONS: |
| getActions().clear(); |
| getActions().addAll((Collection<? extends StatemachineAction>)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case StatemachineDSLPackage.STATEMACHINE_TRIGGER__HAS_TRANSITION: |
| setHasTransition(HAS_TRANSITION_EDEFAULT); |
| return; |
| case StatemachineDSLPackage.STATEMACHINE_TRIGGER__TRANSITION: |
| setTransition((StatemachineState)null); |
| return; |
| case StatemachineDSLPackage.STATEMACHINE_TRIGGER__TRIGGERS: |
| getTriggers().clear(); |
| return; |
| case StatemachineDSLPackage.STATEMACHINE_TRIGGER__GUARDS: |
| getGuards().clear(); |
| return; |
| case StatemachineDSLPackage.STATEMACHINE_TRIGGER__ACTIONS: |
| getActions().clear(); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case StatemachineDSLPackage.STATEMACHINE_TRIGGER__HAS_TRANSITION: |
| return hasTransition != HAS_TRANSITION_EDEFAULT; |
| case StatemachineDSLPackage.STATEMACHINE_TRIGGER__TRANSITION: |
| return transition != null; |
| case StatemachineDSLPackage.STATEMACHINE_TRIGGER__TRIGGERS: |
| return triggers != null && !triggers.isEmpty(); |
| case StatemachineDSLPackage.STATEMACHINE_TRIGGER__GUARDS: |
| return guards != null && !guards.isEmpty(); |
| case StatemachineDSLPackage.STATEMACHINE_TRIGGER__ACTIONS: |
| return actions != null && !actions.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(" (hasTransition: "); |
| result.append(hasTransition); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| } //StatemachineTriggerImpl |