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