| /** |
| * <copyright> |
| * </copyright> |
| * |
| */ |
| package org.eclipse.xtext.example.fowlerdsl.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.impl.MinimalEObjectImpl; |
| |
| import org.eclipse.emf.ecore.util.EObjectContainmentEList; |
| import org.eclipse.emf.ecore.util.EObjectResolvingEList; |
| import org.eclipse.emf.ecore.util.InternalEList; |
| |
| import org.eclipse.xtext.example.fowlerdsl.statemachine.Command; |
| import org.eclipse.xtext.example.fowlerdsl.statemachine.State; |
| import org.eclipse.xtext.example.fowlerdsl.statemachine.StatemachinePackage; |
| import org.eclipse.xtext.example.fowlerdsl.statemachine.Transition; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>State</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * <ul> |
| * <li>{@link org.eclipse.xtext.example.fowlerdsl.statemachine.impl.StateImpl#getName <em>Name</em>}</li> |
| * <li>{@link org.eclipse.xtext.example.fowlerdsl.statemachine.impl.StateImpl#getActions <em>Actions</em>}</li> |
| * <li>{@link org.eclipse.xtext.example.fowlerdsl.statemachine.impl.StateImpl#getTransitions <em>Transitions</em>}</li> |
| * </ul> |
| * </p> |
| * |
| * @generated |
| */ |
| public class StateImpl extends MinimalEObjectImpl.Container implements State |
| { |
| /** |
| * The default value of the '{@link #getName() <em>Name</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getName() |
| * @generated |
| * @ordered |
| */ |
| protected static final String NAME_EDEFAULT = null; |
| |
| /** |
| * The cached value of the '{@link #getName() <em>Name</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getName() |
| * @generated |
| * @ordered |
| */ |
| protected String name = NAME_EDEFAULT; |
| |
| /** |
| * The cached value of the '{@link #getActions() <em>Actions</em>}' reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getActions() |
| * @generated |
| * @ordered |
| */ |
| protected EList<Command> actions; |
| |
| /** |
| * The cached value of the '{@link #getTransitions() <em>Transitions</em>}' containment reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getTransitions() |
| * @generated |
| * @ordered |
| */ |
| protected EList<Transition> transitions; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected StateImpl() |
| { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() |
| { |
| return StatemachinePackage.Literals.STATE; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public String getName() |
| { |
| return name; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setName(String newName) |
| { |
| String oldName = name; |
| name = newName; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, StatemachinePackage.STATE__NAME, oldName, name)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EList<Command> getActions() |
| { |
| if (actions == null) |
| { |
| actions = new EObjectResolvingEList<Command>(Command.class, this, StatemachinePackage.STATE__ACTIONS); |
| } |
| return actions; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EList<Transition> getTransitions() |
| { |
| if (transitions == null) |
| { |
| transitions = new EObjectContainmentEList<Transition>(Transition.class, this, StatemachinePackage.STATE__TRANSITIONS); |
| } |
| return transitions; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) |
| { |
| switch (featureID) |
| { |
| case StatemachinePackage.STATE__TRANSITIONS: |
| return ((InternalEList<?>)getTransitions()).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 StatemachinePackage.STATE__NAME: |
| return getName(); |
| case StatemachinePackage.STATE__ACTIONS: |
| return getActions(); |
| case StatemachinePackage.STATE__TRANSITIONS: |
| return getTransitions(); |
| } |
| 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 StatemachinePackage.STATE__NAME: |
| setName((String)newValue); |
| return; |
| case StatemachinePackage.STATE__ACTIONS: |
| getActions().clear(); |
| getActions().addAll((Collection<? extends Command>)newValue); |
| return; |
| case StatemachinePackage.STATE__TRANSITIONS: |
| getTransitions().clear(); |
| getTransitions().addAll((Collection<? extends Transition>)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) |
| { |
| switch (featureID) |
| { |
| case StatemachinePackage.STATE__NAME: |
| setName(NAME_EDEFAULT); |
| return; |
| case StatemachinePackage.STATE__ACTIONS: |
| getActions().clear(); |
| return; |
| case StatemachinePackage.STATE__TRANSITIONS: |
| getTransitions().clear(); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) |
| { |
| switch (featureID) |
| { |
| case StatemachinePackage.STATE__NAME: |
| return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); |
| case StatemachinePackage.STATE__ACTIONS: |
| return actions != null && !actions.isEmpty(); |
| case StatemachinePackage.STATE__TRANSITIONS: |
| return transitions != null && !transitions.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(" (name: "); |
| result.append(name); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| } //StateImpl |