Interface PredicateExt<T,E extends java.lang.Throwable>
-
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@PrimaryRequirement(updates=java.util.function.Predicate.class) @FunctionalInterface public interface PredicateExt<T,E extends java.lang.Throwable>
Changes for
PredicateWhy:
1. If a Predicate lambda throws a checked exceptions, the developer has to messily wrap it in a RuntimeException.
2. If Predicate.test throws a RuntimeException, the compiler will not warn the developer.
3. This class provides type-safe exceptions which is not currently possible with java.util.function classes.
To eliminate the need for this class:
1. Java should support default values for generic parameters.
2. Modifyjava.util.function.Predicate<T>toPredicate<T, E extends Throwable = Throwable>
Risk:
1. Maintains source compatibility because the E parameter can be omitted.
2. Maintains binary compatibility because generic types are erased.
3. Impact on code using Reflection APIs should be minimal.
-
-
Method Summary
Modifier and Type Method Description default PredicateExt<T,E>and(PredicateExt<? super T,E> other)static <T,E extends java.lang.Throwable>
PredicateExt<T,E>isEqual(java.lang.Object targetRef)default PredicateExt<T,E>negate()static <T,E extends java.lang.Throwable>
PredicateExt<T,E>not(PredicateExt<? super T,E> target)default PredicateExt<T,E>or(PredicateExt<? super T,E> other)booleantest(T t)
-
-
-
Method Detail
-
test
@Update boolean test(T t) throws E extends java.lang.Throwable
- Throws:
E extends java.lang.Throwable
-
and
@Update default PredicateExt<T,E> and(PredicateExt<? super T,E> other)
-
negate
@Update default PredicateExt<T,E> negate()
-
or
@Update default PredicateExt<T,E> or(PredicateExt<? super T,E> other)
-
isEqual
@Update static <T,E extends java.lang.Throwable> PredicateExt<T,E> isEqual(java.lang.Object targetRef)
-
not
@Update static <T,E extends java.lang.Throwable> PredicateExt<T,E> not(PredicateExt<? super T,E> target)
-
-