Interface ThrowingDoublePredicate<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 ThrowingDoublePredicate<X extends Throwable>
Represents a predicate (boolean-valued function) of onedouble-valued argument. This is a checked-exception throwing equivalent ofDoublePredicate.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default ThrowingDoublePredicate<X>and(ThrowingDoublePredicate<? extends X> other)Returns a composed predicate that represents a short-circuiting logical AND of this predicate and another.static <X extends Throwable>
ThrowingDoublePredicate<X>checked(DoublePredicate predicate)Returns a predicate that evaluates thepredicatepredicate on its input.static <X extends Throwable>
ThrowingDoublePredicate<X>checked(DoublePredicate predicate, Class<X> errorType)Returns a predicate that evaluates thepredicatepredicate on its input.default ThrowingDoublePredicate<X>negate()Returns a predicate that represents the logical negation of this predicate.static <X extends Throwable>
ThrowingDoublePredicate<X>not(ThrowingDoublePredicate<? extends X> predicate)Returns a predicate that is the negation of the supplied predicate.static <X extends Throwable>
ThrowingDoublePredicate<X>of(ThrowingDoublePredicate<X> predicate)Factory method for turningThrowingDoublePredicate-shaped lambdas intoThrowingDoublePredicates.default <E extends Throwable>
ThrowingDoublePredicate<E>onErrorGetCheckedAsBoolean(ThrowingBooleanSupplier<? extends E> fallback)Returns a predicate that evaluates this predicate on its input.default DoublePredicateonErrorGetUncheckedAsBoolean(BooleanSupplier fallback)Returns a predicate that evaluates this predicate on its input.default <E extends Throwable>
ThrowingDoublePredicate<E>onErrorHandleChecked(ThrowingPredicate<? super X,? extends E> errorHandler)Returns a predicate that evaluates this predicate on its input.default DoublePredicateonErrorHandleUnchecked(Predicate<? super X> errorHandler)Returns a predicate that evaluates this predicate on its input.default DoublePredicateonErrorReturn(boolean fallback)Returns a predicate that evaluates this predicate on its input.default <E extends Throwable>
ThrowingDoublePredicate<E>onErrorTestChecked(ThrowingDoublePredicate<? extends E> fallback)Returns a predicate that evaluates this predicate on its input.default DoublePredicateonErrorTestUnchecked(DoublePredicate fallback)Returns a predicate that evaluates this predicate on its input.default <E extends Throwable>
ThrowingDoublePredicate<E>onErrorThrowAsChecked(Function<? super X,? extends E> errorMapper)Returns a predicate that evaluates this predicate on its input.default <E extends RuntimeException>
DoublePredicateonErrorThrowAsUnchecked(Function<? super X,? extends E> errorMapper)Returns a predicate that evaluates this predicate on its input.default ThrowingDoublePredicate<X>or(ThrowingDoublePredicate<? extends X> other)Returns a composed predicate that represents a short-circuiting logical OR of this predicate and another.booleantest(double value)Evaluates this predicate on the given argument.default DoublePredicateunchecked()Returns a predicate that evaluates this predicate on its input.static DoublePredicateunchecked(ThrowingDoublePredicate<?> predicate)Returns a predicate that evaluates thepredicatepredicate on its input.
-
-
-
Method Detail
-
test
boolean test(double value) throws X extends ThrowableEvaluates this predicate on the given argument.
-
and
default ThrowingDoublePredicate<X> and(ThrowingDoublePredicate<? 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 ThrowingDoublePredicate<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 ThrowingDoublePredicate<X> or(ThrowingDoublePredicate<? 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> ThrowingDoublePredicate<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> DoublePredicate 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> ThrowingDoublePredicate<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 DoublePredicate 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> ThrowingDoublePredicate<E> onErrorTestChecked(ThrowingDoublePredicate<? 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 DoublePredicate onErrorTestUnchecked(DoublePredicate 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> ThrowingDoublePredicate<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 DoublePredicate 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 DoublePredicate 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 DoublePredicate 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 <X extends Throwable> ThrowingDoublePredicate<X> of(ThrowingDoublePredicate<X> predicate)
Factory method for turningThrowingDoublePredicate-shaped lambdas intoThrowingDoublePredicates.- Type Parameters:
X- The type of checked exception that can be thrown.- Parameters:
predicate- The lambda to return asThrowingDoublePredicate.- Returns:
- The given lambda as a
ThrowingDoublePredicate. - Throws:
NullPointerException- Ifpredicateisnull.
-
not
static <X extends Throwable> ThrowingDoublePredicate<X> not(ThrowingDoublePredicate<? 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- Ifpredicateisnull.
-
unchecked
static DoublePredicate unchecked(ThrowingDoublePredicate<?> predicate)
Returns a predicate that evaluates thepredicatepredicate on its input. Any checked exception thrown by thepredicatepredicate is wrapped in anUncheckedException.- 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 <X extends Throwable> ThrowingDoublePredicate<X> checked(DoublePredicate predicate)
Returns a predicate that evaluates thepredicatepredicate on its input. Any unchecked exception thrown by thepredicatepredicate is relayed to the caller. This method allows existingDoublePredicateinstances to be used whereThrowingDoublePredicateis 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- Ifpredicateisnull.
-
checked
static <X extends Throwable> ThrowingDoublePredicate<X> checked(DoublePredicate 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:
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.
-
-