public abstract class AbstractDestroyable extends java.lang.Object implements Destroyable
Abstract implementation of the Destroyable. Provides default implementations for all methods.
doDestroy(),
assertNotDestroyed()| Constructor and Description |
|---|
AbstractDestroyable() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
assertNotDestroyed() |
void |
destroy()
This method may be called to ask instance to release any locked resources
and to prepare itself to be properly garbage collected.
|
protected void |
doDestroy()
This method will be called only when
destroy() is called for the first time. |
boolean |
isDestroyed()
This method returns
true if this instance was already destroyed and cannot be used anymore. |
public final void destroy()
DestroyableThis method may be called to ask instance to release any locked resources and to prepare itself to be properly garbage collected.
Note: this method should not throw an exception for being called for the second (or more) time. If instance is already destroyed - method should exit without performing any actual functionality.
destroy in interface Destroyableprotected void doDestroy()
destroy() is called for the first time.public final boolean isDestroyed()
DestroyableThis method returns true if this instance was already destroyed and cannot be used anymore.
If this method returns true - it is a signal for other parts of the program to not perform any
additional calls on it.
If this method returns false - Destroyable.destroy() should be called when instance is not planned
to be used anymore.
isDestroyed in interface Destroyableprotected final void assertNotDestroyed()
throws java.lang.IllegalStateException
java.lang.IllegalStateException