ro.isdc.wro.util
Class LazyInitializer<T>
java.lang.Object
ro.isdc.wro.util.LazyInitializer<T>
- Direct Known Subclasses:
- DestroyableLazyInitializer
public abstract class LazyInitializer<T>
- extends Object
A clone of LazyInitializer
, which doesn't throw any checked exception when get method is invoked.
- Since:
- 1.4.6
- Author:
- Alex Objelean
Field Summary |
protected T |
object
Stores the managed object. |
Method Summary |
T |
get()
Returns the object wrapped by this instance. |
protected abstract T |
initialize()
Creates and initializes the object managed by this LazyInitializer . |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
object
protected volatile T object
- Stores the managed object.
LazyInitializer
public LazyInitializer()
get
public final T get()
- Returns the object wrapped by this instance. On first access the object is created. After that it is cached and can
be accessed pretty fast.
- Returns:
- the object initialized by this
LazyInitializer
the object
initialize
protected abstract T initialize()
- Creates and initializes the object managed by this
LazyInitializer
. This method is called by get()
when the object is accessed for the first time. An implementation can focus on the creation of the object. No
synchronization is needed, as this is already handled by get()
.
- Returns:
- the managed data object
Copyright © 2008-2013. All Rights Reserved.