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