Package io.microsphere.lang.function
Interface ThrowableSupplier<T>
-
- 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 ThrowableSupplier<T>
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default T
execute()
Executeget()
withthe default exception handling
static <T> T
execute(ThrowableSupplier<T> supplier)
ExecutesThrowableSupplier
withthe default exception handling
static <T> T
execute(ThrowableSupplier<T> supplier, java.util.function.Function<java.lang.Throwable,T> exceptionHandler)
ExecutesThrowableSupplier
with the customizedexception
handlingdefault T
execute(java.util.function.Function<java.lang.Throwable,T> exceptionHandler)
Executeget()
with the customizedexception
handlingT
get()
Applies this function to the given argument.default T
handleException(java.lang.Throwable failure)
Handle any exception that theget()
method throws
-
-
-
Method Detail
-
get
T get() throws java.lang.Throwable
Applies this function to the given argument.- Returns:
- the supplied result
- Throws:
java.lang.Throwable
- if met with any error
-
execute
default T execute()
Executeget()
withthe default exception handling
- Returns:
- the supplied result
- See Also:
get()
-
execute
default T execute(java.util.function.Function<java.lang.Throwable,T> exceptionHandler)
Executeget()
with the customizedexception
handling
-
handleException
default T handleException(java.lang.Throwable failure)
Handle any exception that theget()
method throws- Parameters:
failure
- the instance ofThrowable
- Returns:
- the result after the exception handling
-
execute
static <T> T execute(ThrowableSupplier<T> supplier) throws java.lang.NullPointerException
ExecutesThrowableSupplier
withthe default exception handling
- Type Parameters:
T
- the supplied type- Parameters:
supplier
-ThrowableSupplier
- Returns:
- the result after execution
- Throws:
java.lang.NullPointerException
- ifsupplier
isnull
-
execute
static <T> T execute(ThrowableSupplier<T> supplier, java.util.function.Function<java.lang.Throwable,T> exceptionHandler) throws java.lang.NullPointerException
ExecutesThrowableSupplier
with the customizedexception
handling- Type Parameters:
T
- the supplied type- Parameters:
supplier
-ThrowableSupplier
exceptionHandler
- the handler to handle anyexception
that theget()
method throws- Returns:
- the result after execution
- Throws:
java.lang.NullPointerException
- ifsupplier
orexceptionHandler
isnull
-
-