public interface CompositeAutoClosable extends AutoCloseable
AutoCloseable made up of several other
AutoCloseables.
The close() method closes in LIFO (Last-In-First-Out) order.
CompositeAutoClosables can be reused. The instance is effectively
cleared on each invocation of close().
| Modifier and Type | Method and Description |
|---|---|
CompositeAutoClosable |
bind(AutoCloseable autoCloseable)
Binds an
AutoCloseable with this composite closable. |
default CompositeAutoClosable |
bindAll(AutoCloseable... autoCloseables)
Binds all given
AutoCloseable with this composite closable. |
default CompositeAutoClosable |
bindAll(Iterable<? extends AutoCloseable> autoCloseables)
Binds all given
AutoCloseable with this composite closable. |
void |
close()
Closes this composite resource.
|
default void |
closeAndReportExceptions()
Closes this composite resource, but simply prints any resultant
exceptions instead of rethrowing them.
|
default void |
closeSilently()
Closes this composite resource, but doesn't rethrow or print any
exceptions.
|
static CompositeAutoClosable |
create()
Creates a new standalone
CompositeAutoClosable. |
static CompositeAutoClosable create()
CompositeAutoClosable.CompositeAutoClosable.CompositeAutoClosable bind(AutoCloseable autoCloseable)
AutoCloseable with this composite closable.
Note that implementations do not keep track of duplicate contains
closables. If a single AutoCloseable is added twice, it will be
closed twice.
autoCloseable - the closable to bindNullPointerException - if the closable is nulldefault CompositeAutoClosable bindAll(AutoCloseable... autoCloseables)
AutoCloseable with this composite closable.
Note that implementations do not keep track of duplicate contains
closables. If a single AutoCloseable is added twice, it will be
closed twice.
Ignores null values.
autoCloseables - the closables to binddefault CompositeAutoClosable bindAll(Iterable<? extends AutoCloseable> autoCloseables)
AutoCloseable with this composite closable.
Note that implementations do not keep track of duplicate contains
closables. If a single AutoCloseable is added twice, it will be
closed twice.
Ignores null values.
autoCloseables - the closables to bindvoid close()
throws CompositeClosingException
close in interface AutoCloseableCompositeClosingException - if any of the sub instances throw an
exception whilst closingdefault void closeSilently()
close()default void closeAndReportExceptions()
Copyright © 2018. All rights reserved.