public class FunctionChainer<T,R> extends Chainer<Function<T,R>,ThrowingFunction<T,R>,FunctionChainer<T,R>> implements ThrowingFunction<T,R>
Chainer.InstantiationException| Constructor and Description |
|---|
FunctionChainer(ThrowingFunction<T,R> function) |
| Modifier and Type | Method and Description |
|---|---|
R |
doApply(T t) |
Function<T,R> |
fallbackTo(Function<T,R> fallback)
Fall back to a non throwing instance if this instance fails
|
Function<T,R> |
orReturn(R retval) |
<E extends RuntimeException> |
orThrow(Class<E> exclass)
Rethrow the exception using a custom (unchecked!) exception class if this
throwing instance fails
|
FunctionChainer<T,R> |
orTryWith(ThrowingFunction<T,R> other)
Try with another throwing instance if the first instance fails
|
Function<T,R> |
sneakyThrow()
Sneaky throw of the exception thrown by the instance
|
doSneakyThrow, rethrowclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitapplypublic FunctionChainer(ThrowingFunction<T,R> function)
public R doApply(T t) throws Throwable
doApply in interface ThrowingFunction<T,R>Throwablepublic FunctionChainer<T,R> orTryWith(ThrowingFunction<T,R> other)
Chainerpublic <E extends RuntimeException> ThrowingFunction<T,R> 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.
public Function<T,R> fallbackTo(Function<T,R> fallback)
ChainerfallbackTo in class Chainer<Function<T,R>,ThrowingFunction<T,R>,FunctionChainer<T,R>>fallback - the fallback instancepublic Function<T,R> sneakyThrow()
ChainerThis code was inspited by the Lombok project.
sneakyThrow in class Chainer<Function<T,R>,ThrowingFunction<T,R>,FunctionChainer<T,R>>