Class SingletonList
java.lang.Object
java.util.AbstractCollection
java.util.AbstractList
org.jaxen.util.SingletonList
- All Implemented Interfaces:
Iterable, Collection, List, SequencedCollection
A utility class that implements singleton lists
(to avoid dependency on JDK 1.3). Many operations
including
add() and remove() throw
UnsupportedOperationExceptions.- Version:
- 1.2b12
-
Field Summary
FieldsFields inherited from class AbstractList
modCount -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class AbstractList
add, add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subListMethods inherited from class AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toStringMethods inherited from interface Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface List
addAll, addFirst, addLast, contains, containsAll, getFirst, getLast, isEmpty, remove, removeAll, removeFirst, removeLast, replaceAll, retainAll, reversed, sort, spliterator, toArray, toArray
-
Field Details
-
element
-
-
Constructor Details
-
SingletonList
Creates a new singleton list.- Parameters:
element- the single member of the list
-
-
Method Details
-
size
public int size()Returns 1.- Specified by:
sizein interfaceCollection- Specified by:
sizein interfaceList- Specified by:
sizein classAbstractCollection- Returns:
- 1
-
get
Returns the single element in the list.- Specified by:
getin interfaceList- Specified by:
getin classAbstractList- Returns:
- the only element in the list
- Throws:
IndexOutOfBoundsException- if index is not 0
-