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 Texecute()Executeget()withthe default exception handlingstatic <T> Texecute(ThrowableSupplier<T> supplier)ExecutesThrowableSupplierwiththe default exception handlingstatic <T> Texecute(ThrowableSupplier<T> supplier, java.util.function.Function<java.lang.Throwable,T> exceptionHandler)ExecutesThrowableSupplierwith the customizedexceptionhandlingdefault Texecute(java.util.function.Function<java.lang.Throwable,T> exceptionHandler)Executeget()with the customizedexceptionhandlingTget()Applies this function to the given argument.default ThandleException(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 customizedexceptionhandling
-
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
ExecutesThrowableSupplierwiththe default exception handling- Type Parameters:
T- the supplied type- Parameters:
supplier-ThrowableSupplier- Returns:
- the result after execution
- Throws:
java.lang.NullPointerException- ifsupplierisnull
-
execute
static <T> T execute(ThrowableSupplier<T> supplier, java.util.function.Function<java.lang.Throwable,T> exceptionHandler) throws java.lang.NullPointerException
ExecutesThrowableSupplierwith the customizedexceptionhandling- Type Parameters:
T- the supplied type- Parameters:
supplier-ThrowableSupplierexceptionHandler- the handler to handle anyexceptionthat theget()method throws- Returns:
- the result after execution
- Throws:
java.lang.NullPointerException- ifsupplierorexceptionHandlerisnull
-
-