Interface LongSupplierWithException<E extends Exception>
-
- Type Parameters:
E- the type of the potential exception of the operation
- All Superinterfaces:
ExceptionHandlerSupport<LongSupplier,LongSupplier,LongSupplierWithException<E>>,PrimitiveReturnExceptionHandlerSupport<LongSupplier,LongSupplierWithException<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 LongSupplierWithException<E extends Exception> extends PrimitiveReturnExceptionHandlerSupport<LongSupplier,LongSupplierWithException<E>>
Represents a supplier oflong-valued results and may throw exception. This is thelong-producing primitive specialization ofSupplierWithException.General contract
long getAsLong() throws E- The functional method.- uncheck - Return a
LongSupplier - lift - Return a
LongSupplier - ignore - Return a
LongSupplier
There is no requirement that a distinct result be returned each time the supplier is invoked.
- See Also:
SupplierWithException
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default longdefaultValue()Defines the default value returned by the ignore and ignored method.static <E extends Exception>
LongSupplierWithException<E>failing(Supplier<E> exceptionBuilder)Returns a supplier that always throw exception.longgetAsLong()Gets a result.default LongSupplierignore()Converts thisLongSupplierWithExceptionto a liftedLongSupplierreturning0in case of exception.static <E extends Exception>
LongSupplierignored(LongSupplierWithException<E> supplier)Converts aLongSupplierWithExceptionto a liftedLongSupplierreturning0in case of exception.static <E extends Exception>
LongSupplierignored(LongSupplierWithException<E> supplier, long defaultValue)Converts aLongSupplierWithExceptionto a liftedLongSupplierreturning a default value in case of exception.static <E extends Exception>
LongSupplierlifted(LongSupplierWithException<E> supplier)Converts aLongSupplierWithExceptionto a liftedLongSupplierreturning0in case of exception.default LongSupplieruncheck()Converts thisLongSupplierWithExceptionto aLongSupplierthat wraps exception toRuntimeException.static <E extends Exception>
LongSupplierunchecked(LongSupplierWithException<E> supplier)Converts aLongSupplierWithExceptionto aLongSupplierthat wraps exception toRuntimeException.static <E extends Exception>
LongSupplierunchecked(LongSupplierWithException<E> supplier, Function<Exception,RuntimeException> exceptionMapper)Converts aLongSupplierWithExceptionto aLongSupplierthat wraps exception toRuntimeExceptionby using the provided mapping function.default LongSupplieruncheckOrIgnore(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
lift
-
-
-
-
Method Detail
-
getAsLong
long getAsLong() throws E extends Exception
Gets a result.- Returns:
- a result
- Throws:
E- any exceptionE extends Exception- See Also:
LongSupplier.getAsLong()
-
uncheckOrIgnore
default LongSupplier uncheckOrIgnore(boolean uncheck)
Description copied from interface:PrimitiveReturnExceptionHandlerSupportUsed internally to implements the ignore or uncheck operation.- Specified by:
uncheckOrIgnorein interfacePrimitiveReturnExceptionHandlerSupport<LongSupplier,LongSupplierWithException<E extends Exception>>- Parameters:
uncheck- create unchecked version of the function when true, else ignored version.- Returns:
- the function
-
uncheck
default LongSupplier uncheck()
Converts thisLongSupplierWithExceptionto aLongSupplierthat wraps exception toRuntimeException.- Specified by:
uncheckin interfaceExceptionHandlerSupport<LongSupplier,LongSupplier,LongSupplierWithException<E extends Exception>>- Specified by:
uncheckin interfacePrimitiveReturnExceptionHandlerSupport<LongSupplier,LongSupplierWithException<E extends Exception>>- Returns:
- the unchecked supplier
- See Also:
unchecked(LongSupplierWithException),unchecked(LongSupplierWithException, Function)
-
ignore
default LongSupplier ignore()
Converts thisLongSupplierWithExceptionto a liftedLongSupplierreturning0in case of exception.- Specified by:
ignorein interfaceExceptionHandlerSupport<LongSupplier,LongSupplier,LongSupplierWithException<E extends Exception>>- Specified by:
ignorein interfacePrimitiveReturnExceptionHandlerSupport<LongSupplier,LongSupplierWithException<E extends Exception>>- Returns:
- the supplier that ignore error
- See Also:
ignored(LongSupplierWithException)
-
failing
static <E extends Exception> LongSupplierWithException<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> LongSupplier unchecked(LongSupplierWithException<E> supplier)
Converts aLongSupplierWithExceptionto aLongSupplierthat 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:
uncheck(),unchecked(LongSupplierWithException, Function)
-
unchecked
static <E extends Exception> LongSupplier unchecked(LongSupplierWithException<E> supplier, Function<Exception,RuntimeException> exceptionMapper)
Converts aLongSupplierWithExceptionto aLongSupplierthat 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:
uncheck(),unchecked(LongSupplierWithException)
-
lifted
static <E extends Exception> LongSupplier lifted(LongSupplierWithException<E> supplier)
Converts aLongSupplierWithExceptionto a liftedLongSupplierreturning0in 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> LongSupplier ignored(LongSupplierWithException<E> supplier)
Converts aLongSupplierWithExceptionto a liftedLongSupplierreturning0in 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:
ignore()
-
ignored
static <E extends Exception> LongSupplier ignored(LongSupplierWithException<E> supplier, long defaultValue)
Converts aLongSupplierWithExceptionto a liftedLongSupplierreturning 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:
ignore(),ignored(LongSupplierWithException)
-
defaultValue
default long 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
-
-