org.gjt.rec.util
Class HomogeneousList
java.lang.Object
|
+--org.gjt.rec.util.HomogeneousList
- All Implemented Interfaces:
- Collection, List, Serializable
- public final class HomogeneousList
- extends Object
- implements List, Serializable
A List proxy that enforces the invariant that all of its list
elements are of the same type. They will not necessarily all be of
the same class if the configured element class is an interface or
can be subclassed.
- Author:
- Neil Stockbridge
- See Also:
List
,
Serialized Form
Constructor Summary |
HomogeneousList(Class elementClass)
Constructs a new HomogeneousList with the default underlying list but a
particular element type. |
HomogeneousList(List underlyingList,
Class elementClass)
Constructs a new HomogeneousList with a particular underlying list and a
particular element type. |
REVISION
public static final String REVISION
- See Also:
- Constant Field Values
HomogeneousList
public HomogeneousList(Class elementClass)
- Constructs a new HomogeneousList with the default underlying list but a
particular element type.
- Parameters:
elementClass
- the only type of element that this list
will accept
- Throws:
NullPointerException
- if (elementClass) is null
HomogeneousList
public HomogeneousList(List underlyingList,
Class elementClass)
- Constructs a new HomogeneousList with a particular underlying list and a
particular element type.
- Parameters:
underlyingList
- the list underlying this one, which will
be used to store the elementselementClass
- the only type of element that this list
will accept
- Throws:
NullPointerException
- if either argument is null
size
public int size()
- Specified by:
size
in interface List
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interface List
contains
public boolean contains(Object obj)
- Specified by:
contains
in interface List
iterator
public Iterator iterator()
- Specified by:
iterator
in interface List
toArray
public Object[] toArray()
- Specified by:
toArray
in interface List
toArray
public Object[] toArray(Object[] array)
- Specified by:
toArray
in interface List
add
public boolean add(Object obj)
- Specified by:
add
in interface List
remove
public boolean remove(Object obj)
- Specified by:
remove
in interface List
containsAll
public boolean containsAll(Collection collection)
- Specified by:
containsAll
in interface List
addAll
public boolean addAll(Collection collection)
- Specified by:
addAll
in interface List
addAll
public boolean addAll(int index,
Collection collection)
- Specified by:
addAll
in interface List
removeAll
public boolean removeAll(Collection collection)
- Specified by:
removeAll
in interface List
retainAll
public boolean retainAll(Collection collection)
- Specified by:
retainAll
in interface List
clear
public void clear()
- Specified by:
clear
in interface List
equals
public boolean equals(Object obj)
- Specified by:
equals
in interface List
- Overrides:
equals
in class Object
hashCode
public int hashCode()
- Specified by:
hashCode
in interface List
- Overrides:
hashCode
in class Object
get
public Object get(int index)
- Specified by:
get
in interface List
set
public Object set(int index,
Object obj)
- Specified by:
set
in interface List
add
public void add(int index,
Object obj)
- Specified by:
add
in interface List
remove
public Object remove(int index)
- Specified by:
remove
in interface List
indexOf
public int indexOf(Object obj)
- Specified by:
indexOf
in interface List
lastIndexOf
public int lastIndexOf(Object obj)
- Specified by:
lastIndexOf
in interface List
listIterator
public ListIterator listIterator()
- Specified by:
listIterator
in interface List
listIterator
public ListIterator listIterator(int index)
- Specified by:
listIterator
in interface List
subList
public List subList(int fromIndex,
int toIndex)
- Specified by:
subList
in interface List