public class LazyList
extends Object
implements List, Serializable
 LazyList wraps around a standard ArrayList and ensures that any get() activity which returns a null
 value will return a freshly instantiated item instead.
This class should allow the Component Builder framework to function well within a form-based UI, where child components are added / removed at the web page level.
This class is similar in intent to the Apache commons-collections version, but my implementation differs in the following ways:
| Constructor and Description | 
|---|
LazyList(Class instantiatingClass)
Base constructor for a lazy list. 
 | 
LazyList(List<?> list,
        Class instantiatingClass)
Complete constructor for a lazy list. 
 | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
add(int index,
   Object element)  | 
boolean | 
add(Object o)  | 
boolean | 
addAll(Collection c)  | 
boolean | 
addAll(int index,
      Collection c)  | 
void | 
clear()  | 
boolean | 
contains(Object o)  | 
boolean | 
containsAll(Collection c)  | 
boolean | 
equals(Object object)  | 
Object | 
get(int index)
Intercepts the get() method to create new items if get() might return null. 
 | 
Class | 
getInstantiatingClass()
Accessor for the class that will be instantiated lazily 
 | 
int | 
hashCode()  | 
int | 
indexOf(Object o)  | 
boolean | 
isEmpty()  | 
Iterator<?> | 
iterator()  | 
int | 
lastIndexOf(Object o)  | 
ListIterator<?> | 
listIterator()  | 
ListIterator<?> | 
listIterator(int index)  | 
Object | 
remove(int index)  | 
boolean | 
remove(Object o)  | 
boolean | 
removeAll(Collection c)  | 
boolean | 
retainAll(Collection c)  | 
Object | 
set(int index,
   Object element)  | 
int | 
size()  | 
List<?> | 
subList(int fromIndex,
       int toIndex)
Intercepts the subList method to maintain a LazyList on the returned sublist. 
 | 
Object[] | 
toArray()  | 
Object[] | 
toArray(Object[] a)  | 
String | 
toString()  | 
public LazyList(Class instantiatingClass)
instantiatingClass - the class that will be instantiated when get() returns nullIllegalArgumentException - if either the list or class are nullpublic LazyList(List<?> list,
                Class instantiatingClass)
list - the underlying list that will be wrappedinstantiatingClass - the class that will be instantiated when get() returns nullIllegalArgumentException - if either the list or class are nullpublic boolean equals(Object object)
equals in interface Collectionequals in interface Listequals in class ObjectObject.equals(Object)public int hashCode()
hashCode in interface CollectionhashCode in interface ListhashCode in class ObjectObject.hashCode()public String toString()
toString in class ObjectObject.toString()public Object get(int index)
If an index is requested beyond the bounds of the list size, the list will extend to that position and interim positions will also be instantiated.
get in interface Listindex - the index to retrievepublic List<?> subList(int fromIndex,
                       int toIndex)
subList in interface ListList.subList(int, int)public Class getInstantiatingClass()
public int size()
size in interface Collectionsize in interface ListList.size()public boolean isEmpty()
isEmpty in interface CollectionisEmpty in interface ListList.isEmpty()public boolean contains(Object o)
contains in interface Collectioncontains in interface ListList.contains(java.lang.Object)public Iterator<?> iterator()
iterator in interface Iterableiterator in interface Collectioniterator in interface ListList.iterator()public Object[] toArray()
toArray in interface CollectiontoArray in interface ListList.toArray()public Object[] toArray(Object[] a)
toArray in interface CollectiontoArray in interface ListList.toArray(Object[])public boolean add(Object o)
add in interface Collectionadd in interface ListList.add(java.lang.Object)public boolean remove(Object o)
remove in interface Collectionremove in interface ListList.remove(java.lang.Object)public boolean containsAll(Collection c)
containsAll in interface CollectioncontainsAll in interface ListList.containsAll(java.util.Collection)public boolean addAll(Collection c)
addAll in interface CollectionaddAll in interface ListList.addAll(java.util.Collection)public boolean addAll(int index,
                      Collection c)
addAll in interface ListList.addAll(int, java.util.Collection)public boolean removeAll(Collection c)
removeAll in interface CollectionremoveAll in interface ListList.removeAll(java.util.Collection)public boolean retainAll(Collection c)
retainAll in interface CollectionretainAll in interface ListList.retainAll(java.util.Collection)public void clear()
clear in interface Collectionclear in interface ListList.clear()public Object set(int index,
                  Object element)
set in interface ListList.set(int, java.lang.Object)public void add(int index,
                Object element)
add in interface ListList.add(int, java.lang.Object)public Object remove(int index)
remove in interface ListList.remove(int)public int indexOf(Object o)
indexOf in interface ListList.indexOf(java.lang.Object)public int lastIndexOf(Object o)
lastIndexOf in interface ListList.lastIndexOf(java.lang.Object)public ListIterator<?> listIterator()
listIterator in interface ListList.listIterator()public ListIterator<?> listIterator(int index)
listIterator in interface ListList.listIterator(int)Copyright 2010 - 2019 by Brian Uri!
Generated on 09/15/2016 12:36 PM
https://ddmsence.urizone.net/