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
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 -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionTypeCheckingList(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
Modifier and TypeMethodDescriptionvoidbooleanbooleanaddAll(int index, Collection c) booleanaddAll(Collection c) voidclear()clone()Create a shallow clone of the objectbooleanbooleanprotected ListMake a copy of the wrapped list - used by subclasses when the overriding the clone methodCreate a deep clone of the objectbooleanget(int index) private ListgetList()getType()getTypeCheckingListIterator(int index) intprivate voidbooleanisEmpty()iterator()intlistIterator(int index) remove(int index) booleanbooleanbooleanintsize()subList(int fromIndex, int toIndex) Object[]toArray()Object[]private voidprivate voidMethods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, streamMethods inherited from interface java.util.List
hashCode, replaceAll, sort, spliterator
-
Field Details
-
_list
-
_type
-
_lastCheckedCollection
-
-
Constructor Details
-
TypeCheckingList
-
TypeCheckingList
-
TypeCheckingList
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 Details
-
init
-
getType
-
getList
-
clone
Description copied from interface:DeepCloneableCreate a shallow clone of the object- Specified by:
clonein interfaceDeepCloneable- Overrides:
clonein classObject- Throws:
CloneNotSupportedException
-
copyBackingList
Make a copy of the wrapped list - used by subclasses when the overriding the clone method- Throws:
CloneNotSupportedException
-
deepClone
Description copied from interface:DeepCloneableCreate a deep clone of the object- Specified by:
deepClonein interfaceDeepCloneable- Throws:
UnsupportedOperationException
-
equals
-
add
- Specified by:
addin interfaceCollection- Specified by:
addin interfaceList
-
add
-
addAll
- Specified by:
addAllin interfaceCollection- Specified by:
addAllin interfaceList
-
addAll
-
contains
- Specified by:
containsin interfaceCollection- Specified by:
containsin interfaceList
-
containsAll
- Specified by:
containsAllin interfaceCollection- Specified by:
containsAllin interfaceList
-
set
-
indexOf
-
lastIndexOf
- Specified by:
lastIndexOfin interfaceList
-
remove
- Specified by:
removein interfaceCollection- Specified by:
removein interfaceList
-
listIterator
- Specified by:
listIteratorin interfaceList
-
listIterator
- Specified by:
listIteratorin interfaceList
-
getTypeCheckingListIterator
-
getTypeCheckingListIterator
-
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
-
toArray
- Specified by:
toArrayin interfaceCollection- Specified by:
toArrayin interfaceList
-
toArray
- Specified by:
toArrayin interfaceCollection- Specified by:
toArrayin interfaceList
-
removeAll
- Specified by:
removeAllin interfaceCollection- Specified by:
removeAllin interfaceList
-
retainAll
- Specified by:
retainAllin interfaceCollection- Specified by:
retainAllin interfaceList
-
clear
public void clear()- Specified by:
clearin interfaceCollection- Specified by:
clearin interfaceList
-
get
-
remove
-
subList
-
typecheck
-
typecheck
-