Interface IntPredicateWithException<E extends Exception>
-
- Type Parameters:
E
- the type of the potential exception of the function
- All Superinterfaces:
ExceptionHandlerSupport<IntPredicate,IntPredicate,IntPredicateWithException<E>>
,PrimitiveReturnExceptionHandlerSupport<IntPredicate,IntPredicateWithException<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 IntPredicateWithException<E extends Exception> extends PrimitiveReturnExceptionHandlerSupport<IntPredicate,IntPredicateWithException<E>>
Represents a predicate (boolean-valued function) of oneint
-valued argument that may throw exception. This is theint
-consuming primitive type specialization ofPredicateWithException
.General contract
boolean test(int value) throws E
- The functional method.- uncheck - Return a
IntPredicate
- lift - Return a
IntPredicate
- ignore - Return a
IntPredicate
- See Also:
IntPredicate
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default IntPredicateWithException<E>
and(IntPredicateWithException<? 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>
IntPredicateWithException<E>failing(Supplier<E> exceptionBuilder)
Returns a predicate that always throw exception.static <E extends Exception>
IntPredicateignored(IntPredicateWithException<E> predicate)
Converts aIntPredicateWithException
to a liftedIntPredicate
returningfalse
in case of exception.static <E extends Exception>
IntPredicateignored(IntPredicateWithException<E> predicate, boolean defaultValue)
Converts aIntPredicateWithException
to a liftedIntPredicate
returning a default value in case of exception.static <E extends Exception>
IntPredicatelifted(IntPredicateWithException<E> predicate)
Converts aIntPredicateWithException
to a liftedIntPredicate
returningfalse
in case of exception.default IntPredicateWithException<E>
negate()
Returns a predicate that represents the logical negation of this predicate.static <E extends Exception>
IntPredicateWithException<E>negate(IntPredicateWithException<E> predicate)
Negate aIntPredicateWithException
.default IntPredicateWithException<E>
or(IntPredicateWithException<? extends E> other)
Returns a composed predicate that represents a short-circuiting logical OR of this predicate and another.boolean
test(int value)
Evaluates this predicate on the given argument.static <E extends Exception>
IntPredicateunchecked(IntPredicateWithException<E> predicate)
Converts aIntPredicateWithException
to aIntPredicate
that wraps exception toRuntimeException
.static <E extends Exception>
IntPredicateunchecked(IntPredicateWithException<E> predicate, Function<Exception,RuntimeException> exceptionMapper)
Converts aPredicateWithException
to aPredicate
that wraps exception toRuntimeException
by using the provided mapping function.default IntPredicate
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(int 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:
IntPredicate.test(int)
-
uncheckOrIgnore
default IntPredicate uncheckOrIgnore(boolean uncheck)
Description copied from interface:PrimitiveReturnExceptionHandlerSupport
Used internally to implements the ignore or uncheck operation.- Specified by:
uncheckOrIgnore
in interfacePrimitiveReturnExceptionHandlerSupport<IntPredicate,IntPredicateWithException<E extends Exception>>
- Parameters:
uncheck
- create unchecked version of the function when true, else ignored version.- Returns:
- the function
-
and
default IntPredicateWithException<E> and(IntPredicateWithException<? 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(IntPredicateWithException)
,negate()
-
negate
default IntPredicateWithException<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(IntPredicateWithException)
,or(IntPredicateWithException)
-
negate
static <E extends Exception> IntPredicateWithException<E> negate(IntPredicateWithException<E> predicate)
Negate aIntPredicateWithException
.- Type Parameters:
E
- the type of the potential exception- Parameters:
predicate
- to be negate- Returns:
- the negated predicate
- See Also:
negate()
-
or
default IntPredicateWithException<E> or(IntPredicateWithException<? 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(IntPredicateWithException)
,negate()
-
failing
static <E extends Exception> IntPredicateWithException<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> IntPredicate unchecked(IntPredicateWithException<E> predicate)
Converts aIntPredicateWithException
to aIntPredicate
that wraps exception toRuntimeException
.- Type Parameters:
E
- 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(IntPredicateWithException, Function)
-
unchecked
static <E extends Exception> IntPredicate unchecked(IntPredicateWithException<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(IntPredicateWithException)
-
lifted
static <E extends Exception> IntPredicate lifted(IntPredicateWithException<E> predicate)
Converts aIntPredicateWithException
to a liftedIntPredicate
returningfalse
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> IntPredicate ignored(IntPredicateWithException<E> predicate)
Converts aIntPredicateWithException
to a liftedIntPredicate
returningfalse
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> IntPredicate ignored(IntPredicateWithException<E> predicate, boolean defaultValue)
Converts aIntPredicateWithException
to a liftedIntPredicate
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(IntPredicateWithException)
-
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
-
-