Tune up action generics
- change so that pass TestEntryAction instead of its super interface Action<TestStates, TestEvents>. Doesn't really matter but makes it much prettier from user point of view.
This commit is contained in:
@@ -77,12 +77,12 @@ public class StateMachineStates<S, E> {
|
||||
public static class StateData<S, E> {
|
||||
private S state;
|
||||
private Collection<E> deferred;
|
||||
private Collection<Action<S, E>> entryActions;
|
||||
private Collection<Action<S, E>> exitActions;
|
||||
private Collection<? extends Action<S, E>> entryActions;
|
||||
private Collection<? extends Action<S, E>> exitActions;
|
||||
public StateData(S state, Collection<E> deferred) {
|
||||
this(state, deferred, null, null);
|
||||
}
|
||||
public StateData(S state, Collection<E> deferred, Collection<Action<S, E>> entryActions, Collection<Action<S, E>> exitActions) {
|
||||
public StateData(S state, Collection<E> deferred, Collection<? extends Action<S, E>> entryActions, Collection<? extends Action<S, E>> exitActions) {
|
||||
this.state = state;
|
||||
this.deferred = deferred;
|
||||
this.entryActions = entryActions;
|
||||
@@ -97,10 +97,10 @@ public class StateMachineStates<S, E> {
|
||||
public Collection<E> getDeferred() {
|
||||
return deferred;
|
||||
}
|
||||
public Collection<Action<S, E>> getEntryActions() {
|
||||
public Collection<? extends Action<S, E>> getEntryActions() {
|
||||
return entryActions;
|
||||
}
|
||||
public Collection<Action<S, E>> getExitActions() {
|
||||
public Collection<? extends Action<S, E>> getExitActions() {
|
||||
return exitActions;
|
||||
}
|
||||
@Override
|
||||
|
||||
@@ -68,7 +68,8 @@ public class DefaultStateConfigurer<S, E>
|
||||
}
|
||||
|
||||
@Override
|
||||
public StateConfigurer<S, E> state(S state, Collection<Action<S, E>> entryActions, Collection<Action<S, E>> exitActions) {
|
||||
public StateConfigurer<S, E> state(S state, Collection<? extends Action<S, E>> entryActions,
|
||||
Collection<? extends Action<S, E>> exitActions) {
|
||||
states.add(new StateData<S, E>(state, null, entryActions, exitActions));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -34,8 +34,8 @@ public class DefaultSubStateConfigurer<S, E>
|
||||
private final Object parent;
|
||||
|
||||
private S initial;
|
||||
private Collection<Action<S, E>> entryActions;
|
||||
private Collection<Action<S, E>> exitActions;
|
||||
private Collection<? extends Action<S, E>> entryActions;
|
||||
private Collection<? extends Action<S, E>> exitActions;
|
||||
|
||||
private final Collection<StateData<S, E>> states = new ArrayList<StateData<S, E>>();
|
||||
|
||||
@@ -62,13 +62,13 @@ public class DefaultSubStateConfigurer<S, E>
|
||||
}
|
||||
|
||||
@Override
|
||||
public SubStateConfigurer<S, E> entry(Collection<Action<S, E>> entryActions) {
|
||||
public SubStateConfigurer<S, E> entry(Collection<? extends Action<S, E>> entryActions) {
|
||||
this.entryActions = entryActions;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SubStateConfigurer<S, E> exit(Collection<Action<S, E>> exitActions) {
|
||||
public SubStateConfigurer<S, E> exit(Collection<? extends Action<S, E>> exitActions) {
|
||||
this.exitActions = exitActions;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,8 @@ public interface StateConfigurer<S, E> extends
|
||||
|
||||
StateConfigurer<S, E> state(S state);
|
||||
|
||||
StateConfigurer<S, E> state(S state, Collection<Action<S, E>> entryActions, Collection<Action<S, E>> exitActions);
|
||||
StateConfigurer<S, E> state(S state, Collection<? extends Action<S, E>> entryActions,
|
||||
Collection<? extends Action<S, E>> exitActions);
|
||||
|
||||
StateConfigurer<S, E> state(S state, E... deferred);
|
||||
|
||||
|
||||
@@ -26,8 +26,8 @@ public interface SubStateConfigurer<S, E> extends
|
||||
|
||||
SubStateConfigurer<S, E> initial(S initial);
|
||||
|
||||
SubStateConfigurer<S, E> entry(Collection<Action<S, E>> entryActions);
|
||||
SubStateConfigurer<S, E> entry(Collection<? extends Action<S, E>> entryActions);
|
||||
|
||||
SubStateConfigurer<S, E> exit(Collection<Action<S, E>> exitActions);
|
||||
SubStateConfigurer<S, E> exit(Collection<? extends Action<S, E>> exitActions);
|
||||
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public abstract class AbstractSimpleState<S, E> extends AbstractState<S, E> {
|
||||
* @param entryActions the entry actions
|
||||
* @param exitActions the exit actions
|
||||
*/
|
||||
public AbstractSimpleState(S id, Collection<E> deferred, Collection<Action<S, E>> entryActions, Collection<Action<S, E>> exitActions) {
|
||||
public AbstractSimpleState(S id, Collection<E> deferred, Collection<? extends Action<S, E>> entryActions, Collection<? extends Action<S, E>> exitActions) {
|
||||
this(id, deferred, entryActions, exitActions, null);
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ public abstract class AbstractSimpleState<S, E> extends AbstractState<S, E> {
|
||||
* @param pseudoState the pseudo state
|
||||
* @param regions the regions
|
||||
*/
|
||||
public AbstractSimpleState(S id, Collection<E> deferred, Collection<Action<S, E>> entryActions, Collection<Action<S, E>> exitActions,
|
||||
public AbstractSimpleState(S id, Collection<E> deferred, Collection<? extends Action<S, E>> entryActions, Collection<? extends Action<S, E>> exitActions,
|
||||
PseudoState pseudoState, Collection<Region<S, E>> regions) {
|
||||
super(id, deferred, entryActions, exitActions, pseudoState, regions);
|
||||
this.ids = new ArrayList<S>();
|
||||
@@ -103,7 +103,7 @@ public abstract class AbstractSimpleState<S, E> extends AbstractState<S, E> {
|
||||
* @param pseudoState the pseudo state
|
||||
* @param submachine the submachine
|
||||
*/
|
||||
public AbstractSimpleState(S id, Collection<E> deferred, Collection<Action<S, E>> entryActions, Collection<Action<S, E>> exitActions,
|
||||
public AbstractSimpleState(S id, Collection<E> deferred, Collection<? extends Action<S, E>> entryActions, Collection<? extends Action<S, E>> exitActions,
|
||||
PseudoState pseudoState, StateMachine<S, E> submachine) {
|
||||
super(id, deferred, entryActions, exitActions, pseudoState, submachine);
|
||||
this.ids = new ArrayList<S>();
|
||||
@@ -119,7 +119,7 @@ public abstract class AbstractSimpleState<S, E> extends AbstractState<S, E> {
|
||||
* @param exitActions the exit actions
|
||||
* @param pseudoState the pseudo state
|
||||
*/
|
||||
public AbstractSimpleState(S id, Collection<E> deferred, Collection<Action<S, E>> entryActions, Collection<Action<S, E>> exitActions,
|
||||
public AbstractSimpleState(S id, Collection<E> deferred, Collection<? extends Action<S, E>> entryActions, Collection<? extends Action<S, E>> exitActions,
|
||||
PseudoState pseudoState) {
|
||||
super(id, deferred, entryActions, exitActions, pseudoState);
|
||||
this.ids = new ArrayList<S>();
|
||||
|
||||
@@ -37,8 +37,8 @@ public abstract class AbstractState<S, E> implements State<S, E> {
|
||||
private final S id;
|
||||
private final PseudoState pseudoState;
|
||||
private final Collection<E> deferred;
|
||||
private final Collection<Action<S, E>> entryActions;
|
||||
private final Collection<Action<S, E>> exitActions;
|
||||
private final Collection<? extends Action<S, E>> entryActions;
|
||||
private final Collection<? extends Action<S, E>> exitActions;
|
||||
private final Collection<Region<S, E>> regions = new ArrayList<Region<S, E>>();
|
||||
private final StateMachine<S, E> submachine;
|
||||
|
||||
@@ -70,7 +70,7 @@ public abstract class AbstractState<S, E> implements State<S, E> {
|
||||
* @param entryActions the entry actions
|
||||
* @param exitActions the exit actions
|
||||
*/
|
||||
public AbstractState(S id, Collection<E> deferred, Collection<Action<S, E>> entryActions, Collection<Action<S, E>> exitActions) {
|
||||
public AbstractState(S id, Collection<E> deferred, Collection<? extends Action<S, E>> entryActions, Collection<? extends Action<S, E>> exitActions) {
|
||||
this(id, deferred, entryActions, exitActions, null);
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ public abstract class AbstractState<S, E> implements State<S, E> {
|
||||
* @param exitActions the exit actions
|
||||
* @param pseudoState the pseudo state
|
||||
*/
|
||||
public AbstractState(S id, Collection<E> deferred, Collection<Action<S, E>> entryActions, Collection<Action<S, E>> exitActions,
|
||||
public AbstractState(S id, Collection<E> deferred, Collection<? extends Action<S, E>> entryActions, Collection<? extends Action<S, E>> exitActions,
|
||||
PseudoState pseudoState) {
|
||||
this(id, deferred, entryActions, exitActions, pseudoState, null, null);
|
||||
}
|
||||
@@ -98,7 +98,7 @@ public abstract class AbstractState<S, E> implements State<S, E> {
|
||||
* @param pseudoState the pseudo state
|
||||
* @param submachine the submachine
|
||||
*/
|
||||
public AbstractState(S id, Collection<E> deferred, Collection<Action<S, E>> entryActions, Collection<Action<S, E>> exitActions,
|
||||
public AbstractState(S id, Collection<E> deferred, Collection<? extends Action<S, E>> entryActions, Collection<? extends Action<S, E>> exitActions,
|
||||
PseudoState pseudoState, StateMachine<S, E> submachine) {
|
||||
this(id, deferred, entryActions, exitActions, pseudoState, null, submachine);
|
||||
}
|
||||
@@ -113,7 +113,7 @@ public abstract class AbstractState<S, E> implements State<S, E> {
|
||||
* @param pseudoState the pseudo state
|
||||
* @param regions the regions
|
||||
*/
|
||||
public AbstractState(S id, Collection<E> deferred, Collection<Action<S, E>> entryActions, Collection<Action<S, E>> exitActions,
|
||||
public AbstractState(S id, Collection<E> deferred, Collection<? extends Action<S, E>> entryActions, Collection<? extends Action<S, E>> exitActions,
|
||||
PseudoState pseudoState, Collection<Region<S, E>> regions) {
|
||||
this(id, deferred, entryActions, exitActions, pseudoState, regions, null);
|
||||
}
|
||||
@@ -129,7 +129,7 @@ public abstract class AbstractState<S, E> implements State<S, E> {
|
||||
* @param regions the regions
|
||||
* @param submachine the submachine
|
||||
*/
|
||||
private AbstractState(S id, Collection<E> deferred, Collection<Action<S, E>> entryActions, Collection<Action<S, E>> exitActions,
|
||||
private AbstractState(S id, Collection<E> deferred, Collection<? extends Action<S, E>> entryActions, Collection<? extends Action<S, E>> exitActions,
|
||||
PseudoState pseudoState, Collection<Region<S, E>> regions, StateMachine<S, E> submachine) {
|
||||
this.id = id;
|
||||
this.deferred = deferred;
|
||||
@@ -174,12 +174,12 @@ public abstract class AbstractState<S, E> implements State<S, E> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Action<S, E>> getEntryActions() {
|
||||
public Collection<? extends Action<S, E>> getEntryActions() {
|
||||
return entryActions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Action<S, E>> getExitActions() {
|
||||
public Collection<? extends Action<S, E>> getExitActions() {
|
||||
return exitActions;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.springframework.statemachine.region.Region;
|
||||
|
||||
/**
|
||||
* A {@link State} implementation where state and event is enum based.
|
||||
*
|
||||
*
|
||||
* @author Janne Valkealahti
|
||||
*
|
||||
* @param <S> the type of state
|
||||
@@ -69,7 +69,7 @@ public class EnumState<S extends Enum<S>, E extends Enum<E>> extends AbstractSim
|
||||
* @param entryActions the entry actions
|
||||
* @param exitActions the exit actions
|
||||
*/
|
||||
public EnumState(S id, Collection<E> deferred, Collection<Action<S, E>> entryActions, Collection<Action<S, E>> exitActions) {
|
||||
public EnumState(S id, Collection<E> deferred, Collection<? extends Action<S, E>> entryActions, Collection<? extends Action<S, E>> exitActions) {
|
||||
super(id, deferred, entryActions, exitActions);
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ public class EnumState<S extends Enum<S>, E extends Enum<E>> extends AbstractSim
|
||||
* @param exitActions the exit actions
|
||||
* @param pseudoState the pseudo state
|
||||
*/
|
||||
public EnumState(S id, Collection<E> deferred, Collection<Action<S, E>> entryActions, Collection<Action<S, E>> exitActions,
|
||||
public EnumState(S id, Collection<E> deferred, Collection<? extends Action<S, E>> entryActions, Collection<? extends Action<S, E>> exitActions,
|
||||
PseudoState pseudoState) {
|
||||
super(id, deferred, entryActions, exitActions, pseudoState);
|
||||
}
|
||||
@@ -97,7 +97,7 @@ public class EnumState<S extends Enum<S>, E extends Enum<E>> extends AbstractSim
|
||||
* @param pseudoState the pseudo state
|
||||
* @param regions the regions
|
||||
*/
|
||||
public EnumState(S id, Collection<E> deferred, Collection<Action<S, E>> entryActions, Collection<Action<S, E>> exitActions,
|
||||
public EnumState(S id, Collection<E> deferred, Collection<? extends Action<S, E>> entryActions, Collection<? extends Action<S, E>> exitActions,
|
||||
PseudoState pseudoState, Collection<Region<S, E>> regions) {
|
||||
super(id, deferred, entryActions, exitActions, pseudoState, regions);
|
||||
}
|
||||
@@ -112,31 +112,31 @@ public class EnumState<S extends Enum<S>, E extends Enum<E>> extends AbstractSim
|
||||
* @param pseudoState the pseudo state
|
||||
* @param submachine the submachine
|
||||
*/
|
||||
public EnumState(S id, Collection<E> deferred, Collection<Action<S, E>> entryActions, Collection<Action<S, E>> exitActions,
|
||||
public EnumState(S id, Collection<E> deferred, Collection<? extends Action<S, E>> entryActions, Collection<? extends Action<S, E>> exitActions,
|
||||
PseudoState pseudoState, StateMachine<S, E> submachine) {
|
||||
super(id, deferred, entryActions, exitActions, pseudoState, submachine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit(E event, StateContext<S, E> context) {
|
||||
Collection<Action<S, E>> actions = getExitActions();
|
||||
Collection<? extends Action<S, E>> actions = getExitActions();
|
||||
if (actions != null) {
|
||||
for (Action<S, E> action : actions) {
|
||||
action.execute(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void entry(E event, StateContext<S, E> context) {
|
||||
Collection<Action<S, E>> actions = getEntryActions();
|
||||
Collection<? extends Action<S, E>> actions = getEntryActions();
|
||||
if (actions != null) {
|
||||
for (Action<S, E> action : actions) {
|
||||
action.execute(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EnumState [getIds()=" + getIds() + ", getClass()=" + getClass() + ", hashCode()=" + hashCode()
|
||||
|
||||
@@ -108,7 +108,7 @@ public class RegionState<S, E> extends AbstractState<S, E> {
|
||||
region.getState().exit(event, context);
|
||||
region.stop();
|
||||
}
|
||||
Collection<Action<S, E>> actions = getExitActions();
|
||||
Collection<? extends Action<S, E>> actions = getExitActions();
|
||||
if (actions != null) {
|
||||
for (Action<S, E> action : actions) {
|
||||
action.execute(context);
|
||||
@@ -118,7 +118,7 @@ public class RegionState<S, E> extends AbstractState<S, E> {
|
||||
|
||||
@Override
|
||||
public void entry(E event, StateContext<S, E> context) {
|
||||
Collection<Action<S, E>> actions = getEntryActions();
|
||||
Collection<? extends Action<S, E>> actions = getEntryActions();
|
||||
if (actions != null) {
|
||||
for (Action<S, E> action : actions) {
|
||||
action.execute(context);
|
||||
|
||||
@@ -90,14 +90,14 @@ public interface State<S, E> {
|
||||
*
|
||||
* @return the state entry actions
|
||||
*/
|
||||
Collection<Action<S, E>> getEntryActions();
|
||||
Collection<? extends Action<S, E>> getEntryActions();
|
||||
|
||||
/**
|
||||
* Gets {@link Action}s executed exiting from this state.
|
||||
*
|
||||
* @return the state exit actions
|
||||
*/
|
||||
Collection<Action<S, E>> getExitActions();
|
||||
Collection<? extends Action<S, E>> getExitActions();
|
||||
|
||||
/**
|
||||
* Checks if state is a simple state. A simple state does not have any
|
||||
|
||||
@@ -84,7 +84,7 @@ public class StateMachineState<S, E> extends AbstractState<S, E> {
|
||||
* @param exitActions the exit actions
|
||||
* @param pseudoState the pseudo state
|
||||
*/
|
||||
public StateMachineState(S id, StateMachine<S, E> submachine, Collection<E> deferred, Collection<Action<S, E>> entryActions, Collection<Action<S, E>> exitActions,
|
||||
public StateMachineState(S id, StateMachine<S, E> submachine, Collection<E> deferred, Collection<? extends Action<S, E>> entryActions, Collection<? extends Action<S, E>> exitActions,
|
||||
PseudoState pseudoState) {
|
||||
super(id, deferred, entryActions, exitActions, pseudoState, submachine);
|
||||
this.ids = new ArrayList<S>();
|
||||
@@ -100,7 +100,7 @@ public class StateMachineState<S, E> extends AbstractState<S, E> {
|
||||
* @param entryActions the entry actions
|
||||
* @param exitActions the exit actions
|
||||
*/
|
||||
public StateMachineState(S id, StateMachine<S, E> submachine, Collection<E> deferred, Collection<Action<S, E>> entryActions, Collection<Action<S, E>> exitActions) {
|
||||
public StateMachineState(S id, StateMachine<S, E> submachine, Collection<E> deferred, Collection<? extends Action<S, E>> entryActions, Collection<? extends Action<S, E>> exitActions) {
|
||||
super(id, deferred, entryActions, exitActions, null, submachine);
|
||||
this.ids = new ArrayList<S>();
|
||||
this.ids.add(id);
|
||||
@@ -121,7 +121,7 @@ public class StateMachineState<S, E> extends AbstractState<S, E> {
|
||||
public void exit(E event, StateContext<S, E> context) {
|
||||
getSubmachine().getState().exit(event, context);
|
||||
getSubmachine().stop();
|
||||
Collection<Action<S, E>> actions = getExitActions();
|
||||
Collection<? extends Action<S, E>> actions = getExitActions();
|
||||
if (actions != null && !isLocal(context)) {
|
||||
for (Action<S, E> action : actions) {
|
||||
action.execute(context);
|
||||
@@ -131,7 +131,7 @@ public class StateMachineState<S, E> extends AbstractState<S, E> {
|
||||
|
||||
@Override
|
||||
public void entry(E event, StateContext<S, E> context) {
|
||||
Collection<Action<S, E>> actions = getEntryActions();
|
||||
Collection<? extends Action<S, E>> actions = getEntryActions();
|
||||
if (actions != null && !isLocal(context)) {
|
||||
for (Action<S, E> action : actions) {
|
||||
action.execute(context);
|
||||
|
||||
@@ -436,91 +436,4 @@ public class SubStateMachineTests extends AbstractStateMachineTests {
|
||||
|
||||
}
|
||||
|
||||
// @Configuration
|
||||
// @EnableStateMachine(name = "submachine11Config")
|
||||
// public static class Config1 extends EnumStateMachineConfigurerAdapter<TestStates, TestEvents> {
|
||||
//
|
||||
// @Override
|
||||
// public void configure(StateMachineStateConfigurer<TestStates, TestEvents> states) throws Exception {
|
||||
// states
|
||||
// .withStates()
|
||||
// .initial(TestStates.S111)
|
||||
// .state(TestStates.S111, Arrays.asList(testEntryAction()), Arrays.asList(testExitAction()));
|
||||
// }
|
||||
//
|
||||
// @Bean(name = "entryActionS111")
|
||||
// public Action<TestStates, TestEvents> testEntryAction() {
|
||||
// return new TestEntryAction();
|
||||
// }
|
||||
//
|
||||
// @Bean(name = "exitActionS111")
|
||||
// public Action<TestStates, TestEvents> testExitAction() {
|
||||
// return new TestExitAction();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
// @Configuration
|
||||
// @EnableStateMachine(name = "submachine1Config")
|
||||
// public static class Config2 extends EnumStateMachineConfigurerAdapter<TestStates, TestEvents> {
|
||||
//
|
||||
// @Autowired
|
||||
// @Qualifier("submachine11Config")
|
||||
// public StateMachine<TestStates,TestEvents> submachine;
|
||||
//
|
||||
// @Override
|
||||
// public void configure(StateMachineStateConfigurer<TestStates, TestEvents> states) throws Exception {
|
||||
// states
|
||||
// .withSubmachine()
|
||||
// .submachine(submachine);
|
||||
// }
|
||||
//
|
||||
// @Bean(name = "entryActionS11")
|
||||
// public Action<TestStates, TestEvents> testEntryAction() {
|
||||
// return new TestEntryAction();
|
||||
// }
|
||||
//
|
||||
// @Bean(name = "exitActionS11")
|
||||
// public Action<TestStates, TestEvents> testExitAction() {
|
||||
// return new TestExitAction();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
// @Configuration
|
||||
// @EnableStateMachine(name = "submachineConfig")
|
||||
// public static class Config3 extends EnumStateMachineConfigurerAdapter<TestStates, TestEvents> {
|
||||
//
|
||||
// @Autowired
|
||||
// @Qualifier("submachine1Config")
|
||||
// public StateMachine<TestStates,TestEvents> submachine;
|
||||
//
|
||||
// @Override
|
||||
// public void configure(StateMachineStateConfigurer<TestStates, TestEvents> states) throws Exception {
|
||||
// states
|
||||
// .withSubmachine()
|
||||
// .submachine(submachine);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void configure(StateMachineTransitionConfigurer<TestStates, TestEvents> transitions) throws Exception {
|
||||
// transitions
|
||||
// .withExternal()
|
||||
// .source(TestStates.S111)
|
||||
// .target(TestStates.S1)
|
||||
// .event(TestEvents.E1);
|
||||
// }
|
||||
//
|
||||
// @Bean(name = "entryActionS1")
|
||||
// public TestEntryAction testEntryAction() {
|
||||
// return new TestEntryAction();
|
||||
// }
|
||||
//
|
||||
// @Bean(name = "exitActionS1")
|
||||
// public TestExitAction testExitAction() {
|
||||
// return new TestExitAction();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@@ -19,6 +19,9 @@ import static org.hamcrest.Matchers.notNullValue;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import org.junit.Test;
|
||||
@@ -31,6 +34,7 @@ import org.springframework.statemachine.AbstractStateMachineTests;
|
||||
import org.springframework.statemachine.EnumStateMachine;
|
||||
import org.springframework.statemachine.StateMachineSystemConstants;
|
||||
import org.springframework.statemachine.TestUtils;
|
||||
import org.springframework.statemachine.action.Action;
|
||||
import org.springframework.statemachine.config.builders.StateMachineStateConfigurer;
|
||||
import org.springframework.statemachine.config.builders.StateMachineTransitionConfigurer;
|
||||
|
||||
@@ -195,5 +199,53 @@ public class ConfigurationTests extends AbstractStateMachineTests {
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EnableStateMachine
|
||||
public static class Config5 extends EnumStateMachineConfigurerAdapter<TestStates, TestEvents> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void configure(StateMachineStateConfigurer<TestStates, TestEvents> states) throws Exception {
|
||||
TestEntryAction action1 = action1();
|
||||
Collection<TestEntryAction> actions1 = new ArrayList<TestEntryAction>();
|
||||
actions1.add(action1);
|
||||
Collection<Action<TestStates, TestEvents>> actions3 = new ArrayList<Action<TestStates,TestEvents>>();
|
||||
actions3.add(action3());
|
||||
states
|
||||
.withSubStates(TestStates.S11, null)
|
||||
.entry(actions1)
|
||||
.exit(Arrays.asList(action2()))
|
||||
.and()
|
||||
.withStates(TestStates.S11)
|
||||
.initial(TestStates.S111)
|
||||
.state(TestStates.S111, actions3, Arrays.asList(action4()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure(StateMachineTransitionConfigurer<TestStates, TestEvents> transitions) throws Exception {
|
||||
transitions
|
||||
.withExternal()
|
||||
.source(TestStates.S111)
|
||||
.target(TestStates.S1)
|
||||
.event(TestEvents.E1);
|
||||
}
|
||||
|
||||
public TestEntryAction action1() {
|
||||
return new TestEntryAction();
|
||||
}
|
||||
|
||||
public Action<TestStates, TestEvents> action2() {
|
||||
return new TestExitAction();
|
||||
}
|
||||
|
||||
public Action<TestStates, TestEvents> action3() {
|
||||
return new TestEntryAction();
|
||||
}
|
||||
|
||||
public TestExitAction action4() {
|
||||
return new TestExitAction();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user