@FunctionalInterface public interface ThrowingRunnable extends Runnable
| Modifier and Type | Method and Description |
|---|---|
default Runnable |
fallbackTo(Runnable fallback)
Returns a
Runnable performing the given operation if this operation throws an exception. |
default Runnable |
fallbackTo(Runnable fallback,
Consumer<Exception> exceptionConsumer)
Returns a
Runnable performing the given operation if this operation throws an exception. |
default Runnable |
orDoNothing()
Returns a
Runnable performing no other operation if this operation throws an exception. |
default Runnable |
orDoNothing(Consumer<Exception> exceptionConsumer)
Returns a
Runnable performing no other operation if this operation throws an exception. |
default ThrowingRunnable |
orThrow(Class<? extends RuntimeException> exceptionClass)
Returns a
ThrowingRunnable throwing an exception of the given type if this operation throws an exception. |
default ThrowingRunnable |
orThrow(Class<? extends RuntimeException> exceptionClass,
String message)
Returns a
ThrowingRunnable throwing an exception of the given type if this operation throws an exception. |
default ThrowingRunnable |
orTryWith(ThrowingRunnable other)
Returns a
ThrowingRunnable performing the given operation if this operation throws an exception. |
default ThrowingRunnable |
orTryWith(ThrowingRunnable other,
Consumer<Exception> exceptionConsumer)
Returns a
ThrowingRunnable performing the given operation if this operation throws an exception. |
default void |
run()
Performs this operation.
|
void |
runThrowing()
Performs this operation.
|
default Runnable fallbackTo(Runnable fallback)
Runnable performing the given operation if this operation throws an exception.IllegalArgumentException - if fallback is nulldefault Runnable fallbackTo(Runnable fallback, Consumer<Exception> exceptionConsumer)
Runnable performing the given operation if this operation throws an exception.IllegalArgumentException - if fallback is nulldefault Runnable orDoNothing()
Runnable performing no other operation if this operation throws an exception.IllegalArgumentException - if fallback is nulldefault Runnable orDoNothing(Consumer<Exception> exceptionConsumer)
Runnable performing no other operation if this operation throws an exception.IllegalArgumentException - if fallback is nulldefault ThrowingRunnable orThrow(Class<? extends RuntimeException> exceptionClass)
ThrowingRunnable throwing an exception of the given type if this operation throws an exception.
The original exception thrown by this operation is the cause of the thrown exception.
The exception class must have a constructor accepting a single Throwable as an argument.
IllegalArgumentException - if exceptionClass is nulldefault ThrowingRunnable orThrow(Class<? extends RuntimeException> exceptionClass, String message)
ThrowingRunnable throwing an exception of the given type if this operation throws an exception.
The original exception thrown by this operation is the cause of the thrown exception.
The exception class must have a constructor accepting String and Throwable as arguments.
IllegalArgumentException - if exceptionClass is nulldefault ThrowingRunnable orTryWith(ThrowingRunnable other)
ThrowingRunnable performing the given operation if this operation throws an exception.IllegalArgumentException - if other is nulldefault ThrowingRunnable orTryWith(ThrowingRunnable other, Consumer<Exception> exceptionConsumer)
ThrowingRunnable performing the given operation if this operation throws an exception.IllegalArgumentException - if other is nulldefault void run()
UncheckedException.