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.Logger
The defaultLogger
used byFinallyAction
instances. -
Method Summary
Modifier and TypeMethodDescriptionstatic FinallyAction
begin()
Begins the finally action.static FinallyAction
begin
(org.slf4j.Logger logger) Begins the finally action.default void
close()
default org.slf4j.Logger
Gets aLogger
used to log exceptions thrown while processing theFinallyAction
.default FinallyAction
Chains thisFinallyAction
to the nextFinallyAction
.default FinallyAction
thenClose
(AutoCloseable closeable) static FinallyAction
with
(FinallyAction first) Convenience method to start a chain ofFinallyAction
instances.
-
Field Details
-
logger
static final org.slf4j.Logger loggerThe defaultLogger
used byFinallyAction
instances.
-
-
Method Details
-
begin
Begins the finally action.- Returns:
-
begin
Begins the finally action.- Returns:
-
getLogger
default org.slf4j.Logger getLogger()Gets aLogger
used to log exceptions thrown while processing theFinallyAction
. The default returnslogger
.- Returns:
- the
Logger
-
then
Chains thisFinallyAction
to the nextFinallyAction
.- Parameters:
next
-- Returns:
-
thenClose
-
close
default void close()- Specified by:
close
in interfaceAutoCloseable
-
with
Convenience method to start a chain ofFinallyAction
instances.- Parameters:
first
- the next in the chain- Returns:
- a new
FinallyAction
-