Interface ThrowingBiPredicate<T,U,X extends Throwable>
-
- Type Parameters:
T- The type of the first argument to the predicate.U- The type of the second argument the predicate.X- The type of checked exception that can be thrown.
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface ThrowingBiPredicate<T,U,X extends Throwable>
Represents a predicate (boolean-valued function) of two arguments. This is a checked-exception throwing equivalent ofBiPredicate.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default ThrowingBiPredicate<T,U,X>and(ThrowingBiPredicate<? super T,? super U,? extends X> other)Returns a composed predicate that represents a short-circuiting logical AND of this predicate and another.static <T,U,X extends Throwable>
ThrowingBiPredicate<T,U,X>checked(BiPredicate<? super T,? super U> predicate)Returns a predicate that evaluates thepredicatepredicate on its input.static <T,U,X extends Throwable>
ThrowingBiPredicate<T,U,X>checked(BiPredicate<? super T,? super U> predicate, Class<X> errorType)Returns a predicate that evaluates thepredicatepredicate on its input.default ThrowingBiPredicate<T,U,X>negate()Returns a predicate that represents the logical negation of this predicate.static <T,U,X extends Throwable>
ThrowingBiPredicate<T,U,X>not(ThrowingBiPredicate<? super T,? super U,? extends X> predicate)Returns a predicate that is the negation of the supplied predicate.static <T,U,X extends Throwable>
ThrowingBiPredicate<T,U,X>of(ThrowingBiPredicate<T,U,X> predicate)Factory method for turningThrowingPredicate-shaped lambdas intoThrowingPredicates.default <E extends Throwable>
ThrowingBiPredicate<T,U,E>onErrorGetCheckedAsBoolean(ThrowingBooleanSupplier<? extends E> fallback)Returns a predicate that evaluates this predicate on its input.default BiPredicate<T,U>onErrorGetUncheckedAsBoolean(BooleanSupplier fallback)Returns a predicate that evaluates this predicate on its input.default <E extends Throwable>
ThrowingBiPredicate<T,U,E>onErrorHandleChecked(ThrowingPredicate<? super X,? extends E> errorHandler)Returns a predicate that evaluates this predicate on its input.default BiPredicate<T,U>onErrorHandleUnchecked(Predicate<? super X> errorHandler)Returns a predicate that evaluates this predicate on its input.default BiPredicate<T,U>onErrorReturn(boolean fallback)Returns a predicate that evaluates this predicate on its input.default <E extends Throwable>
ThrowingBiPredicate<T,U,E>onErrorTestChecked(ThrowingBiPredicate<? super T,? super U,? extends E> fallback)Returns a predicate that evaluates this predicate on its input.default BiPredicate<T,U>onErrorTestUnchecked(BiPredicate<? super T,? super U> fallback)Returns a predicate that evaluates this predicate on its input.default <E extends Throwable>
ThrowingBiPredicate<T,U,E>onErrorThrowAsChecked(Function<? super X,? extends E> errorMapper)Returns a predicate that evaluates this predicate on its input.default <E extends RuntimeException>
BiPredicate<T,U>onErrorThrowAsUnchecked(Function<? super X,? extends E> errorMapper)Returns a predicate that evaluates this predicate on its input.default ThrowingBiPredicate<T,U,X>or(ThrowingBiPredicate<? super T,? super U,? extends X> other)Returns a composed predicate that represents a short-circuiting logical OR of this predicate and another.booleantest(T t, U u)Evaluates this predicate on the given arguments.default BiPredicate<T,U>unchecked()Returns a predicate that evaluates this predicate on its input.static <T,U>
BiPredicate<T,U>unchecked(ThrowingBiPredicate<? super T,? super U,?> predicate)Returns a predicate that evaluates thepredicatepredicate on its input.
-
-
-
Method Detail
-
test
boolean test(T t, U u) throws X extends Throwable
Evaluates this predicate on the given arguments.
-
and
default ThrowingBiPredicate<T,U,X> and(ThrowingBiPredicate<? super T,? super U,? extends X> other)
Returns a composed predicate that represents a short-circuiting logical AND of this predicate and another. When evaluating the composed predicate, if this predicate isfalse, then theotherpredicate is not evaluated.Any exceptions thrown during evaluation of either predicate are relayed to the caller; if evaluation of this predicate throws an exception, the
otherpredicate will not be evaluated.- Parameters:
other- A predicate that will be logically-ANDed with this predicate.- Returns:
- A composed predicate that represents the short-circuiting logical AND of this predicate and the
otherpredicate. - Throws:
NullPointerException- Ifotherisnull.
-
negate
default ThrowingBiPredicate<T,U,X> negate()
Returns a predicate that represents the logical negation of this predicate.- Returns:
- A predicate that represents the logical negation of this predicate
-
or
default ThrowingBiPredicate<T,U,X> or(ThrowingBiPredicate<? super T,? super U,? extends X> other)
Returns a composed predicate that represents a short-circuiting logical OR of this predicate and another. When evaluating the composed predicate, if this predicate istrue, then theotherpredicate is not evaluated.Any exceptions thrown during evaluation of either predicate are relayed to the caller; if evaluation of this predicate throws an exception, the
otherpredicate will not be evaluated.- Parameters:
other- A predicate that will be logically-ORed with this predicate- Returns:
- A composed predicate that represents the short-circuiting logical OR of this predicate and the
otherpredicate. - Throws:
NullPointerException- Ifotherisnull.
-
onErrorThrowAsChecked
default <E extends Throwable> ThrowingBiPredicate<T,U,E> onErrorThrowAsChecked(Function<? super X,? extends E> errorMapper)
Returns a predicate that evaluates this predicate on its input. Any checked exception thrown by this predicate is transformed using the given error mapper, and the returned predicate throws the transformation result.- Type Parameters:
E- The type of checked exception to transform to.- Parameters:
errorMapper- The function to use to transform any checked exception thrown by this predicate.- Returns:
- A predicate that transforms any thrown checked exception.
- Throws:
NullPointerException- IferrorMapperisnull.
-
onErrorThrowAsUnchecked
default <E extends RuntimeException> BiPredicate<T,U> onErrorThrowAsUnchecked(Function<? super X,? extends E> errorMapper)
Returns a predicate that evaluates this predicate on its input. Any checked exception thrown by this predicate is transformed using the given error mapper, and the returned predicate throws the transformation result.- Type Parameters:
E- The type of unchecked exception to transform to.- Parameters:
errorMapper- The function to use to transform any checked exception thrown by this predicate.- Returns:
- A predicate that transforms any thrown checked exception.
- Throws:
NullPointerException- IferrorMapperisnull.
-
onErrorHandleChecked
default <E extends Throwable> ThrowingBiPredicate<T,U,E> onErrorHandleChecked(ThrowingPredicate<? super X,? extends E> errorHandler)
Returns a predicate that evaluates this predicate on its input. Any checked exception thrown by this predicate is transformed using the given error handler, and the returned predicate returns the transformation result.- Type Parameters:
E- The type of checked exception that can be thrown by the given error handler.- Parameters:
errorHandler- The function (as a predicate) to use to transform any checked exception thrown by this predicate.- Returns:
- A predicate that transforms any thrown checked exception.
- Throws:
NullPointerException- IferrorHandlerisnull.
-
onErrorHandleUnchecked
default BiPredicate<T,U> onErrorHandleUnchecked(Predicate<? super X> errorHandler)
Returns a predicate that evaluates this predicate on its input. Any checked exception thrown by this predicate is transformed using the given error handler, and the returned predicate returns the transformation result.- Parameters:
errorHandler- The function (as a predicate) to use to transform any checked exception thrown by this predicate.- Returns:
- A predicate that transforms any thrown checked exception.
- Throws:
NullPointerException- IferrorHandlerisnull.
-
onErrorTestChecked
default <E extends Throwable> ThrowingBiPredicate<T,U,E> onErrorTestChecked(ThrowingBiPredicate<? super T,? super U,? extends E> fallback)
Returns a predicate that evaluates this predicate on its input. If this predicate throws any checked exception, it is discarded and the given fallback predicate is invoked.- Type Parameters:
E- The type of checked exception that can be thrown by the given fallback predicate.- Parameters:
fallback- The predicate to invoke if this predicate throws any checked exception.- Returns:
- A predicate that invokes the
fallbackpredicate if this predicate throws any checked exception. - Throws:
NullPointerException- Iffallbackisnull.
-
onErrorTestUnchecked
default BiPredicate<T,U> onErrorTestUnchecked(BiPredicate<? super T,? super U> fallback)
Returns a predicate that evaluates this predicate on its input. If this predicate throws any checked exception, it is discarded and the given fallback predicate is invoked.- Parameters:
fallback- The predicate to invoke if this predicate throws any checked exception.- Returns:
- A predicate that invokes the
fallbackpredicate if this predicate throws any checked exception. - Throws:
NullPointerException- Iffallbackisnull.
-
onErrorGetCheckedAsBoolean
default <E extends Throwable> ThrowingBiPredicate<T,U,E> onErrorGetCheckedAsBoolean(ThrowingBooleanSupplier<? extends E> fallback)
Returns a predicate that evaluates this predicate on its input. If this predicate throws any checked exception, it is discarded and the given fallback supplier is invoked.- Type Parameters:
E- The type of checked exception that can be thrown by the given fallback supplier.- Parameters:
fallback- The supplier to produce the value to return if this predicate throws any checked exception.- Returns:
- A predicate that invokes the
fallbacksupplier if this predicate throws any checked exception. - Throws:
NullPointerException- Iffallbackisnull.
-
onErrorGetUncheckedAsBoolean
default BiPredicate<T,U> onErrorGetUncheckedAsBoolean(BooleanSupplier fallback)
Returns a predicate that evaluates this predicate on its input. If this predicate throws any checked exception, it is discarded and the given fallback supplier is invoked.- Parameters:
fallback- The supplier to produce the value to return if this predicate throws any checked exception.- Returns:
- A predicate that invokes the
fallbacksupplier if this predicate throws any checked exception. - Throws:
NullPointerException- Iffallbackisnull.
-
onErrorReturn
default BiPredicate<T,U> onErrorReturn(boolean fallback)
Returns a predicate that evaluates this predicate on its input. If this predicate throws any checked exception, it is discarded and the given fallback value is returned.- Parameters:
fallback- The value to return if this predicate throws any checked exception.- Returns:
- A predicate that returns the
fallbackvalue if this predicate throws any checked exception.
-
unchecked
default BiPredicate<T,U> unchecked()
Returns a predicate that evaluates this predicate on its input. Any checked exception thrown by this predicate is wrapped in anUncheckedExceptionwithout a stack trace.- Returns:
- A predicate that wraps any checked exception in an
UncheckedException.
-
of
static <T,U,X extends Throwable> ThrowingBiPredicate<T,U,X> of(ThrowingBiPredicate<T,U,X> predicate)
Factory method for turningThrowingPredicate-shaped lambdas intoThrowingPredicates.- Type Parameters:
T- The type of the first argument to the predicate.U- The type of the second argument the predicate.X- The type of checked exception that can be thrown.- Parameters:
predicate- The lambda to return asThrowingPredicate.- Returns:
- The given lambda as a
ThrowingPredicate. - Throws:
NullPointerException- Ifpredicateisnull.
-
not
static <T,U,X extends Throwable> ThrowingBiPredicate<T,U,X> not(ThrowingBiPredicate<? super T,? super U,? extends X> predicate)
Returns a predicate that is the negation of the supplied predicate.- Type Parameters:
T- The type of the first argument to the predicate.U- The type of the second argument the predicate.X- The type of checked exception that can be thrown.- Parameters:
predicate- The predicate to negate.- Returns:
- A predicate that negates the results of
predicate. - Throws:
NullPointerException- Ifpredicateisnull.
-
unchecked
static <T,U> BiPredicate<T,U> unchecked(ThrowingBiPredicate<? super T,? super U,?> predicate)
Returns a predicate that evaluates thepredicatepredicate on its input. Any checked exception thrown by thepredicatepredicate is wrapped in anUncheckedException.- Type Parameters:
T- The type of the first argument to the predicate.U- The type of the second argument the predicate.- Parameters:
predicate- The predicate to evaluate when the returned predicate is evaluated.- Returns:
- A predicate that wraps any checked exception in an
UncheckedException. - Throws:
NullPointerException- Ifpredicateisnull.
-
checked
static <T,U,X extends Throwable> ThrowingBiPredicate<T,U,X> checked(BiPredicate<? super T,? super U> predicate)
Returns a predicate that evaluates thepredicatepredicate on its input. Any unchecked exception thrown by thepredicatepredicate is relayed to the caller. This method allows existingPredicateinstances to be used whereThrowingPredicateis expected.- Type Parameters:
T- The type of the first argument to the predicate.U- The type of the second argument the predicate.X- The type of checked exception that can be thrown.- Parameters:
predicate- The predicate to evaluate when the returned predicate is evaluated.- Returns:
- A predicate that wraps any checked exception in an
UncheckedException. - Throws:
NullPointerException- Ifpredicateisnull.
-
checked
static <T,U,X extends Throwable> ThrowingBiPredicate<T,U,X> checked(BiPredicate<? super T,? super U> predicate, Class<X> errorType)
Returns a predicate that evaluates thepredicatepredicate on its input. AnyUncheckedExceptionthrown by thepredicatepredicate is unwrapped if its cause is an instance oferrorType, otherwise it is relayed to the caller.- Type Parameters:
T- The type of the first argument to the predicate.U- The type of the second argument the predicate.X- The type of checked exception that can be thrown.- Parameters:
predicate- The predicate to evaluate when the returned predicate is evaluated.errorType- The type of checked exception that can be thrown.- Returns:
- A predicate that wraps any checked exception in an
UncheckedException. - Throws:
NullPointerException- IfpredicateorerrorTypeisnull.
-
-