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 of BiPredicate.
    • Method Detail

      • test

        boolean test​(T t,
                     U u)
              throws X extends Throwable
        Evaluates this predicate on the given arguments.
        Parameters:
        t - The first input argument.
        u - The second input argument.
        Returns:
        true if the input arguments matches the predicate, otherwise false.
        Throws:
        X - If an error occurs.
        X extends Throwable
      • 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 is false, then the other predicate 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 other predicate 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 other predicate.
        Throws:
        NullPointerException - If other is null.
      • 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 is true, then the other predicate 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 other predicate 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 other predicate.
        Throws:
        NullPointerException - If other is null.
      • onErrorThrowAsChecked

        default <E extends ThrowableThrowingBiPredicate<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 - If errorMapper is null.
      • onErrorThrowAsUnchecked

        default <E extends RuntimeExceptionBiPredicate<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 - If errorMapper is null.
      • onErrorHandleChecked

        default <E extends ThrowableThrowingBiPredicate<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 - If errorHandler is null.
      • 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 - If errorHandler is null.
      • onErrorTestChecked

        default <E extends ThrowableThrowingBiPredicate<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 fallback predicate if this predicate throws any checked exception.
        Throws:
        NullPointerException - If fallback is null.
      • 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 fallback predicate if this predicate throws any checked exception.
        Throws:
        NullPointerException - If fallback is null.
      • onErrorGetCheckedAsBoolean

        default <E extends ThrowableThrowingBiPredicate<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 fallback supplier if this predicate throws any checked exception.
        Throws:
        NullPointerException - If fallback is null.
      • 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 fallback supplier if this predicate throws any checked exception.
        Throws:
        NullPointerException - If fallback is null.
      • 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 fallback value if this predicate throws any checked exception.
      • of

        static <T,​U,​X extends ThrowableThrowingBiPredicate<T,​U,​X> of​(ThrowingBiPredicate<T,​U,​X> predicate)
        Factory method for turning ThrowingPredicate-shaped lambdas into ThrowingPredicates.
        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 as ThrowingPredicate.
        Returns:
        The given lambda as a ThrowingPredicate.
        Throws:
        NullPointerException - If predicate is null.
      • not

        static <T,​U,​X extends ThrowableThrowingBiPredicate<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 - If predicate is null.
      • unchecked

        static <T,​U> BiPredicate<T,​U> unchecked​(ThrowingBiPredicate<? super T,​? super U,​?> predicate)
        Returns a predicate that evaluates the predicate predicate on its input. Any checked exception thrown by the predicate predicate is wrapped in an UncheckedException.
        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 - If predicate is null.
      • checked

        static <T,​U,​X extends ThrowableThrowingBiPredicate<T,​U,​X> checked​(BiPredicate<? super T,​? super U> predicate)
        Returns a predicate that evaluates the predicate predicate on its input. Any unchecked exception thrown by the predicate predicate is relayed to the caller. This method allows existing Predicate instances to be used where ThrowingPredicate is 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 - If predicate is null.
      • checked

        static <T,​U,​X extends ThrowableThrowingBiPredicate<T,​U,​X> checked​(BiPredicate<? super T,​? super U> predicate,
                                                                                                    Class<X> errorType)
        Returns a predicate that evaluates the predicate predicate on its input. Any UncheckedException thrown by the predicate predicate is unwrapped if its cause is an instance of errorType, 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 - If predicate or errorType is null.