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