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