Package net.didion.jwnl.util
Class TypeCheckingList
- java.lang.Object
-
- net.didion.jwnl.util.TypeCheckingList
-
- All Implemented Interfaces:
Cloneable
,Iterable
,Collection
,List
,DeepCloneable
- Direct Known Subclasses:
PointerTargetNodeList
,RelationshipList
public class TypeCheckingList extends Object implements List, DeepCloneable
Wrapper for a list that checks the type of arguments before putting them in the list. It also does type-checking on methods which iterate over the list so that they fail fast if the argument is not of the correct type.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
TypeCheckingList.TypeCheckingListIterator
-
Constructor Summary
Constructors Modifier Constructor Description TypeCheckingList(Class type)
TypeCheckingList(List backingList, Class type)
protected
TypeCheckingList(List backingList, Class type, Class parentType)
Create a new Type checking list that checks for type type, but only if parentType is equal to, a super class/interface of, or an interface implemented by type.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int index, Object o)
boolean
add(Object o)
boolean
addAll(int index, Collection c)
boolean
addAll(Collection c)
void
clear()
Object
clone()
Create a shallow clone of the objectboolean
contains(Object o)
boolean
containsAll(Collection c)
protected List
copyBackingList()
Make a copy of the wrapped list - used by subclasses when the overriding the clone methodObject
deepClone()
Create a deep clone of the objectboolean
equals(Object obj)
Object
get(int index)
Class
getType()
protected TypeCheckingList.TypeCheckingListIterator
getTypeCheckingListIterator()
protected TypeCheckingList.TypeCheckingListIterator
getTypeCheckingListIterator(int index)
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)
Object[]
toArray()
Object[]
toArray(Object[] a)
-
-
-
Constructor Detail
-
TypeCheckingList
public TypeCheckingList(Class type)
-
-
Method Detail
-
getType
public Class getType()
-
clone
public Object clone() throws CloneNotSupportedException
Description copied from interface:DeepCloneable
Create a shallow clone of the object- Specified by:
clone
in interfaceDeepCloneable
- Overrides:
clone
in classObject
- Throws:
CloneNotSupportedException
-
copyBackingList
protected List copyBackingList() throws CloneNotSupportedException
Make a copy of the wrapped list - used by subclasses when the overriding the clone method- Throws:
CloneNotSupportedException
-
deepClone
public Object deepClone() throws UnsupportedOperationException
Description copied from interface:DeepCloneable
Create a deep clone of the object- Specified by:
deepClone
in interfaceDeepCloneable
- Throws:
UnsupportedOperationException
-
equals
public boolean equals(Object obj)
-
add
public boolean add(Object o)
- Specified by:
add
in interfaceCollection
- Specified by:
add
in interfaceList
-
addAll
public boolean addAll(Collection c)
- Specified by:
addAll
in interfaceCollection
- Specified by:
addAll
in interfaceList
-
addAll
public boolean addAll(int index, Collection c)
-
contains
public boolean contains(Object o)
- Specified by:
contains
in interfaceCollection
- Specified by:
contains
in interfaceList
-
containsAll
public boolean containsAll(Collection c)
- Specified by:
containsAll
in interfaceCollection
- Specified by:
containsAll
in interfaceList
-
lastIndexOf
public int lastIndexOf(Object o)
- Specified by:
lastIndexOf
in interfaceList
-
remove
public boolean remove(Object o)
- Specified by:
remove
in interfaceCollection
- Specified by:
remove
in interfaceList
-
listIterator
public ListIterator listIterator()
- Specified by:
listIterator
in interfaceList
-
listIterator
public ListIterator listIterator(int index)
- Specified by:
listIterator
in interfaceList
-
getTypeCheckingListIterator
protected TypeCheckingList.TypeCheckingListIterator getTypeCheckingListIterator()
-
getTypeCheckingListIterator
protected TypeCheckingList.TypeCheckingListIterator getTypeCheckingListIterator(int index)
-
size
public int size()
- Specified by:
size
in interfaceCollection
- Specified by:
size
in interfaceList
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfaceCollection
- Specified by:
isEmpty
in interfaceList
-
iterator
public Iterator iterator()
-
toArray
public Object[] toArray()
- Specified by:
toArray
in interfaceCollection
- Specified by:
toArray
in interfaceList
-
toArray
public Object[] toArray(Object[] a)
- Specified by:
toArray
in interfaceCollection
- Specified by:
toArray
in interfaceList
-
removeAll
public boolean removeAll(Collection c)
- Specified by:
removeAll
in interfaceCollection
- Specified by:
removeAll
in interfaceList
-
retainAll
public boolean retainAll(Collection c)
- Specified by:
retainAll
in interfaceCollection
- Specified by:
retainAll
in interfaceList
-
clear
public void clear()
- Specified by:
clear
in interfaceCollection
- Specified by:
clear
in interfaceList
-
-