Interface Action<S>

  • Type Parameters:
    S - Type of the state object

    @API(status=MAINTAINED,
         since="1.0")
    public interface Action<S>
    An action class represents a state change that can be preformed on a stateful S. At runtime the execution of an action is regulated by a precondition.
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default boolean precondition​(S state)
      If this method returns false, the action will not be performed.
      S run​(S state)
      Perform an action on state S and return the same state (if it has state) or a new one representing the new state.
    • Method Detail

      • precondition

        default boolean precondition​(S state)
        If this method returns false, the action will not be performed.
        Parameters:
        state - the current state
        Returns:
        true if the precondition holds
      • run

        S run​(S state)
        Perform an action on state S and return the same state (if it has state) or a new one representing the new state.
        Parameters:
        state - the current state
        Returns:
        the new state, which may or may not be the same object