Decorates another
Map
to create objects in the map on demand.
When the {@link #get(Object)} method is called with a key that does notexist in the map, the factory is used to create the object. The created object will be added to the map using the requested key.
For instance:
Factory factory = new Factory() { public Object create() { return new Date(); } } Map lazy = Lazy.map(new HashMap(), factory); Object obj = lazy.get("NOW");
After the above code is executed,
obj
will contain a new
Date
instance. Furthermore, that
Date
instance is mapped to the "NOW" key in the map.
This class is Serializable from Commons Collections 3.1.
@author Stephen Colebourne
@author Matt Hall, John Watkinson, Paul Jack
@version $Revision: 1.1 $ $Date: 2005/10/11 17:05:32 $
@since Commons Collections 3.0