Interface IntSupplierWithException<E extends Exception>
-
- Type Parameters:
E- the type of the potential exception of the operation
- All Superinterfaces:
ExceptionHandlerSupport<IntSupplier,IntSupplier,IntSupplierWithException<E>>,PrimitiveReturnExceptionHandlerSupport<IntSupplier,IntSupplierWithException<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 IntSupplierWithException<E extends Exception> extends PrimitiveReturnExceptionHandlerSupport<IntSupplier,IntSupplierWithException<E>>
Represents a supplier ofint-valued results and may throw exception. This is theint-producing primitive specialization ofSupplierWithException.General contract
int getAsInt() throws E- The functional method.- uncheck - Return a
IntSupplier - lift - Return a
IntSupplier - ignore - Return a
IntSupplier
There is no requirement that a distinct result be returned each time the supplier is invoked.
- See Also:
IntSupplier
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default intdefaultValue()Defines the default value returned by the ignore and ignored method.static <E extends Exception>
IntSupplierWithException<E>failing(Supplier<E> exceptionBuilder)Returns a supplier that always throw exception.intgetAsInt()Gets a result.static <E extends Exception>
IntSupplierignored(IntSupplierWithException<E> supplier)Converts aIntSupplierWithExceptionto a liftedIntSupplierreturning0in case of exception.static <E extends Exception>
IntSupplierignored(IntSupplierWithException<E> supplier, int defaultValue)Converts aIntSupplierWithExceptionto a liftedIntSupplierreturning a default value in case of exception.static <E extends Exception>
IntSupplierlifted(IntSupplierWithException<E> supplier)Converts aIntSupplierWithExceptionto a liftedIntSupplierreturning0in case of exception.static <E extends Exception>
IntSupplierunchecked(IntSupplierWithException<E> supplier)Converts aIntSupplierWithExceptionto aIntSupplierthat wraps exception toRuntimeException.static <E extends Exception>
IntSupplierunchecked(IntSupplierWithException<E> supplier, Function<Exception,RuntimeException> exceptionMapper)Converts aIntSupplierWithExceptionto aIntSupplierthat wraps exception toRuntimeExceptionby using the provided mapping function.default IntSupplieruncheckOrIgnore(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
-
getAsInt
int getAsInt() throws E extends Exception
Gets a result.- Returns:
- a result
- Throws:
E- any exceptionE extends Exception- See Also:
IntSupplier.getAsInt()
-
uncheckOrIgnore
default IntSupplier uncheckOrIgnore(boolean uncheck)
Description copied from interface:PrimitiveReturnExceptionHandlerSupportUsed internally to implements the ignore or uncheck operation.- Specified by:
uncheckOrIgnorein interfacePrimitiveReturnExceptionHandlerSupport<IntSupplier,IntSupplierWithException<E extends Exception>>- Parameters:
uncheck- create unchecked version of the function when true, else ignored version.- Returns:
- the function
-
failing
static <E extends Exception> IntSupplierWithException<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> IntSupplier unchecked(IntSupplierWithException<E> supplier)
Converts aIntSupplierWithExceptionto aIntSupplierthat 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(IntSupplierWithException, Function)
-
unchecked
static <E extends Exception> IntSupplier unchecked(IntSupplierWithException<E> supplier, Function<Exception,RuntimeException> exceptionMapper)
Converts aIntSupplierWithExceptionto aIntSupplierthat wraps exception toRuntimeExceptionby 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 or exceptionMapper is null- See Also:
PrimitiveReturnExceptionHandlerSupport.uncheck(),unchecked(IntSupplierWithException)
-
lifted
static <E extends Exception> IntSupplier lifted(IntSupplierWithException<E> supplier)
Converts aIntSupplierWithExceptionto a liftedIntSupplierreturning0in 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> IntSupplier ignored(IntSupplierWithException<E> supplier)
Converts aIntSupplierWithExceptionto a liftedIntSupplierreturning0in 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> IntSupplier ignored(IntSupplierWithException<E> supplier, int defaultValue)
Converts aIntSupplierWithExceptionto a liftedIntSupplierreturning 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(IntSupplierWithException)
-
defaultValue
default int 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
-
-