public class BiConsumerChainer<T,U> extends Chainer<BiConsumer<T,U>,ThrowingBiConsumer<T,U>,BiConsumerChainer<T,U>> implements ThrowingBiConsumer<T,U>
Chainer.InstantiationException| Constructor and Description |
|---|
BiConsumerChainer(ThrowingBiConsumer<T,U> throwing) |
| Modifier and Type | Method and Description |
|---|---|
void |
doAccept(T t,
U u) |
BiConsumer<T,U> |
fallbackTo(BiConsumer<T,U> fallback)
Fall back to a non throwing instance if this instance fails
|
BiConsumer<T,U> |
orDoNothing() |
<E extends RuntimeException> |
orThrow(Class<E> exclass)
Rethrow the exception using a custom (unchecked!) exception class if this
throwing instance fails
|
BiConsumerChainer<T,U> |
orTryWith(ThrowingBiConsumer<T,U> other)
Try with another throwing instance if the first instance fails
|
BiConsumer<T,U> |
sneakyThrow()
Sneaky throw of the exception thrown by the instance
|
doSneakyThrow, rethrowclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitacceptandThenpublic BiConsumerChainer(ThrowingBiConsumer<T,U> throwing)
public void doAccept(T t, U u) throws Throwable
doAccept in interface ThrowingBiConsumer<T,U>Throwablepublic BiConsumerChainer<T,U> orTryWith(ThrowingBiConsumer<T,U> other)
ChainerorTryWith in class Chainer<BiConsumer<T,U>,ThrowingBiConsumer<T,U>,BiConsumerChainer<T,U>>other - the other throwing instancepublic <E extends RuntimeException> ThrowingBiConsumer<T,U> 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<BiConsumer<T,U>,ThrowingBiConsumer<T,U>,BiConsumerChainer<T,U>>E - type parameter of the exception classexclass - the exception classpublic BiConsumer<T,U> fallbackTo(BiConsumer<T,U> fallback)
ChainerfallbackTo in class Chainer<BiConsumer<T,U>,ThrowingBiConsumer<T,U>,BiConsumerChainer<T,U>>fallback - the fallback instancepublic BiConsumer<T,U> sneakyThrow()
ChainerThis code was inspited by the Lombok project.
sneakyThrow in class Chainer<BiConsumer<T,U>,ThrowingBiConsumer<T,U>,BiConsumerChainer<T,U>>public BiConsumer<T,U> orDoNothing()