Interface BooleanSupplierWithException<E extends Exception>
-
- Type Parameters:
E
- the type of the potential exception of the operation
- All Superinterfaces:
ExceptionHandlerSupport<BooleanSupplier,BooleanSupplier,BooleanSupplierWithException<E>>
,PrimitiveReturnExceptionHandlerSupport<BooleanSupplier,BooleanSupplierWithException<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 BooleanSupplierWithException<E extends Exception> extends PrimitiveReturnExceptionHandlerSupport<BooleanSupplier,BooleanSupplierWithException<E>>
Represents a supplier ofboolean
-valued results which may throw exception. This is theboolean
-producing primitive specialization ofSupplierWithException
.General contract
boolean getAsBoolean() throws E
- The functional method.- uncheck - Return a
BooleanSupplier
- lift - Return a
BooleanSupplier
- ignore - Return a
BooleanSupplier
- See Also:
BooleanSupplier
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default boolean
defaultValue()
Defines the default value returned by the ignore and ignored method.static <E extends Exception>
BooleanSupplierWithException<E>failing(Supplier<E> exceptionBuilder)
Returns a supplier that always throw exception.boolean
getAsBoolean()
Gets a result.static <E extends Exception>
BooleanSupplierignored(BooleanSupplierWithException<E> supplier)
Converts aBooleanSupplierWithException
to a liftedBooleanSupplier
returningnull
in case of exception.static <E extends Exception>
BooleanSupplierignored(BooleanSupplierWithException<E> supplier, boolean defaultValue)
Converts aBooleanSupplierWithException
to a liftedBooleanSupplier
returning a default value in case of exception.static <E extends Exception>
BooleanSupplierlifted(BooleanSupplierWithException<E> supplier)
Converts aBooleanSupplierWithException
to a liftedBooleanSupplier
returningnull
in case of exception.static <E extends Exception>
BooleanSupplierunchecked(BooleanSupplierWithException<E> supplier)
Converts aBooleanSupplierWithException
to aBooleanSupplier
that wraps exception toRuntimeException
.static <E extends Exception>
BooleanSupplierunchecked(BooleanSupplierWithException<E> supplier, Function<Exception,RuntimeException> exceptionMapper)
Converts aBooleanSupplierWithException
to aBooleanSupplier
that wraps exception toRuntimeException
by using the provided mapping function.default BooleanSupplier
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
-
getAsBoolean
boolean getAsBoolean() throws E extends Exception
Gets a result.- Returns:
- a boolean
- Throws:
E
- any exceptionE extends Exception
- See Also:
BooleanSupplier.getAsBoolean()
-
uncheckOrIgnore
default BooleanSupplier uncheckOrIgnore(boolean uncheck)
Description copied from interface:PrimitiveReturnExceptionHandlerSupport
Used internally to implements the ignore or uncheck operation.- Specified by:
uncheckOrIgnore
in interfacePrimitiveReturnExceptionHandlerSupport<BooleanSupplier,BooleanSupplierWithException<E extends Exception>>
- Parameters:
uncheck
- create unchecked version of the function when true, else ignored version.- Returns:
- the function
-
failing
static <E extends Exception> BooleanSupplierWithException<E> failing(Supplier<E> exceptionBuilder)
Returns a supplier that always throw exception.- Type Parameters:
E
- the type of the exception- Parameters:
exceptionBuilder
- the supplier to create the exception- Returns:
- an operation that always throw exception
-
unchecked
static <E extends Exception> BooleanSupplier unchecked(BooleanSupplierWithException<E> supplier)
Converts aBooleanSupplierWithException
to aBooleanSupplier
that wraps exception toRuntimeException
.- Type Parameters:
E
- the type of the potential exception- Parameters:
supplier
- to be unchecked- Returns:
- the unchecked supplier
- Throws:
NullPointerException
- if supplier is null- See Also:
PrimitiveReturnExceptionHandlerSupport.uncheck()
,unchecked(BooleanSupplierWithException, Function)
-
unchecked
static <E extends Exception> BooleanSupplier unchecked(BooleanSupplierWithException<E> supplier, Function<Exception,RuntimeException> exceptionMapper)
Converts aBooleanSupplierWithException
to aBooleanSupplier
that wraps exception toRuntimeException
by using the provided mapping function.- Type Parameters:
E
- the type of the potential exception- Parameters:
supplier
- the be uncheckedexceptionMapper
- a function to convert the exception to the runtime exception.- Returns:
- the unchecked supplier
- Throws:
NullPointerException
- if supplier and exceptionMapper is null- See Also:
PrimitiveReturnExceptionHandlerSupport.uncheck()
,unchecked(BooleanSupplierWithException)
-
lifted
static <E extends Exception> BooleanSupplier lifted(BooleanSupplierWithException<E> supplier)
Converts aBooleanSupplierWithException
to a liftedBooleanSupplier
returningnull
in case of exception.- Type Parameters:
E
- the type of the potential exception- Parameters:
supplier
- to be lifted- Returns:
- the lifted supplier
- Throws:
NullPointerException
- if supplier is null- See Also:
PrimitiveReturnExceptionHandlerSupport.lift()
-
ignored
static <E extends Exception> BooleanSupplier ignored(BooleanSupplierWithException<E> supplier)
Converts aBooleanSupplierWithException
to a liftedBooleanSupplier
returningnull
in case of exception.- Type Parameters:
E
- the type of the potential exception- Parameters:
supplier
- to be lifted- Returns:
- the lifted supplier
- Throws:
NullPointerException
- if supplier is null- See Also:
PrimitiveReturnExceptionHandlerSupport.ignore()
-
ignored
static <E extends Exception> BooleanSupplier ignored(BooleanSupplierWithException<E> supplier, boolean defaultValue)
Converts aBooleanSupplierWithException
to a liftedBooleanSupplier
returning a default value in case of exception.- Type Parameters:
E
- the type of the potential exception- Parameters:
supplier
- to be lifteddefaultValue
- value in case of exception- Returns:
- the lifted supplier
- Throws:
NullPointerException
- if supplier is null- Since:
- 3.0.0
- See Also:
PrimitiveReturnExceptionHandlerSupport.ignore()
,ignored(BooleanSupplierWithException)
-
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
-
-