X
- The exception type which may get thrown by close()
.
If this is an IOException
, then the subclass can implement
the Closeable
interface, too.@CleanupObligation public abstract class Resource<X extends Exception> extends Object implements AutoCloseable
Constructor and Description |
---|
Resource() |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this resource.
|
boolean |
isOpen()
Returns
true if and only if this resource hasn't been
closed yet. |
protected void |
onAfterClose()
A hook which gets called by
close() unless this resource has
already been closed and unless onBeforeClose() throws an
exception. |
protected void |
onBeforeClose()
A hook which gets called by
close() unless this resource has
already been closed. |
@DischargesObligation public void close() throws X extends Exception
onBeforeClose()
gets called.
Upon successful termination, this resource gets marked as closed.
Next, the method onAfterClose()
gets called.close
in interface AutoCloseable
X
- At the discretion of the methods onBeforeClose()
and
onAfterClose()
.X extends Exception
public boolean isOpen()
true
if and only if this resource hasn't been
closed yet.protected void onAfterClose() throws X extends Exception
close()
unless this resource has
already been closed and unless onBeforeClose()
throws an
exception.Copyright © 2012–2014 Schlichtherle IT Services. All rights reserved.