public abstract class ProxyListImpl<T> extends Object implements List<T>, Serializable
List with modification detection capability.
This wrapper class exposes two additional methods
setModified and isModified
to check whether the contents of a list is modified.
I originally thought the modCount field of AbstractList is suffice to implement this capability, but a close look at the source code reveals that modCount is not updated when value is modified without a structural change. This includes modifying a value of a list, for example.
Thus unfortunately we need to trap the calls to all the mutation methods of List.
Note that Iterator implementation of AbstractList modifies list directly without using a public method of List. Thus we also need to wrap Iterators.
| Modifier and Type | Field and Description |
|---|---|
protected List<T> |
core
The actual storage.
|
| Constructor and Description |
|---|
ProxyListImpl() |
ProxyListImpl(List<T> c) |
| 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) |
abstract void |
setModified(boolean f) |
int |
size() |
List<T> |
subList(int fromIndex,
int toIndex) |
Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
public abstract void setModified(boolean f)
public boolean add(T o)
public boolean addAll(Collection<? extends T> c)
public boolean addAll(int index,
Collection<? extends T> c)
public void clear()
public boolean remove(Object o)
public ListIterator<T> listIterator(int index)
listIterator in interface List<T>public ListIterator<T> listIterator()
listIterator in interface List<T>public boolean removeAll(Collection<?> c)
public boolean retainAll(Collection<?> c)
public boolean contains(Object o)
public boolean containsAll(Collection<?> c)
containsAll in interface Collection<T>containsAll in interface List<T>public boolean isEmpty()
public int lastIndexOf(Object o)
lastIndexOf in interface List<T>public int size()
public Object[] toArray()
public <T> T[] toArray(T[] a)
public boolean equals(Object o)
Copyright © 2015 Oracle Corporation. All Rights Reserved.