Package ratpack.func

Interface Block

  • Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

    public interface Block
    A block of code.

    Similar to Runnable, but allows throwing of checked exceptions.

    • Method Detail

      • noop

        static Block noop()
      • throwException

        static Block throwException​(Throwable throwable)
        Returns an action that immediately throws the given exception.

        The exception is thrown via Exceptions.toException(Throwable)

        throwable - the throwable to immediately throw when the returned action is executed
        an action that immediately throws the given exception.
      • toRunnable

        default Runnable toRunnable()
        Converts this action to a runnable.

        Any thrown exceptions will be unchecked.

        a runnable
      • action

        default Action<Object> action()
        Creates an Action from this block, where the argument is ignored.
        an action that executes this block
      • map

        default <T> T map​(Function<? super Block,​? extends T> function)
        Maps a block onto a new object with the provided function.

        The block is not implicitly handled and the mapping function must call execute() if desired.

        Type Parameters:
        T - the return type
        function - the mapping function
        the mapped block