Class StateMachineFactory

java.lang.Object
org.apache.mina.statemachine.StateMachineFactory

public class StateMachineFactory extends Object
Creates StateMachines by reading State, Transition and Transitions (or equivalent) and SelfTransition annotations from one or more arbitrary objects.
  • Field Details

    • transitionAnnotation

      private final Class<? extends Annotation> transitionAnnotation
    • transitionsAnnotation

      private final Class<? extends Annotation> transitionsAnnotation
    • entrySelfTransitionsAnnotation

      private final Class<? extends Annotation> entrySelfTransitionsAnnotation
    • exitSelfTransitionsAnnotation

      private final Class<? extends Annotation> exitSelfTransitionsAnnotation
  • Constructor Details

  • Method Details

    • getInstance

      public static StateMachineFactory getInstance(Class<? extends Annotation> transitionAnnotation)
      Returns a new StateMachineFactory instance which creates StateMachines by reading the specified Transition equivalent annotation.
      Parameters:
      transitionAnnotation - the Transition equivalent annotation.
      Returns:
      the StateMachineFactory.
    • create

      public StateMachine create(Object handler)
      Creates a new StateMachine from the specified handler object and using a start state with id start.
      Parameters:
      handler - the object containing the annotations describing the state machine.
      Returns:
      the StateMachine object.
    • create

      public StateMachine create(String start, Object handler)
      Creates a new StateMachine from the specified handler object and using the State with the specified id as start state.
      Parameters:
      start - the id of the start State to use.
      handler - the object containing the annotations describing the state machine.
      Returns:
      the StateMachine object.
    • create

      public StateMachine create(Object handler, Object... handlers)
      Creates a new StateMachine from the specified handler objects and using a start state with id start.
      Parameters:
      handler - the first object containing the annotations describing the state machine.
      handlers - zero or more additional objects containing the annotations describing the state machine.
      Returns:
      the StateMachine object.
    • create

      public StateMachine create(String start, Object handler, Object... handlers)
      Creates a new StateMachine from the specified handler objects and using the State with the specified id as start state.
      Parameters:
      start - the id of the start State to use.
      handler - the first object containing the annotations describing the state machine.
      handlers - zero or more additional objects containing the annotations describing the state machine.
      Returns:
      the StateMachine object.
    • setupTransitions

      private static void setupTransitions(Class<? extends Annotation> transitionAnnotation, Class<? extends Annotation> transitionsAnnotation, Class<? extends Annotation> onEntrySelfTransitionAnnotation, Class<? extends Annotation> onExitSelfTransitionAnnotation, Map<String,State> states, List<Object> handlers)
    • setupSelfTransitions

      private static void setupSelfTransitions(Method m, Class<? extends Annotation> onEntrySelfTransitionAnnotation, Class<? extends Annotation> onExitSelfTransitionAnnotation, Map<String,State> states, Object handler)
    • setupTransitions

      private static void setupTransitions(Class<? extends Annotation> transitionAnnotation, Class<? extends Annotation> transitionsAnnotation, Class<? extends Annotation> onEntrySelfTransitionAnnotation, Class<? extends Annotation> onExitSelfTransitionAnnotation, Map<String,State> states, Object handler)
    • getFields

      static List<Field> getFields(Class<?> clazz)
    • createStates

      static State[] createStates(List<Field> fields)