public class SequentialCloseable extends java.lang.Object implements java.io.Closeable, Cancelable
Closeables assigned to this container after it was closed is ignored and the incoming closeable is closed instantly.
The implementation is thread-safe.
| Modifier and Type | Field and Description |
|---|---|
protected java.io.Closeable |
current
The current closeable.
|
protected boolean |
done
Indicate that this container was closed.
|
protected java.util.concurrent.locks.Lock |
lock
The lock guarding the contents.
|
| Constructor and Description |
|---|
SequentialCloseable() |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
closeSilently()
Closes this container silently.
|
java.io.Closeable |
get() |
boolean |
isClosed() |
void |
set(java.io.Closeable c)
Replaces the current closeable with the new closeable.
|
protected final java.util.concurrent.locks.Lock lock
protected java.io.Closeable current
protected boolean done
public void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOException@Nullable public java.io.Closeable get()
public void set(@Nullable
java.io.Closeable c)
c - the closeablepublic boolean isClosed()
isClosed in interface Cancelablepublic void closeSilently()