com.github.markozajc.ef.bipredicate.except.EObjLongPredicate Maven / Gradle / Ivy
package com.github.markozajc.ef.bipredicate.except;
import static com.github.markozajc.ef.Utilities.asUnchecked;
import com.github.markozajc.ef.bipredicate.ObjLongPredicate;
/**
* Variant of {@link ObjLongPredicate} capable of throwing a generic
* {@link Throwable}.
*
* @author Marko Zajc
*
* @param
* the type of the first argument to the predicate
* @param
* {@link Throwable} type
*/
@FunctionalInterface
public interface EObjLongPredicate extends ObjLongPredicate {
@Override
default boolean test(T t, long p) {
try {
return testChecked(t, p);
} catch (Throwable e) { // NOSONAR can't catch generic exceptions
throw asUnchecked(e);
}
}
/**
* Same as {@link #test(Object, long)}, but throws a checked exception.
*
* @param t
* the first input argument
* @param p
* the second {@code long} input argument
*
* @return {@code true} if the input arguments match the predicate, otherwise
* {@code false}
*
* @throws E
* the defined exception type
*/
boolean testChecked(T t, long p) throws E;
}