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