Decorates another
List to create objects in the list on demand.
When the {@link #get(int)} method is called with an index greater thanthe size of the list, the list will automatically grow in size and return a new object from the specified factory. The gaps will be filled by null. If a get method call encounters a null, it will be replaced with a new object from the factory. Thus this list is unsuitable for storing null objects.
For instance:
Factory factory = new Factory() { public Object create() { return new Date(); } } List lazy = LazyList.decorate(new ArrayList(), factory); Object obj = lazy.get(3); After the above code is executed,
obj will contain a new
Date instance. Furthermore, that
Date instance is the fourth element in the list. The first, second, and third element are all set to
null.
This class is Serializable from Commons Collections 3.1.
@author Stephen Colebourne
@author Arron Bates
@author Paul Jack
@version $Revision: 1.1 $ $Date: 2005/10/11 17:05:32 $
@since Commons Collections 3.0