Interface BiPredicateWithException<T,U,E extends Exception>
-
- Type Parameters:
T
- the type of the first argument to the predicateU
- the type of the second argument the predicateE
- the type of the potential exception of the function
- All Superinterfaces:
ExceptionHandlerSupport<BiPredicate<T,U>,BiPredicate<T,U>,BiPredicateWithException<T,U,E>>
,PrimitiveReturnExceptionHandlerSupport<BiPredicate<T,U>,BiPredicateWithException<T,U,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 BiPredicateWithException<T,U,E extends Exception> extends PrimitiveReturnExceptionHandlerSupport<BiPredicate<T,U>,BiPredicateWithException<T,U,E>>
Represents a predicate (boolean-valued function) of two arguments that may throw exception. This is the two-arity specialization ofPredicateWithException
.General contract
boolean test(T t, U u) throws E
- The functional method.- uncheck - Return a
BiPredicate<T, U>
- lift - Return a
BiPredicate<T, U>
- ignore - Return a
BiPredicate<T, U>
- See Also:
BiPredicate
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default BiPredicateWithException<T,U,E>
and(BiPredicateWithException<? super T,? super U,? 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 <T,U,E extends Exception>
BiPredicateWithException<T,U,E>failing(Supplier<E> exceptionBuilder)
Returns a predicate that always throw exception.static <T,U,E extends Exception>
BiPredicate<T,U>ignored(BiPredicateWithException<T,U,E> predicate)
Converts aBiPredicateWithException
to a liftedBiPredicate
returningfalse
in case of exception.static <T,U,E extends Exception>
BiPredicate<T,U>ignored(BiPredicateWithException<T,U,E> predicate, boolean defaultValue)
Converts aBiPredicateWithException
to a liftedBiPredicate
returning a default value in case of exception.static <T,U,E extends Exception>
BiPredicate<T,U>lifted(BiPredicateWithException<T,U,E> predicate)
Converts aBiPredicateWithException
to a liftedBiPredicate
returningfalse
in case of exception.default BiPredicateWithException<T,U,E>
negate()
Returns a predicate that represents the logical negation of this predicate.static <T,U,E extends Exception>
BiPredicateWithException<T,U,E>negate(BiPredicateWithException<T,U,E> predicate)
Negate aDoublePredicateWithException
.default BiPredicateWithException<T,U,E>
or(BiPredicateWithException<? super T,? super U,? extends E> other)
Returns a composed predicate that represents a short-circuiting logical OR of this predicate and another.boolean
test(T t, U u)
Evaluates this predicate on the given arguments.static <T,U,E extends Exception>
BiPredicate<T,U>unchecked(BiPredicateWithException<T,U,E> predicate)
Converts aBiPredicateWithException
to aBiPredicate
that wraps toRuntimeException
.static <T,U,E extends Exception>
BiPredicate<T,U>unchecked(BiPredicateWithException<T,U,E> predicate, Function<Exception,RuntimeException> exceptionMapper)
Converts aBiPredicateWithException
to aBiPredicate
that wraps toRuntimeException
by using the provided mapping function.default BiPredicate<T,U>
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(T t, U u) throws E extends Exception
Evaluates this predicate on the given arguments.- Parameters:
t
- the first input argumentu
- the second input argument- Returns:
true
if the input arguments match the predicate, otherwisefalse
- Throws:
E
- any exceptionE extends Exception
- See Also:
BiPredicate.test(Object, Object)
-
uncheckOrIgnore
default BiPredicate<T,U> uncheckOrIgnore(boolean uncheck)
Description copied from interface:PrimitiveReturnExceptionHandlerSupport
Used internally to implements the ignore or uncheck operation.- Specified by:
uncheckOrIgnore
in interfacePrimitiveReturnExceptionHandlerSupport<T,U>
- Parameters:
uncheck
- create unchecked version of the function when true, else ignored version.- Returns:
- the function
-
and
default BiPredicateWithException<T,U,E> and(BiPredicateWithException<? super T,? super U,? 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(BiPredicateWithException)
,negate()
-
negate
default BiPredicateWithException<T,U,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(BiPredicateWithException)
,or(BiPredicateWithException)
-
negate
static <T,U,E extends Exception> BiPredicateWithException<T,U,E> negate(BiPredicateWithException<T,U,E> predicate)
Negate aDoublePredicateWithException
.- Type Parameters:
T
- the type of the first argument to the predicateU
- the type of the second argument the predicateE
- the type of the potential exception- Parameters:
predicate
- to be negate- Returns:
- the negated predicate
- See Also:
negate()
-
or
default BiPredicateWithException<T,U,E> or(BiPredicateWithException<? super T,? super U,? 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(BiPredicateWithException)
,negate()
-
failing
static <T,U,E extends Exception> BiPredicateWithException<T,U,E> failing(Supplier<E> exceptionBuilder)
Returns a predicate that always throw exception.- Type Parameters:
T
- the type of the first argument to the predicateU
- the type of the second argument the predicateE
- the type of the exception- Parameters:
exceptionBuilder
- the supplier to create the exception- Returns:
- a predicate that always throw exception
-
unchecked
static <T,U,E extends Exception> BiPredicate<T,U> unchecked(BiPredicateWithException<T,U,E> predicate)
Converts aBiPredicateWithException
to aBiPredicate
that wraps toRuntimeException
.- Type Parameters:
T
- the type of the first argument to the predicateU
- the type of the second argument the predicateE
- the type of the potential exception- Parameters:
predicate
- to be unchecked- Returns:
- the unchecked predicate
- Throws:
NullPointerException
- if predicate is null- See Also:
PrimitiveReturnExceptionHandlerSupport.uncheck()
,unchecked(BiPredicateWithException, Function)
-
unchecked
static <T,U,E extends Exception> BiPredicate<T,U> unchecked(BiPredicateWithException<T,U,E> predicate, Function<Exception,RuntimeException> exceptionMapper)
Converts aBiPredicateWithException
to aBiPredicate
that wraps toRuntimeException
by using the provided mapping function.- Type Parameters:
T
- the type of the first argument to the predicateU
- the type of the second argument the predicateE
- 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(BiPredicateWithException)
-
lifted
static <T,U,E extends Exception> BiPredicate<T,U> lifted(BiPredicateWithException<T,U,E> predicate)
Converts aBiPredicateWithException
to a liftedBiPredicate
returningfalse
in case of exception.- Type Parameters:
T
- the type of the first argument to the predicateU
- the type of the second argument the predicateE
- 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 <T,U,E extends Exception> BiPredicate<T,U> ignored(BiPredicateWithException<T,U,E> predicate)
Converts aBiPredicateWithException
to a liftedBiPredicate
returningfalse
in case of exception.- Type Parameters:
T
- the type of the first argument to the predicateU
- the type of the second argument the predicateE
- 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 <T,U,E extends Exception> BiPredicate<T,U> ignored(BiPredicateWithException<T,U,E> predicate, boolean defaultValue)
Converts aBiPredicateWithException
to a liftedBiPredicate
returning a default value in case of exception.- Type Parameters:
T
- the type of the first argument to the predicateU
- the type of the second argument the predicateE
- 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(BiPredicateWithException)
-
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
-
-