cz.cuni.amis.utils
Class Lazy<T>

java.lang.Object
  extended by cz.cuni.amis.utils.Lazy<T>
Direct Known Subclasses:
SyncLazy

public abstract class Lazy<T>
extends java.lang.Object

Utility class for lazy initialization of objects.

THREAD-UNSAFE!


Field Summary
protected  T obj
           
 
Constructor Summary
Lazy()
           
 
Method Summary
protected abstract  T create()
          Creates lazy initialized object.
 T get()
          Synonym for getVal().
 T getVal()
          Deprecated.  
 void set(T val)
          Sets value that should be returned via get().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

obj

protected T obj
Constructor Detail

Lazy

public Lazy()
Method Detail

create

protected abstract T create()
Creates lazy initialized object.

Returns:

getVal

public T getVal()
Deprecated. 

Returns:
value created by create() (UNSYNCHRONIZED CREATION!)

get

public T get()
Synonym for getVal().

Returns:

set

public void set(T val)
Sets value that should be returned via get().

Parameters:
val -