T - The type to createpublic abstract class AbstractSynchronousLazy<T> extends java.lang.Object implements CreateAndHold<T>
An implementation of CreateAndHold which initializes after a double-checked lock.
Example implementation:
public static CreateAndHold<MyCrazySingletonConfig> myCrazySingletonConfig = new AbstractSynchronousLazy<MyCrazySingletonConfig>() {
@Override
protected MyCrazySingletonConfig create() {
final MyCrazySingletonConfig newConfig = .....
return newConfig;
}
};
| Constructor and Description |
|---|
AbstractSynchronousLazy() |
| Modifier and Type | Method and Description |
|---|---|
protected abstract T |
create()
The creation function.
|
T |
getObject()
Returns the object, creating it first if necessary.
|
boolean |
isCreated()
Check if object of type T is created
|
public boolean isCreated()
CreateAndHoldCheck if object of type T is created
isCreated in interface CreateAndHold<T>protected abstract T create() throws java.lang.Throwable
The creation function. This function will only be called once. If the implementation gives an error, that error will be retained and rethrown.
java.lang.Throwablepublic final T getObject()
CreateAndHoldReturns the object, creating it first if necessary.
getObject in interface CreateAndHold<T>