public interface CompositeTerminable extends Terminable, TerminableConsumer
Terminable made up of several other Terminables.
The close() method closes in LIFO (Last-In-First-Out) order.
Terminables can be reused. The instance is effectively
cleared on each invocation of close().
EMPTY| Modifier and Type | Method and Description |
|---|---|
default <T extends AutoCloseable> |
bind(T terminable)
Binds with the given terminable.
|
void |
cleanup()
Removes instances which have already been terminated.
|
void |
close()
Closes this composite terminable.
|
default void |
closeAndReportException()
Closes this resource, and prints the exception if one is thrown.
|
default CompositeClosingException |
closeSilently()
Silently closes this resource, and returns the exception if one is thrown.
|
static CompositeTerminable |
create()
Creates a new standalone
CompositeTerminable. |
static CompositeTerminable |
createWeak()
Creates a new standalone
CompositeTerminable, which wraps
contained terminables in WeakReferences. |
CompositeTerminable |
with(AutoCloseable autoCloseable)
Binds an
AutoCloseable with this composite closable. |
default CompositeTerminable |
withAll(AutoCloseable... autoCloseables)
Binds all given
AutoCloseable with this composite closable. |
default CompositeTerminable |
withAll(Iterable<? extends AutoCloseable> autoCloseables)
Binds all given
AutoCloseable with this composite closable. |
bindWith, isClosedbindModule@Nonnull static CompositeTerminable create()
CompositeTerminable.CompositeTerminable@Nonnull static CompositeTerminable createWeak()
CompositeTerminable, which wraps
contained terminables in WeakReferences.CompositeTerminablevoid close()
throws CompositeClosingException
close in interface AutoCloseableclose in interface TerminableCompositeClosingException - if any of the sub-terminables throw an
exception on close@Nullable default CompositeClosingException closeSilently()
TerminablecloseSilently in interface Terminabledefault void closeAndReportException()
TerminablecloseAndReportException in interface TerminableCompositeTerminable with(AutoCloseable autoCloseable)
AutoCloseable with this composite closable.
Note that implementations do not keep track of duplicate contained
terminables. If a single AutoCloseable is added twice, it will be
closed twice.
autoCloseable - the closable to bindNullPointerException - if the closable is nulldefault CompositeTerminable withAll(AutoCloseable... autoCloseables)
AutoCloseable with this composite closable.
Note that implementations do not keep track of duplicate contained
terminables. If a single AutoCloseable is added twice, it will be
closed twice.
Ignores null values.
autoCloseables - the closables to binddefault CompositeTerminable withAll(Iterable<? extends AutoCloseable> autoCloseables)
AutoCloseable with this composite closable.
Note that implementations do not keep track of duplicate contained
terminables. If a single AutoCloseable is added twice, it will be
closed twice.
Ignores null values.
autoCloseables - the closables to bind@Nonnull default <T extends AutoCloseable> T bind(@Nonnull T terminable)
TerminableConsumerbind in interface TerminableConsumerT - the terminable typeterminable - the terminable to bind withvoid cleanup()
Copyright © 2020. All rights reserved.