/** * <copyright> * </copyright> * * $Id$ */ package net.sf.orcc.df.impl; import java.util.Collection; import net.sf.orcc.df.Action; import net.sf.orcc.df.DfPackage; import net.sf.orcc.df.State; import net.sf.orcc.df.Transition; import net.sf.orcc.graph.impl.EdgeImpl; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.util.EObjectResolvingEList; /** * <!-- begin-user-doc --> An implementation of the model object ' * <em><b>Transition</b></em>'. <!-- end-user-doc --> * <p> * The following features are implemented: * <ul> * <li>{@link net.sf.orcc.df.impl.TransitionImpl#getActions <em>Actions</em>}</li> * </ul> * </p> * * @generated */ public class TransitionImpl extends EdgeImpl implements Transition { /** * The cached value of the '{@link #getActions() <em>Actions</em>}' reference list. * <!-- begin-user-doc --> <!-- end-user-doc --> * @see #getActions() * @generated * @ordered */ protected EList<Action> actions; /** * <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ protected TransitionImpl() { super(); } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ @Override public Object eGet(int featureID, boolean resolve, boolean coreType) { switch (featureID) { case DfPackage.TRANSITION__ACTIONS: return getActions(); } return super.eGet(featureID, resolve, coreType); } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case DfPackage.TRANSITION__ACTIONS: return actions != null && !actions.isEmpty(); } return super.eIsSet(featureID); } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ @SuppressWarnings("unchecked") @Override public void eSet(int featureID, Object newValue) { switch (featureID) { case DfPackage.TRANSITION__ACTIONS: getActions().clear(); getActions().addAll((Collection<? extends Action>) newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return DfPackage.Literals.TRANSITION; } @Override public Action getAction() { if (getActions().isEmpty()) { return null; } return getActions().get(0); } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ public EList<Action> getActions() { if (actions == null) { actions = new EObjectResolvingEList<Action>(Action.class, this, DfPackage.TRANSITION__ACTIONS); } return actions; } @Override public State getSource() { return (State) super.getSource(); } @Override public State getTarget() { return (State) super.getTarget(); } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case DfPackage.TRANSITION__ACTIONS: getActions().clear(); return; } super.eUnset(featureID); } @Override public String toString() { StringBuilder builder = new StringBuilder(); if (getSource() != null) { builder.append(getSource().getName()); } builder.append(" ("); if (getAction() != null) { builder.append(getAction().getName()); } builder.append(") --> "); if (getSource() != null) { builder.append(getTarget().getName()); } return builder.toString(); } } // TransitionImpl