Interface ThrowingIntPredicate<X extends Throwable>

  • Type Parameters:
    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 ThrowingIntPredicate<X extends Throwable>
    Represents a predicate (boolean-valued function) of one int-valued argument. This is a checked-exception throwing equivalent of IntPredicate.
    • Method Detail

      • test

        boolean test​(int value)
              throws X extends Throwable
        Evaluates this predicate on the given argument.
        Parameters:
        value - The input argument.
        Returns:
        true if the input argument matches the predicate, otherwise false.
        Throws:
        X - If an error occurs.
        X extends Throwable
      • and

        default ThrowingIntPredicate<X> and​(ThrowingIntPredicate<? 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 ThrowingIntPredicate<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 ThrowingIntPredicate<X> or​(ThrowingIntPredicate<? 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 ThrowableThrowingIntPredicate<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 RuntimeExceptionIntPredicate 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 ThrowableThrowingIntPredicate<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 IntPredicate 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 ThrowableThrowingIntPredicate<E> onErrorTestChecked​(ThrowingIntPredicate<? 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 IntPredicate onErrorTestUnchecked​(IntPredicate 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 ThrowableThrowingIntPredicate<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 IntPredicate 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 IntPredicate 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 <X extends ThrowableThrowingIntPredicate<X> of​(ThrowingIntPredicate<X> predicate)
        Factory method for turning ThrowingIntPredicate-shaped lambdas into ThrowingIntPredicates.
        Type Parameters:
        X - The type of checked exception that can be thrown.
        Parameters:
        predicate - The lambda to return as ThrowingIntPredicate.
        Returns:
        The given lambda as a ThrowingIntPredicate.
        Throws:
        NullPointerException - If predicate is null.
      • not

        static <X extends ThrowableThrowingIntPredicate<X> not​(ThrowingIntPredicate<? extends X> predicate)
        Returns a predicate that is the negation of the supplied predicate.
        Type Parameters:
        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 IntPredicate unchecked​(ThrowingIntPredicate<?> 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.
        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 <X extends ThrowableThrowingIntPredicate<X> checked​(IntPredicate 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 IntPredicate instances to be used where ThrowingIntPredicate is expected.
        Type Parameters:
        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 <X extends ThrowableThrowingIntPredicate<X> checked​(IntPredicate 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:
        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.