Package io.microsphere.lang.function
Interface ThrowableConsumer<T>
-
- Type Parameters:
T
- the source type
- 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 ThrowableConsumer<T>
Consumer
withThrowable
- Since:
- 1.0.0
- See Also:
Function
,Throwable
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
accept(T t)
Applies this function to the given argument.default void
execute(T t)
Executes#accept(T)
withthe default exception handling
static <T> void
execute(T t, ThrowableConsumer<T> consumer)
ExecutesThrowableConsumer
withthe default exception handling
static <T> void
execute(T t, ThrowableConsumer<T> consumer, java.util.function.BiConsumer<T,java.lang.Throwable> exceptionHandler)
ExecutesThrowableConsumer
with the customized exception handlingdefault void
execute(T t, java.util.function.BiConsumer<T,java.lang.Throwable> exceptionHandler)
Executes#accept(T)
with the customized exception handlingdefault void
handleException(T t, java.lang.Throwable failure)
Handle any exception that the#accept(T)
method throws
-
-
-
Method Detail
-
accept
void accept(T t) throws java.lang.Throwable
Applies this function to the given argument.- Parameters:
t
- the function argument- Throws:
java.lang.Throwable
- if met with any error
-
execute
default void execute(T t)
Executes#accept(T)
withthe default exception handling
- Parameters:
t
- the function argument- See Also:
#accept(T)
-
execute
default void execute(T t, java.util.function.BiConsumer<T,java.lang.Throwable> exceptionHandler) throws java.lang.NullPointerException
Executes#accept(T)
with the customized exception handling- Parameters:
t
- the function argumentexceptionHandler
- the handler to handle the function argument and the exception that the#accept(T)
method throws- Throws:
java.lang.NullPointerException
- ifexceptionHandler
isnull
-
handleException
default void handleException(T t, java.lang.Throwable failure)
Handle any exception that the#accept(T)
method throws- Parameters:
t
- the value to be consumedfailure
- the instance ofThrowable
-
execute
static <T> void execute(T t, ThrowableConsumer<T> consumer) throws java.lang.NullPointerException
ExecutesThrowableConsumer
withthe default exception handling
- Type Parameters:
T
- the source type- Parameters:
t
- the function argumentconsumer
-ThrowableConsumer
- Throws:
java.lang.NullPointerException
- ifconsumer
isnull
-
execute
static <T> void execute(T t, ThrowableConsumer<T> consumer, java.util.function.BiConsumer<T,java.lang.Throwable> exceptionHandler) throws java.lang.NullPointerException
ExecutesThrowableConsumer
with the customized exception handling- Type Parameters:
T
- the source type- Parameters:
t
- the function argumentconsumer
-ThrowableConsumer
exceptionHandler
- the handler to handle anyexception
that the#accept(T)
()} method throws- Throws:
java.lang.NullPointerException
- ifconsumer
andexceptionHandler
isnull
-
-