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 classTypeCheckingList.TypeCheckingListIterator
-
Constructor Summary
Constructors Modifier Constructor Description TypeCheckingList(Class type)TypeCheckingList(List backingList, Class type)protectedTypeCheckingList(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 voidadd(int index, Object o)booleanadd(Object o)booleanaddAll(int index, Collection c)booleanaddAll(Collection c)voidclear()Objectclone()Create a shallow clone of the objectbooleancontains(Object o)booleancontainsAll(Collection c)protected ListcopyBackingList()Make a copy of the wrapped list - used by subclasses when the overriding the clone methodObjectdeepClone()Create a deep clone of the objectbooleanequals(Object obj)Objectget(int index)ClassgetType()protected TypeCheckingList.TypeCheckingListIteratorgetTypeCheckingListIterator()protected TypeCheckingList.TypeCheckingListIteratorgetTypeCheckingListIterator(int index)intindexOf(Object o)booleanisEmpty()Iteratoriterator()intlastIndexOf(Object o)ListIteratorlistIterator()ListIteratorlistIterator(int index)Objectremove(int index)booleanremove(Object o)booleanremoveAll(Collection c)booleanretainAll(Collection c)Objectset(int index, Object element)intsize()ListsubList(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:DeepCloneableCreate a shallow clone of the object- Specified by:
clonein interfaceDeepCloneable- Overrides:
clonein 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:DeepCloneableCreate a deep clone of the object- Specified by:
deepClonein interfaceDeepCloneable- Throws:
UnsupportedOperationException
-
equals
public boolean equals(Object obj)
-
add
public boolean add(Object o)
- Specified by:
addin interfaceCollection- Specified by:
addin interfaceList
-
addAll
public boolean addAll(Collection c)
- Specified by:
addAllin interfaceCollection- Specified by:
addAllin interfaceList
-
addAll
public boolean addAll(int index, Collection c)
-
contains
public boolean contains(Object o)
- Specified by:
containsin interfaceCollection- Specified by:
containsin interfaceList
-
containsAll
public boolean containsAll(Collection c)
- Specified by:
containsAllin interfaceCollection- Specified by:
containsAllin interfaceList
-
lastIndexOf
public int lastIndexOf(Object o)
- Specified by:
lastIndexOfin interfaceList
-
remove
public boolean remove(Object o)
- Specified by:
removein interfaceCollection- Specified by:
removein interfaceList
-
listIterator
public ListIterator listIterator()
- Specified by:
listIteratorin interfaceList
-
listIterator
public ListIterator listIterator(int index)
- Specified by:
listIteratorin interfaceList
-
getTypeCheckingListIterator
protected TypeCheckingList.TypeCheckingListIterator getTypeCheckingListIterator()
-
getTypeCheckingListIterator
protected TypeCheckingList.TypeCheckingListIterator getTypeCheckingListIterator(int index)
-
size
public int size()
- Specified by:
sizein interfaceCollection- Specified by:
sizein interfaceList
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfaceCollection- Specified by:
isEmptyin interfaceList
-
iterator
public Iterator iterator()
-
toArray
public Object[] toArray()
- Specified by:
toArrayin interfaceCollection- Specified by:
toArrayin interfaceList
-
toArray
public Object[] toArray(Object[] a)
- Specified by:
toArrayin interfaceCollection- Specified by:
toArrayin interfaceList
-
removeAll
public boolean removeAll(Collection c)
- Specified by:
removeAllin interfaceCollection- Specified by:
removeAllin interfaceList
-
retainAll
public boolean retainAll(Collection c)
- Specified by:
retainAllin interfaceCollection- Specified by:
retainAllin interfaceList
-
clear
public void clear()
- Specified by:
clearin interfaceCollection- Specified by:
clearin interfaceList
-
-