Interface Action<S>

  • Type Parameters:
    S - Type of the object to transform through an action
    All Known Subinterfaces:
    Action.Dependent<S>, Action.Independent<S>
    All Known Implementing Classes:
    Action.JustMutate, Action.JustTransform

    @API(status=EXPERIMENTAL,
         since="1.7.0")
    public interface Action<S>
    An action class represents a state transformation that can be performed on an object of type S. Those objects can be mutable, which means that the state changing method will return the same object, or immutable, which requires the method to return another object that represents the transformed state.

    Do not implement this interface directly, but either Action.Dependent or Action.Independent. Only those can be used to create an arbitrary for a ActionChain.

    Mind that there is a another interface Action which looks similar but refers to jqwik's old and deprecated style of state-based property testing. The two interfaces CANNOT be used interchangeably.

    See Also:
    ActionChain, ActionChainArbitrary
    • Method Detail

      • when

        static <T> ActionBuilder<T> when​(java.util.function.Predicate<T> precondition)
        Create an ActionBuilder with a precondition.
      • just

        static <T> Action.Independent<T> just​(java.lang.String description,
                                              Transformer<T> transformer)
        Convenience method to create an independent Action with a description and a constant transformer
      • precondition

        default boolean precondition​(S state)
        If this method returns false, the action will not be performed.

        Implementing this method will make the chain of actions harder to shrink.

        Parameters:
        state - the current state
        Returns:
        true if the precondition holds