public class Closer extends Object implements AutoCloseable
Subclasses can override handleCloseException()
to decide what should
happen with exceptions thrown during close. The default behavior is to
log a warning and ignore the exception.
Constructor and Description |
---|
Closer() |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes all resources registered with
closeLater(AutoCloseable) . |
<CloseableType extends AutoCloseable> |
close(CloseableType o)
Close an object immediately, will not be closed "later".
|
void |
close(Collection<? extends AutoCloseable> objects)
Close given objects immediately, will not be closed "later".
|
<Obj extends AutoCloseable> |
closeLater(Obj o)
Add a resource to be closed with
close() . |
boolean |
remove(AutoCloseable o)
Remove object from collection so close will not be called later.
|
String |
toString() |
public <Obj extends AutoCloseable> Obj closeLater(Obj o)
close()
.
Resources will be closed in reverse registration order.
Obj
- The type of objects to be closed by this Closero
- Object to note for later closingpublic boolean remove(AutoCloseable o)
o
- Object to be removed from this ClosercloseLater(AutoCloseable)
public void close()
closeLater(AutoCloseable)
.close
in interface AutoCloseable
public void close(Collection<? extends AutoCloseable> objects)
objects
- The collection of objects to closepublic <CloseableType extends AutoCloseable> CloseableType close(CloseableType o)
If the object is registered on the list of resources to be closed later by this Closer, it will be removed from that list.
CloseableType
- The type of objects that can be closed by this Closero
- The object being closedCopyright © 2019 Franz Inc.. All rights reserved.