Interface LongPredicateWithException<E extends Exception>
-
- Type Parameters:
E
- the type of the potential exception of the function
- All Superinterfaces:
ExceptionHandlerSupport<LongPredicate,LongPredicate,LongPredicateWithException<E>>
,PrimitiveReturnExceptionHandlerSupport<LongPredicate,LongPredicateWithException<E>>
- 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 LongPredicateWithException<E extends Exception> extends PrimitiveReturnExceptionHandlerSupport<LongPredicate,LongPredicateWithException<E>>
Represents a predicate (boolean-valued function) of onelong
-valued argument that may throw exception. This is thelong
-consuming primitive type specialization ofPredicateWithException
.General contract
boolean test(long value) throws E
- The functional method.- uncheck - Return a
LongPredicate
- lift - Return a
LongPredicate
- ignore - Return a
LongPredicate
- See Also:
LongPredicate
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default LongPredicateWithException<E>
and(LongPredicateWithException<? extends E> other)
Returns a composed predicate that represents a short-circuiting logical AND of this predicate and another.default boolean
defaultValue()
Defines the default value returned by the ignore and ignored method.static <E extends Exception>
LongPredicateWithException<E>failing(Supplier<E> exceptionBuilder)
Returns a predicate that always throw exception.static <E extends Exception>
LongPredicateignored(LongPredicateWithException<E> predicate)
Converts aLongPredicateWithException
to a liftedLongPredicate
returning0
in case of exception.static <E extends Exception>
LongPredicateignored(LongPredicateWithException<E> predicate, boolean defaultValue)
Converts aLongPredicateWithException
to a liftedLongPredicate
returning a default value in case of exception.static <E extends Exception>
LongPredicatelifted(LongPredicateWithException<E> predicate)
Converts aLongPredicateWithException
to a liftedLongPredicate
returning0
in case of exception.default LongPredicateWithException<E>
negate()
Returns a predicate that represents the logical negation of this predicate.static <E extends Exception>
LongPredicateWithException<E>negate(LongPredicateWithException<E> predicate)
Negate aLongPredicateWithException
.default LongPredicateWithException<E>
or(LongPredicateWithException<? extends E> other)
Returns a composed predicate that represents a short-circuiting logical OR of this predicate and another.boolean
test(long value)
Evaluates this predicate on the given argument.static <E extends Exception>
LongPredicateunchecked(LongPredicateWithException<E> predicate)
Converts aLongPredicateWithException
to aLongPredicate
that convert exception toRuntimeException
.static <E extends Exception>
LongPredicateunchecked(LongPredicateWithException<E> predicate, Function<Exception,RuntimeException> exceptionMapper)
Converts aPredicateWithException
to aPredicate
that wraps exception toRuntimeException
by using the provided mapping function.default LongPredicate
uncheckOrIgnore(boolean uncheck)
Used internally to implements the ignore or uncheck operation.-
Methods inherited from interface ch.powerunit.extensions.exceptions.ExceptionHandlerSupport
documented, exceptionMapper
-
Methods inherited from interface ch.powerunit.extensions.exceptions.PrimitiveReturnExceptionHandlerSupport
ignore, lift, uncheck
-
-
-
-
Method Detail
-
test
boolean test(long value) throws E extends Exception
Evaluates this predicate on the given argument.- Parameters:
value
- the input argument- Returns:
true
if the input argument matches the predicate, otherwisefalse
- Throws:
E
- any exceptionE extends Exception
- See Also:
LongPredicate.test(long)
-
uncheckOrIgnore
default LongPredicate uncheckOrIgnore(boolean uncheck)
Description copied from interface:PrimitiveReturnExceptionHandlerSupport
Used internally to implements the ignore or uncheck operation.- Specified by:
uncheckOrIgnore
in interfacePrimitiveReturnExceptionHandlerSupport<LongPredicate,LongPredicateWithException<E extends Exception>>
- Parameters:
uncheck
- create unchecked version of the function when true, else ignored version.- Returns:
- the function
-
and
default LongPredicateWithException<E> and(LongPredicateWithException<? extends E> 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 theother
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- See Also:
or(LongPredicateWithException)
,negate()
-
negate
default LongPredicateWithException<E> negate()
Returns a predicate that represents the logical negation of this predicate.- Returns:
- a predicate that represents the logical negation of this predicate
- See Also:
and(LongPredicateWithException)
,or(LongPredicateWithException)
-
negate
static <E extends Exception> LongPredicateWithException<E> negate(LongPredicateWithException<E> predicate)
Negate aLongPredicateWithException
.- Type Parameters:
E
- the type of the potential exception- Parameters:
predicate
- to be negate- Returns:
- the negated predicate
- See Also:
negate()
-
or
default LongPredicateWithException<E> or(LongPredicateWithException<? extends E> 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 theother
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- See Also:
and(LongPredicateWithException)
,negate()
-
failing
static <E extends Exception> LongPredicateWithException<E> failing(Supplier<E> exceptionBuilder)
Returns a predicate that always throw exception.- Type Parameters:
E
- the type of the exception- Parameters:
exceptionBuilder
- the supplier to create the exception the type of the input object to the function- Returns:
- a predicate that always throw exception
-
unchecked
static <E extends Exception> LongPredicate unchecked(LongPredicateWithException<E> predicate)
Converts aLongPredicateWithException
to aLongPredicate
that convert exception toRuntimeException
.- Type Parameters:
E
- the type of the potential exception- Parameters:
predicate
- to be unchecked- Returns:
- the unchecked exception
- Throws:
NullPointerException
- if predicate is null- See Also:
PrimitiveReturnExceptionHandlerSupport.uncheck()
,unchecked(LongPredicateWithException, Function)
-
unchecked
static <E extends Exception> LongPredicate unchecked(LongPredicateWithException<E> predicate, Function<Exception,RuntimeException> exceptionMapper)
Converts aPredicateWithException
to aPredicate
that wraps exception toRuntimeException
by using the provided mapping function.- Type Parameters:
E
- the type of the potential exception- Parameters:
predicate
- the be uncheckedexceptionMapper
- a function to convert the exception to the runtime exception.- Returns:
- the unchecked predicate
- Throws:
NullPointerException
- if predicate or exceptionMapper is null- See Also:
PrimitiveReturnExceptionHandlerSupport.uncheck()
,unchecked(LongPredicateWithException)
-
lifted
static <E extends Exception> LongPredicate lifted(LongPredicateWithException<E> predicate)
Converts aLongPredicateWithException
to a liftedLongPredicate
returning0
in case of exception.- Type Parameters:
E
- the type of the potential exception- Parameters:
predicate
- to be lifted- Returns:
- the lifted predicate
- Throws:
NullPointerException
- if predicate is null- See Also:
PrimitiveReturnExceptionHandlerSupport.lift()
-
ignored
static <E extends Exception> LongPredicate ignored(LongPredicateWithException<E> predicate)
Converts aLongPredicateWithException
to a liftedLongPredicate
returning0
in case of exception.- Type Parameters:
E
- the type of the potential exception- Parameters:
predicate
- to be lifted- Returns:
- the lifted predicate
- Throws:
NullPointerException
- if predicate is null- See Also:
PrimitiveReturnExceptionHandlerSupport.ignore()
-
ignored
static <E extends Exception> LongPredicate ignored(LongPredicateWithException<E> predicate, boolean defaultValue)
Converts aLongPredicateWithException
to a liftedLongPredicate
returning a default value in case of exception.- Type Parameters:
E
- the type of the potential exception- Parameters:
predicate
- to be lifteddefaultValue
- value in case of exception- Returns:
- the lifted predicate
- Throws:
NullPointerException
- if predicate is null- Since:
- 3.0.0
- See Also:
PrimitiveReturnExceptionHandlerSupport.ignore()
,ignored(LongPredicateWithException)
-
defaultValue
default boolean defaultValue()
Defines the default value returned by the ignore and ignored method.- Returns:
- the default value for the ignore/ignored method.
- Since:
- 3.0.0
-
-