Package io.vavr

Interface CheckedRunnable

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

@FunctionalInterface public interface CheckedRunnable
A Runnable which may throw.
  • Method Summary

    Modifier and Type
    Method
    Description
    of(CheckedRunnable methodReference)
    Creates a CheckedRunnable.
    void
    run()
    Performs side-effects.
    default Runnable
    Returns an unchecked Runnable that will sneaky throw if an exceptions occurs when running the unit of work.
  • Method Details

    • of

      static CheckedRunnable of(CheckedRunnable methodReference)
      Creates a CheckedRunnable.
      
       // class Evil { static void sideEffect() { ... } }
       final CheckedRunnable checkedRunnable = CheckedRunnable.of(Evil::sideEffect);
       final Runnable runnable = checkedRunnable.unchecked();
      
       // may or may not perform a side-effect while not throwing
       runnable.run();
      
       // may or may not perform a side-effect while throwing
       runnable.run();
       
      Parameters:
      methodReference - (typically) a method reference, e.g. Type::method
      Returns:
      a new CheckedRunnable
      See Also:
    • run

      void run() throws Throwable
      Performs side-effects.
      Throws:
      Throwable - if an error occurs
    • unchecked

      default Runnable unchecked()
      Returns an unchecked Runnable that will sneaky throw if an exceptions occurs when running the unit of work.
      Returns:
      a new Runnable that throws a Throwable.