Interface ThrowingLongPredicate<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 ThrowingLongPredicate<X extends Throwable>
Represents a predicate (boolean-valued function) of onelong-valued argument. This is a checked-exception throwing equivalent ofLongPredicate.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default ThrowingLongPredicate<X>and(ThrowingLongPredicate<? extends X> other)Returns a composed predicate that represents a short-circuiting logical AND of this predicate and another.static <X extends Throwable>
ThrowingLongPredicate<X>checked(LongPredicate predicate)Returns a predicate that evaluates thepredicatepredicate on its input.static <X extends Throwable>
ThrowingLongPredicate<X>checked(LongPredicate predicate, Class<X> errorType)Returns a predicate that evaluates thepredicatepredicate on its input.default ThrowingLongPredicate<X>negate()Returns a predicate that represents the logical negation of this predicate.static <X extends Throwable>
ThrowingLongPredicate<X>not(ThrowingLongPredicate<? extends X> predicate)Returns a predicate that is the negation of the supplied predicate.static <X extends Throwable>
ThrowingLongPredicate<X>of(ThrowingLongPredicate<X> predicate)Factory method for turningThrowingLongPredicate-shaped lambdas intoThrowingLongPredicates.default <E extends Throwable>
ThrowingLongPredicate<E>onErrorGetCheckedAsBoolean(ThrowingBooleanSupplier<? extends E> fallback)Returns a predicate that evaluates this predicate on its input.default LongPredicateonErrorGetUncheckedAsBoolean(BooleanSupplier fallback)Returns a predicate that evaluates this predicate on its input.default <E extends Throwable>
ThrowingLongPredicate<E>onErrorHandleChecked(ThrowingPredicate<? super X,? extends E> errorHandler)Returns a predicate that evaluates this predicate on its input.default LongPredicateonErrorHandleUnchecked(Predicate<? super X> errorHandler)Returns a predicate that evaluates this predicate on its input.default LongPredicateonErrorReturn(boolean fallback)Returns a predicate that evaluates this predicate on its input.default <E extends Throwable>
ThrowingLongPredicate<E>onErrorTestChecked(ThrowingLongPredicate<? extends E> fallback)Returns a predicate that evaluates this predicate on its input.default LongPredicateonErrorTestUnchecked(LongPredicate fallback)Returns a predicate that evaluates this predicate on its input.default <E extends Throwable>
ThrowingLongPredicate<E>onErrorThrowAsChecked(Function<? super X,? extends E> errorMapper)Returns a predicate that evaluates this predicate on its input.default <E extends RuntimeException>
LongPredicateonErrorThrowAsUnchecked(Function<? super X,? extends E> errorMapper)Returns a predicate that evaluates this predicate on its input.default ThrowingLongPredicate<X>or(ThrowingLongPredicate<? extends X> other)Returns a composed predicate that represents a short-circuiting logical OR of this predicate and another.booleantest(long value)Evaluates this predicate on the given argument.default LongPredicateunchecked()Returns a predicate that evaluates this predicate on its input.static LongPredicateunchecked(ThrowingLongPredicate<?> predicate)Returns a predicate that evaluates thepredicatepredicate on its input.
-
-
-
Method Detail
-
test
boolean test(long value) throws X extends ThrowableEvaluates this predicate on the given argument.
-
and
default ThrowingLongPredicate<X> and(ThrowingLongPredicate<? 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 ThrowingLongPredicate<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 ThrowingLongPredicate<X> or(ThrowingLongPredicate<? 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> ThrowingLongPredicate<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> LongPredicate 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> ThrowingLongPredicate<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 LongPredicate 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> ThrowingLongPredicate<E> onErrorTestChecked(ThrowingLongPredicate<? 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 LongPredicate onErrorTestUnchecked(LongPredicate 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> ThrowingLongPredicate<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 LongPredicate 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 LongPredicate 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 LongPredicate 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> ThrowingLongPredicate<X> of(ThrowingLongPredicate<X> predicate)
Factory method for turningThrowingLongPredicate-shaped lambdas intoThrowingLongPredicates.- Type Parameters:
X- The type of checked exception that can be thrown.- Parameters:
predicate- The lambda to return asThrowingLongPredicate.- Returns:
- The given lambda as a
ThrowingLongPredicate. - Throws:
NullPointerException- Ifpredicateisnull.
-
not
static <X extends Throwable> ThrowingLongPredicate<X> not(ThrowingLongPredicate<? 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 LongPredicate unchecked(ThrowingLongPredicate<?> 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> ThrowingLongPredicate<X> checked(LongPredicate predicate)
Returns a predicate that evaluates thepredicatepredicate on its input. Any unchecked exception thrown by thepredicatepredicate is relayed to the caller. This method allows existingLongPredicateinstances to be used whereThrowingLongPredicateis 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> ThrowingLongPredicate<X> checked(LongPredicate 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.
-
-