Interface KiwiRunnables.ThrowingRunnable

Enclosing class:
KiwiRunnables
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 static interface KiwiRunnables.ThrowingRunnable
A variation on Runnable which allows exceptions to be thrown.

Note that since it has no relation to Runnable it can't be used in things like Java's concurrency classes that expect Runnable. However, you can use the provided conversion methods to convert into Runnable objects.

  • Method Details

    • run

      void run() throws Exception
      Does something that might throw a checked exception.
      Throws:
      Exception - if something went wrong
    • of

      Parameters:
      runnable - the Runnable to convert
      Returns:
      a new ThrowingRunnable that wraps the original Runnable
    • toRunnable

      default Runnable toRunnable()
      Converts this instance to a Runnable which catches any Exception that is thrown and wraps it in a RuntimeException.
      Returns:
      a new Runnable instance
    • toCatchingRunnable

      default org.kiwiproject.base.CatchingRunnable toCatchingRunnable()
      Converts this instance to a CatchingRunnable.
      Returns:
      a new CatchingRunnable instance
    • toCatchingRunnable2

      default CatchingRunnable2 toCatchingRunnable2()
      Converts this instance to a CatchingRunnable2.
      Returns:
      a new CatchingRunnable2 instance