X - - The type of data this var returns.public abstract class SingletonProvider<X> extends Object implements Provider<X>, ProvidesValue<X>
initialValue() on first load and replaces the initializer with a pojo getter.
This allows for easy wrapping of lazily-loaded singletons without null-checking on every access.| Modifier and Type | Class and Description |
|---|---|
class |
SingletonProvider.NullCheckOnGet |
ProvidesValue.NoOp<X>| Modifier and Type | Field and Description |
|---|---|
protected Provider<X> |
proxy
The proxy object will override itself on first load with a bare pojo-based provider.
|
| Constructor and Description |
|---|
SingletonProvider() |
| Modifier and Type | Method and Description |
|---|---|
protected Provider<X> |
createImmutableProvider(X init)
Return a new proxy provider which just returns the set field.
|
X |
get()
This method is final so the compiler can optimize the call.
|
protected abstract X |
initialValue()
Called once, on first .get().
|
boolean |
isSet()
Tells whether or not this singleton is already set by instanceof checking
the pojo class return from
createImmutableProvider(Object). |
protected void |
onCreate(X init)
Called whenever the object is initialized.
|
protected Provider<X> createImmutableProvider(X init)
SingletonProvider.NullCheckOnGet,
or you will contract a case of recursion sickness.init - - A non-null value to provide immutablyImmutableProvider, THEN YOU MUST OVERRIDE isSet() AS WELL.public boolean isSet()
createImmutableProvider(Object).
IF YOU OVERRIDE createImmutableProvider(Object), YOU MUST ALSO OVERRIDE isSet().protected void onCreate(X init)
get(),
and every successful get() after a call to #reset()init - protected abstract X initialValue()
public final X get()
Copyright © December 07, 2012–2015 The Internet Party. All rights reserved.