| Modifier and Type | Field and Description |
|---|---|
static Closeable |
NOOP
A closable which no-ops on
close(react.Closeable) and throws an exception for all other
methods. |
| Constructor and Description |
|---|
Util() |
| Modifier and Type | Method and Description |
|---|---|
static Closeable |
close(Closeable con)
Closes
con and returns NOOP. |
static Closeable |
join(Closeable... cons)
Creates a closable that closes multiple connections at once.
|
public static final Closeable NOOP
close(react.Closeable) and throws an exception for all other
methods. This is for the following code pattern:
Closable _conn = Closeable.Util.NOOP;
void open () {
_conn = whatever.connect(...);
}
void close () {
_conn = Closeable.Util.close(_conn);
}
In that it allows close to avoid a null check if it's possible for
close to be called with no call to open or repeatedly.Copyright © 2017. All rights reserved.