| /** |
| * * Copyright (c) 2021 The University of York. |
| * * |
| * * This program and the accompanying materials are made |
| * * available under the terms of the Eclipse Public License 2.0 |
| * * which is available at https://www.eclipse.org/legal/epl-2.0/ |
| * * |
| * * SPDX-License-Identifier: EPL-2.0 |
| */ |
| package org.eclipse.epsilon.sirius.widget.examples.statemachine.impl; |
| |
| import org.eclipse.emf.common.notify.Notification; |
| import org.eclipse.emf.common.notify.NotificationChain; |
| |
| import org.eclipse.emf.ecore.EClass; |
| import org.eclipse.emf.ecore.InternalEObject; |
| |
| import org.eclipse.emf.ecore.impl.ENotificationImpl; |
| |
| import org.eclipse.epsilon.sirius.widget.examples.statemachine.State; |
| import org.eclipse.epsilon.sirius.widget.examples.statemachine.StatemachinePackage; |
| import org.eclipse.epsilon.sirius.widget.examples.statemachine.Transition; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Transition</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.epsilon.sirius.widget.examples.statemachine.impl.TransitionImpl#getTo <em>To</em>}</li> |
| * <li>{@link org.eclipse.epsilon.sirius.widget.examples.statemachine.impl.TransitionImpl#getFrom <em>From</em>}</li> |
| * <li>{@link org.eclipse.epsilon.sirius.widget.examples.statemachine.impl.TransitionImpl#getGuard <em>Guard</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public class TransitionImpl extends NamedElementImpl implements Transition { |
| /** |
| * The cached value of the '{@link #getTo() <em>To</em>}' reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getTo() |
| * @generated |
| * @ordered |
| */ |
| protected State to; |
| |
| /** |
| * The cached value of the '{@link #getFrom() <em>From</em>}' reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getFrom() |
| * @generated |
| * @ordered |
| */ |
| protected State from; |
| |
| /** |
| * The default value of the '{@link #getGuard() <em>Guard</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getGuard() |
| * @generated |
| * @ordered |
| */ |
| protected static final String GUARD_EDEFAULT = null; |
| |
| /** |
| * The cached value of the '{@link #getGuard() <em>Guard</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getGuard() |
| * @generated |
| * @ordered |
| */ |
| protected String guard = GUARD_EDEFAULT; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected TransitionImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return StatemachinePackage.Literals.TRANSITION; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public State getTo() { |
| if (to != null && to.eIsProxy()) { |
| InternalEObject oldTo = (InternalEObject)to; |
| to = (State)eResolveProxy(oldTo); |
| if (to != oldTo) { |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.RESOLVE, StatemachinePackage.TRANSITION__TO, oldTo, to)); |
| } |
| } |
| return to; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public State basicGetTo() { |
| return to; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetTo(State newTo, NotificationChain msgs) { |
| State oldTo = to; |
| to = newTo; |
| if (eNotificationRequired()) { |
| ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, StatemachinePackage.TRANSITION__TO, oldTo, newTo); |
| if (msgs == null) msgs = notification; else msgs.add(notification); |
| } |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setTo(State newTo) { |
| if (newTo != to) { |
| NotificationChain msgs = null; |
| if (to != null) |
| msgs = ((InternalEObject)to).eInverseRemove(this, StatemachinePackage.STATE__INCOMING, State.class, msgs); |
| if (newTo != null) |
| msgs = ((InternalEObject)newTo).eInverseAdd(this, StatemachinePackage.STATE__INCOMING, State.class, msgs); |
| msgs = basicSetTo(newTo, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, StatemachinePackage.TRANSITION__TO, newTo, newTo)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public State getFrom() { |
| if (from != null && from.eIsProxy()) { |
| InternalEObject oldFrom = (InternalEObject)from; |
| from = (State)eResolveProxy(oldFrom); |
| if (from != oldFrom) { |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.RESOLVE, StatemachinePackage.TRANSITION__FROM, oldFrom, from)); |
| } |
| } |
| return from; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public State basicGetFrom() { |
| return from; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetFrom(State newFrom, NotificationChain msgs) { |
| State oldFrom = from; |
| from = newFrom; |
| if (eNotificationRequired()) { |
| ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, StatemachinePackage.TRANSITION__FROM, oldFrom, newFrom); |
| if (msgs == null) msgs = notification; else msgs.add(notification); |
| } |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setFrom(State newFrom) { |
| if (newFrom != from) { |
| NotificationChain msgs = null; |
| if (from != null) |
| msgs = ((InternalEObject)from).eInverseRemove(this, StatemachinePackage.STATE__OUTGOING, State.class, msgs); |
| if (newFrom != null) |
| msgs = ((InternalEObject)newFrom).eInverseAdd(this, StatemachinePackage.STATE__OUTGOING, State.class, msgs); |
| msgs = basicSetFrom(newFrom, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, StatemachinePackage.TRANSITION__FROM, newFrom, newFrom)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public String getGuard() { |
| return guard; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setGuard(String newGuard) { |
| String oldGuard = guard; |
| guard = newGuard; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, StatemachinePackage.TRANSITION__GUARD, oldGuard, guard)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case StatemachinePackage.TRANSITION__TO: |
| if (to != null) |
| msgs = ((InternalEObject)to).eInverseRemove(this, StatemachinePackage.STATE__INCOMING, State.class, msgs); |
| return basicSetTo((State)otherEnd, msgs); |
| case StatemachinePackage.TRANSITION__FROM: |
| if (from != null) |
| msgs = ((InternalEObject)from).eInverseRemove(this, StatemachinePackage.STATE__OUTGOING, State.class, msgs); |
| return basicSetFrom((State)otherEnd, msgs); |
| } |
| return super.eInverseAdd(otherEnd, featureID, msgs); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case StatemachinePackage.TRANSITION__TO: |
| return basicSetTo(null, msgs); |
| case StatemachinePackage.TRANSITION__FROM: |
| return basicSetFrom(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 StatemachinePackage.TRANSITION__TO: |
| if (resolve) return getTo(); |
| return basicGetTo(); |
| case StatemachinePackage.TRANSITION__FROM: |
| if (resolve) return getFrom(); |
| return basicGetFrom(); |
| case StatemachinePackage.TRANSITION__GUARD: |
| return getGuard(); |
| } |
| return super.eGet(featureID, resolve, coreType); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eSet(int featureID, Object newValue) { |
| switch (featureID) { |
| case StatemachinePackage.TRANSITION__TO: |
| setTo((State)newValue); |
| return; |
| case StatemachinePackage.TRANSITION__FROM: |
| setFrom((State)newValue); |
| return; |
| case StatemachinePackage.TRANSITION__GUARD: |
| setGuard((String)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case StatemachinePackage.TRANSITION__TO: |
| setTo((State)null); |
| return; |
| case StatemachinePackage.TRANSITION__FROM: |
| setFrom((State)null); |
| return; |
| case StatemachinePackage.TRANSITION__GUARD: |
| setGuard(GUARD_EDEFAULT); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case StatemachinePackage.TRANSITION__TO: |
| return to != null; |
| case StatemachinePackage.TRANSITION__FROM: |
| return from != null; |
| case StatemachinePackage.TRANSITION__GUARD: |
| return GUARD_EDEFAULT == null ? guard != null : !GUARD_EDEFAULT.equals(guard); |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public String toString() { |
| if (eIsProxy()) return super.toString(); |
| |
| StringBuilder result = new StringBuilder(super.toString()); |
| result.append(" (guard: "); |
| result.append(guard); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| } //TransitionImpl |