public class RunnableChainer extends Chainer<Runnable,ThrowingRunnable,RunnableChainer> implements ThrowingRunnable
Chainer.InstantiationException| Constructor and Description |
|---|
RunnableChainer(ThrowingRunnable throwing) |
| Modifier and Type | Method and Description |
|---|---|
void |
doRun() |
Runnable |
fallbackTo(Runnable fallback)
Fall back to a non throwing instance if this instance fails
|
Runnable |
orDoNothing() |
<E extends RuntimeException> |
orThrow(Class<E> exclass)
Rethrow the exception using a custom (unchecked!) exception class if this
throwing instance fails
|
RunnableChainer |
orTryWith(ThrowingRunnable other)
Try with another throwing instance if the first instance fails
|
Runnable |
sneakyThrow()
Sneaky throw of the exception thrown by the instance
|
doSneakyThrow, rethrowclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitrunpublic RunnableChainer(ThrowingRunnable throwing)
public void doRun()
throws Throwable
doRun in interface ThrowingRunnableThrowablepublic RunnableChainer orTryWith(ThrowingRunnable other)
ChainerorTryWith in class Chainer<Runnable,ThrowingRunnable,RunnableChainer>other - the other throwing instancepublic <E extends RuntimeException> ThrowingRunnable orThrow(Class<E> exclass)
ChainerYour custom exception class must have a constructor
accepting a single Throwable as an argument.
The original exception thrown will be the cause of the generated exception.
All instances of Error or RuntimeException thrown by
the instance are thrown as is.
orThrow in class Chainer<Runnable,ThrowingRunnable,RunnableChainer>E - type parameter of the exception classexclass - the exception classpublic Runnable fallbackTo(Runnable fallback)
ChainerfallbackTo in class Chainer<Runnable,ThrowingRunnable,RunnableChainer>fallback - the fallback instancepublic Runnable sneakyThrow()
ChainerThis code was inspited by the Lombok project.
sneakyThrow in class Chainer<Runnable,ThrowingRunnable,RunnableChainer>public Runnable orDoNothing()