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) 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
Modifier and TypeMethodDescriptionvoid
boolean
boolean
addAll
(int index, Collection c) boolean
addAll
(Collection c) void
clear()
clone()
Create a shallow clone of the objectboolean
boolean
protected List
Make a copy of the wrapped list - used by subclasses when the overriding the clone methodCreate a deep clone of the objectboolean
get
(int index) private List
getList()
getType()
getTypeCheckingListIterator
(int index) int
private void
boolean
isEmpty()
iterator()
int
listIterator
(int index) remove
(int index) boolean
boolean
boolean
int
size()
subList
(int fromIndex, int toIndex) Object[]
toArray()
Object[]
private void
private void
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream
Methods 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:DeepCloneable
Create a shallow clone of the object- Specified by:
clone
in interfaceDeepCloneable
- Overrides:
clone
in 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:DeepCloneable
Create a deep clone of the object- Specified by:
deepClone
in interfaceDeepCloneable
- Throws:
UnsupportedOperationException
-
equals
-
add
- Specified by:
add
in interfaceCollection
- Specified by:
add
in interfaceList
-
add
-
addAll
- Specified by:
addAll
in interfaceCollection
- Specified by:
addAll
in interfaceList
-
addAll
-
contains
- Specified by:
contains
in interfaceCollection
- Specified by:
contains
in interfaceList
-
containsAll
- Specified by:
containsAll
in interfaceCollection
- Specified by:
containsAll
in interfaceList
-
set
-
indexOf
-
lastIndexOf
- Specified by:
lastIndexOf
in interfaceList
-
remove
- Specified by:
remove
in interfaceCollection
- Specified by:
remove
in interfaceList
-
listIterator
- Specified by:
listIterator
in interfaceList
-
listIterator
- Specified by:
listIterator
in interfaceList
-
getTypeCheckingListIterator
-
getTypeCheckingListIterator
-
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
-
toArray
- Specified by:
toArray
in interfaceCollection
- Specified by:
toArray
in interfaceList
-
toArray
- Specified by:
toArray
in interfaceCollection
- Specified by:
toArray
in interfaceList
-
removeAll
- Specified by:
removeAll
in interfaceCollection
- Specified by:
removeAll
in interfaceList
-
retainAll
- Specified by:
retainAll
in interfaceCollection
- Specified by:
retainAll
in interfaceList
-
clear
public void clear()- Specified by:
clear
in interfaceCollection
- Specified by:
clear
in interfaceList
-
get
-
remove
-
subList
-
typecheck
-
typecheck
-