Package dev.getelements.elements.rt.util
Interface FinallyAction
- All Superinterfaces:
AutoCloseable,Runnable
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
A
FunctionalInterface which performs a series of actions when it is closed. Ideally to be used in a finally
block or in a try-with-resources to chain additional destruction steps.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final org.slf4j.LoggerThe defaultLoggerused byFinallyActioninstances. -
Method Summary
Modifier and TypeMethodDescriptionstatic FinallyActionbegin()Begins the finally action.static FinallyActionbegin(org.slf4j.Logger logger) Begins the finally action.default voidclose()default org.slf4j.LoggerGets aLoggerused to log exceptions thrown while processing theFinallyAction.default FinallyActionChains thisFinallyActionto the nextFinallyAction.default FinallyActionthenClose(AutoCloseable closeable) static FinallyActionwith(FinallyAction first) Convenience method to start a chain ofFinallyActioninstances.
-
Field Details
-
logger
static final org.slf4j.Logger loggerThe defaultLoggerused byFinallyActioninstances.
-
-
Method Details
-
begin
Begins the finally action.- Returns:
-
begin
Begins the finally action.- Returns:
-
getLogger
default org.slf4j.Logger getLogger()Gets aLoggerused to log exceptions thrown while processing theFinallyAction. The default returnslogger.- Returns:
- the
Logger
-
then
Chains thisFinallyActionto the nextFinallyAction.- Parameters:
next-- Returns:
-
thenClose
-
close
default void close()- Specified by:
closein interfaceAutoCloseable
-
with
Convenience method to start a chain ofFinallyActioninstances.- Parameters:
first- the next in the chain- Returns:
- a new
FinallyAction
-