public abstract class UnsupportedList<T> extends Object implements List<T>
List
where all methods throw
an UnsupportedOperationException exception except for the
isEmpty
method. The iterator
and
listIterator
methods can be easily implemented in
derived classes by using the helper inner classes:
Itr
and ListItr
.
These iterators are all read only,
their remove
, add
and set
methods throw the
UnsupportedOperationException exception.
This class can be used for List implementations that only implement a subset of all the methods.
Modifier and Type | Class and Description |
---|---|
protected class |
UnsupportedList.Itr |
protected class |
UnsupportedList.ItrUnknownSize
Iterator for arrays of a priori unknown size.
|
protected class |
UnsupportedList.ListItr |
Modifier | Constructor and Description |
---|---|
protected |
UnsupportedList() |
Modifier and Type | Method and Description |
---|---|
void |
add(int index,
T element) |
boolean |
add(T o) |
boolean |
addAll(Collection<? extends T> c) |
boolean |
addAll(int index,
Collection<? extends T> c) |
void |
clear() |
boolean |
contains(Object o) |
boolean |
containsAll(Collection<?> c) |
boolean |
equals(Object o) |
T |
get(int index) |
int |
hashCode() |
int |
indexOf(Object o) |
boolean |
isEmpty() |
Iterator<T> |
iterator() |
int |
lastIndexOf(Object o) |
ListIterator<T> |
listIterator() |
ListIterator<T> |
listIterator(int index) |
T |
remove(int index) |
boolean |
remove(Object o) |
boolean |
removeAll(Collection<?> c) |
boolean |
retainAll(Collection<?> c) |
T |
set(int index,
T element) |
int |
size() |
List<T> |
subList(int fromIndex,
int toIndex) |
Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
protected UnsupportedList()
public boolean isEmpty()
public int size()
public int lastIndexOf(Object o)
lastIndexOf
in interface List<T>
public <T> T[] toArray(T[] a)
public boolean containsAll(Collection<?> c)
containsAll
in interface Collection<T>
containsAll
in interface List<T>
public boolean addAll(Collection<? extends T> c)
public boolean addAll(int index, Collection<? extends T> c)
public boolean removeAll(Collection<?> c)
public boolean retainAll(Collection<?> c)
public void clear()
public int hashCode()
public ListIterator<T> listIterator()
listIterator
in interface List<T>
public ListIterator<T> listIterator(int index)
listIterator
in interface List<T>