You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ch...@apache.org on 2017/07/11 17:55:09 UTC
[24/77] [abbrv] commons-collections git commit: finish generics
(minus one class)
http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/java/org/apache/commons/collections/keyvalue/TiedMapEntry.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/commons/collections/keyvalue/TiedMapEntry.java b/src/java/org/apache/commons/collections/keyvalue/TiedMapEntry.java
index a793824..46d2083 100644
--- a/src/java/org/apache/commons/collections/keyvalue/TiedMapEntry.java
+++ b/src/java/org/apache/commons/collections/keyvalue/TiedMapEntry.java
@@ -32,15 +32,16 @@ import org.apache.commons.collections.KeyValue;
*
* @author Stephen Colebourne
*/
-public class TiedMapEntry implements Map.Entry, KeyValue, Serializable {
+public class TiedMapEntry<K, V> implements Map.Entry<K, V>, KeyValue<K, V>, Serializable {
/** Serialization version */
private static final long serialVersionUID = -8453869361373831205L;
/** The map underlying the entry/iterator */
- private final Map map;
+ private final Map<K, V> map;
+
/** The key */
- private final Object key;
+ private final K key;
/**
* Constructs a new entry with the given Map and key.
@@ -48,7 +49,7 @@ public class TiedMapEntry implements Map.Entry, KeyValue, Serializable {
* @param map the map
* @param key the key
*/
- public TiedMapEntry(Map map, Object key) {
+ public TiedMapEntry(Map<K, V> map, K key) {
super();
this.map = map;
this.key = key;
@@ -61,7 +62,7 @@ public class TiedMapEntry implements Map.Entry, KeyValue, Serializable {
*
* @return the key
*/
- public Object getKey() {
+ public K getKey() {
return key;
}
@@ -70,7 +71,7 @@ public class TiedMapEntry implements Map.Entry, KeyValue, Serializable {
*
* @return the value
*/
- public Object getValue() {
+ public V getValue() {
return map.get(key);
}
@@ -81,7 +82,7 @@ public class TiedMapEntry implements Map.Entry, KeyValue, Serializable {
* @return the old value
* @throws IllegalArgumentException if the value is set to this map entry
*/
- public Object setValue(Object value) {
+ public V setValue(V value) {
if (value == this) {
throw new IllegalArgumentException("Cannot set value to this map entry");
}
@@ -96,6 +97,7 @@ public class TiedMapEntry implements Map.Entry, KeyValue, Serializable {
* @param obj the object to compare to
* @return true if equal key and value
*/
+ @SuppressWarnings("unchecked")
public boolean equals(Object obj) {
if (obj == this) {
return true;
http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/java/org/apache/commons/collections/keyvalue/UnmodifiableMapEntry.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/commons/collections/keyvalue/UnmodifiableMapEntry.java b/src/java/org/apache/commons/collections/keyvalue/UnmodifiableMapEntry.java
index 047967e..c316bbc 100644
--- a/src/java/org/apache/commons/collections/keyvalue/UnmodifiableMapEntry.java
+++ b/src/java/org/apache/commons/collections/keyvalue/UnmodifiableMapEntry.java
@@ -30,7 +30,7 @@ import org.apache.commons.collections.Unmodifiable;
*
* @author Stephen Colebourne
*/
-public final class UnmodifiableMapEntry extends AbstractMapEntry implements Unmodifiable {
+public final class UnmodifiableMapEntry<K, V> extends AbstractMapEntry<K, V> implements Unmodifiable {
/**
* Constructs a new entry with the specified key and given value.
@@ -38,7 +38,7 @@ public final class UnmodifiableMapEntry extends AbstractMapEntry implements Unmo
* @param key the key for the entry, may be null
* @param value the value for the entry, may be null
*/
- public UnmodifiableMapEntry(final Object key, final Object value) {
+ public UnmodifiableMapEntry(final K key, final V value) {
super(key, value);
}
@@ -48,7 +48,7 @@ public final class UnmodifiableMapEntry extends AbstractMapEntry implements Unmo
* @param pair the pair to copy, must not be null
* @throws NullPointerException if the entry is null
*/
- public UnmodifiableMapEntry(final KeyValue pair) {
+ public UnmodifiableMapEntry(final KeyValue<K, V> pair) {
super(pair.getKey(), pair.getValue());
}
@@ -58,7 +58,7 @@ public final class UnmodifiableMapEntry extends AbstractMapEntry implements Unmo
* @param entry the entry to copy, must not be null
* @throws NullPointerException if the entry is null
*/
- public UnmodifiableMapEntry(final Map.Entry entry) {
+ public UnmodifiableMapEntry(final Map.Entry<K, V> entry) {
super(entry.getKey(), entry.getValue());
}
@@ -69,7 +69,7 @@ public final class UnmodifiableMapEntry extends AbstractMapEntry implements Unmo
* @return the previous value
* @throws UnsupportedOperationException always
*/
- public Object setValue(Object value) {
+ public V setValue(V value) {
throw new UnsupportedOperationException("setValue() is not supported");
}
http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/java/org/apache/commons/collections/list/AbstractLinkedList.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/commons/collections/list/AbstractLinkedList.java b/src/java/org/apache/commons/collections/list/AbstractLinkedList.java
index 04c7357..738871e 100644
--- a/src/java/org/apache/commons/collections/list/AbstractLinkedList.java
+++ b/src/java/org/apache/commons/collections/list/AbstractLinkedList.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -37,7 +37,7 @@ import org.apache.commons.collections.OrderedIterator;
* Overridable methods are provided to change the storage node and to change how
* nodes are added to and removed. Hopefully, all you need for unusual subclasses
* is here.
- *
+ *
* @since Commons Collections 3.0
* @version $Revision$ $Date$
*
@@ -45,7 +45,7 @@ import org.apache.commons.collections.OrderedIterator;
* @author Phil Steitz
* @author Stephen Colebourne
*/
-public abstract class AbstractLinkedList implements List {
+public abstract class AbstractLinkedList<E> implements List<E> {
/*
* Implementation notes:
@@ -63,9 +63,11 @@ public abstract class AbstractLinkedList implements List {
* hold a value. The value of <code>next</code> is the first item in the
* list. The value of of <code>previous</code> is the last item in the list.
*/
- protected transient Node header;
+ protected transient Node<E> header;
+
/** The size of the list */
protected transient int size;
+
/** Modification count for iterators */
protected transient int modCount;
@@ -81,10 +83,10 @@ public abstract class AbstractLinkedList implements List {
/**
* Constructs a list copying data from the specified collection.
- *
+ *
* @param coll the collection to copy
*/
- protected AbstractLinkedList(Collection coll) {
+ protected AbstractLinkedList(Collection<? extends E> coll) {
super();
init();
addAll(coll);
@@ -109,28 +111,28 @@ public abstract class AbstractLinkedList implements List {
return (size() == 0);
}
- public Object get(int index) {
- Node node = getNode(index, false);
+ public E get(int index) {
+ Node<E> node = getNode(index, false);
return node.getValue();
}
//-----------------------------------------------------------------------
- public Iterator iterator() {
+ public Iterator<E> iterator() {
return listIterator();
}
- public ListIterator listIterator() {
- return new LinkedListIterator(this, 0);
+ public ListIterator<E> listIterator() {
+ return new LinkedListIterator<E>(this, 0);
}
- public ListIterator listIterator(int fromIndex) {
- return new LinkedListIterator(this, fromIndex);
+ public ListIterator<E> listIterator(int fromIndex) {
+ return new LinkedListIterator<E>(this, fromIndex);
}
//-----------------------------------------------------------------------
public int indexOf(Object value) {
int i = 0;
- for (Node node = header.next; node != header; node = node.next) {
+ for (Node<E> node = header.next; node != header; node = node.next) {
if (isEqualValue(node.getValue(), value)) {
return i;
}
@@ -141,7 +143,7 @@ public abstract class AbstractLinkedList implements List {
public int lastIndexOf(Object value) {
int i = size - 1;
- for (Node node = header.previous; node != header; node = node.previous) {
+ for (Node<E> node = header.previous; node != header; node = node.previous) {
if (isEqualValue(node.getValue(), value)) {
return i;
}
@@ -154,31 +156,31 @@ public abstract class AbstractLinkedList implements List {
return indexOf(value) != -1;
}
- public boolean containsAll(Collection coll) {
- Iterator it = coll.iterator();
- while (it.hasNext()) {
- if (contains(it.next()) == false) {
+ public boolean containsAll(Collection<?> coll) {
+ for (Object o : coll) {
+ if (!contains(o)) {
return false;
}
}
return true;
}
-
+
//-----------------------------------------------------------------------
public Object[] toArray() {
return toArray(new Object[size]);
}
- public Object[] toArray(Object[] array) {
+ @SuppressWarnings("unchecked")
+ public <T> T[] toArray(T[] array) {
// Extend the array if needed
if (array.length < size) {
Class componentType = array.getClass().getComponentType();
- array = (Object[]) Array.newInstance(componentType, size);
+ array = (T[]) Array.newInstance(componentType, size);
}
// Copy the values into the array
int i = 0;
- for (Node node = header.next; node != header; node = node.next, i++) {
- array[i] = node.getValue();
+ for (Node<E> node = header.next; node != header; node = node.next, i++) {
+ array[i] = (T) node.getValue();
}
// Set the value after the last value to null
if (array.length > size) {
@@ -189,49 +191,48 @@ public abstract class AbstractLinkedList implements List {
/**
* Gets a sublist of the main list.
- *
+ *
* @param fromIndexInclusive the index to start from
* @param toIndexExclusive the index to end at
* @return the new sublist
*/
- public List subList(int fromIndexInclusive, int toIndexExclusive) {
- return new LinkedSubList(this, fromIndexInclusive, toIndexExclusive);
+ public List<E> subList(int fromIndexInclusive, int toIndexExclusive) {
+ return new LinkedSubList<E>(this, fromIndexInclusive, toIndexExclusive);
}
-
+
//-----------------------------------------------------------------------
- public boolean add(Object value) {
+ public boolean add(E value) {
addLast(value);
return true;
}
-
- public void add(int index, Object value) {
- Node node = getNode(index, true);
+
+ public void add(int index, E value) {
+ Node<E> node = getNode(index, true);
addNodeBefore(node, value);
}
-
- public boolean addAll(Collection coll) {
+
+ public boolean addAll(Collection<? extends E> coll) {
return addAll(size, coll);
}
- public boolean addAll(int index, Collection coll) {
- Node node = getNode(index, true);
- for (Iterator itr = coll.iterator(); itr.hasNext();) {
- Object value = itr.next();
- addNodeBefore(node, value);
+ public boolean addAll(int index, Collection<? extends E> coll) {
+ Node<E> node = getNode(index, true);
+ for (E e : coll) {
+ addNodeBefore(node, e);
}
return true;
}
//-----------------------------------------------------------------------
- public Object remove(int index) {
- Node node = getNode(index, false);
- Object oldValue = node.getValue();
+ public E remove(int index) {
+ Node<E> node = getNode(index, false);
+ E oldValue = node.getValue();
removeNode(node);
return oldValue;
}
public boolean remove(Object value) {
- for (Node node = header.next; node != header; node = node.next) {
+ for (Node<E> node = header.next; node != header; node = node.next) {
if (isEqualValue(node.getValue(), value)) {
removeNode(node);
return true;
@@ -240,9 +241,9 @@ public abstract class AbstractLinkedList implements List {
return false;
}
- public boolean removeAll(Collection coll) {
+ public boolean removeAll(Collection<?> coll) {
boolean modified = false;
- Iterator it = iterator();
+ Iterator<E> it = iterator();
while (it.hasNext()) {
if (coll.contains(it.next())) {
it.remove();
@@ -253,9 +254,9 @@ public abstract class AbstractLinkedList implements List {
}
//-----------------------------------------------------------------------
- public boolean retainAll(Collection coll) {
+ public boolean retainAll(Collection<?> coll) {
boolean modified = false;
- Iterator it = iterator();
+ Iterator<E> it = iterator();
while (it.hasNext()) {
if (coll.contains(it.next()) == false) {
it.remove();
@@ -265,9 +266,9 @@ public abstract class AbstractLinkedList implements List {
return modified;
}
- public Object set(int index, Object value) {
- Node node = getNode(index, false);
- Object oldValue = node.getValue();
+ public E set(int index, E value) {
+ Node<E> node = getNode(index, false);
+ E oldValue = node.getValue();
updateNode(node, value);
return oldValue;
}
@@ -275,55 +276,56 @@ public abstract class AbstractLinkedList implements List {
public void clear() {
removeAllNodes();
}
-
+
//-----------------------------------------------------------------------
- public Object getFirst() {
- Node node = header.next;
+ public E getFirst() {
+ Node<E> node = header.next;
if (node == header) {
throw new NoSuchElementException();
}
return node.getValue();
}
- public Object getLast() {
- Node node = header.previous;
+ public E getLast() {
+ Node<E> node = header.previous;
if (node == header) {
throw new NoSuchElementException();
}
return node.getValue();
}
- public boolean addFirst(Object o) {
+ public boolean addFirst(E o) {
addNodeAfter(header, o);
return true;
}
- public boolean addLast(Object o) {
+ public boolean addLast(E o) {
addNodeBefore(header, o);
return true;
}
- public Object removeFirst() {
- Node node = header.next;
+ public E removeFirst() {
+ Node<E> node = header.next;
if (node == header) {
throw new NoSuchElementException();
}
- Object oldValue = node.getValue();
+ E oldValue = node.getValue();
removeNode(node);
return oldValue;
}
- public Object removeLast() {
- Node node = header.previous;
+ public E removeLast() {
+ Node<E> node = header.previous;
if (node == header) {
throw new NoSuchElementException();
}
- Object oldValue = node.getValue();
+ E oldValue = node.getValue();
removeNode(node);
return oldValue;
}
//-----------------------------------------------------------------------
+ @SuppressWarnings("unchecked")
public boolean equals(Object obj) {
if (obj == this) {
return true;
@@ -348,10 +350,8 @@ public abstract class AbstractLinkedList implements List {
public int hashCode() {
int hashCode = 1;
- Iterator it = iterator();
- while (it.hasNext()) {
- Object obj = it.next();
- hashCode = 31 * hashCode + (obj == null ? 0 : obj.hashCode());
+ for (E e : this) {
+ hashCode = 31 * hashCode + (e == null ? 0 : e.hashCode());
}
return hashCode;
}
@@ -363,7 +363,7 @@ public abstract class AbstractLinkedList implements List {
StringBuffer buf = new StringBuffer(16 * size());
buf.append("[");
- Iterator it = iterator();
+ Iterator<E> it = iterator();
boolean hasNext = it.hasNext();
while (hasNext) {
Object value = it.next();
@@ -382,7 +382,7 @@ public abstract class AbstractLinkedList implements List {
* Compares two values for equals.
* This implementation uses the equals method.
* Subclasses can override this to match differently.
- *
+ *
* @param value1 the first value to compare, may be null
* @param value2 the second value to compare, may be null
* @return true if equal
@@ -390,16 +390,16 @@ public abstract class AbstractLinkedList implements List {
protected boolean isEqualValue(Object value1, Object value2) {
return (value1 == value2 || (value1 == null ? false : value1.equals(value2)));
}
-
+
/**
* Updates the node with a new value.
* This implementation sets the value on the node.
* Subclasses can override this to record the change.
- *
+ *
* @param node node to update
* @param value new value of the node
*/
- protected void updateNode(Node node, Object value) {
+ protected void updateNode(Node<E> node, E value) {
node.setValue(value);
}
@@ -407,26 +407,26 @@ public abstract class AbstractLinkedList implements List {
* Creates a new node with previous, next and element all set to null.
* This implementation creates a new empty Node.
* Subclasses can override this to create a different class.
- *
+ *
* @return newly created node
*/
- protected Node createHeaderNode() {
- return new Node();
+ protected Node<E> createHeaderNode() {
+ return new Node<E>();
}
/**
* Creates a new node with the specified properties.
* This implementation creates a new Node with data.
* Subclasses can override this to create a different class.
- *
+ *
* @param value value of the new node
*/
- protected Node createNode(Object value) {
- return new Node(value);
+ protected Node<E> createNode(E value) {
+ return new Node<E>(value);
}
/**
- * Creates a new node with the specified object as its
+ * Creates a new node with the specified object as its
* <code>value</code> and inserts it before <code>node</code>.
* <p>
* This implementation uses {@link #createNode(Object)} and
@@ -436,24 +436,24 @@ public abstract class AbstractLinkedList implements List {
* @param value value of the newly added node
* @throws NullPointerException if <code>node</code> is null
*/
- protected void addNodeBefore(Node node, Object value) {
- Node newNode = createNode(value);
+ protected void addNodeBefore(Node<E> node, E value) {
+ Node<E> newNode = createNode(value);
addNode(newNode, node);
}
/**
- * Creates a new node with the specified object as its
+ * Creates a new node with the specified object as its
* <code>value</code> and inserts it after <code>node</code>.
* <p>
* This implementation uses {@link #createNode(Object)} and
* {@link #addNode(AbstractLinkedList.Node,AbstractLinkedList.Node)}.
- *
+ *
* @param node node to insert after
* @param value value of the newly added node
* @throws NullPointerException if <code>node</code> is null
*/
- protected void addNodeAfter(Node node, Object value) {
- Node newNode = createNode(value);
+ protected void addNodeAfter(Node<E> node, E value) {
+ Node<E> newNode = createNode(value);
addNode(newNode, node.next);
}
@@ -464,7 +464,7 @@ public abstract class AbstractLinkedList implements List {
* @param insertBeforeNode node to insert before
* @throws NullPointerException if either node is null
*/
- protected void addNode(Node nodeToInsert, Node insertBeforeNode) {
+ protected void addNode(Node<E> nodeToInsert, Node<E> insertBeforeNode) {
nodeToInsert.next = insertBeforeNode;
nodeToInsert.previous = insertBeforeNode.previous;
insertBeforeNode.previous.next = nodeToInsert;
@@ -479,7 +479,7 @@ public abstract class AbstractLinkedList implements List {
* @param node the node to remove
* @throws NullPointerException if <code>node</code> is null
*/
- protected void removeNode(Node node) {
+ protected void removeNode(Node<E> node) {
node.previous.next = node.next;
node.next.previous = node.previous;
size--;
@@ -498,7 +498,7 @@ public abstract class AbstractLinkedList implements List {
/**
* Gets the node at a particular index.
- *
+ *
* @param index the index, starting from 0
* @param endMarkerAllowed whether or not the end marker can be returned if
* startIndex is set to the list's size
@@ -506,7 +506,7 @@ public abstract class AbstractLinkedList implements List {
* the size of the list and endMakerAllowed is false; or greater than the
* size of the list
*/
- protected Node getNode(int index, boolean endMarkerAllowed) throws IndexOutOfBoundsException {
+ protected Node<E> getNode(int index, boolean endMarkerAllowed) throws IndexOutOfBoundsException {
// Check the index is within the bounds
if (index < 0) {
throw new IndexOutOfBoundsException("Couldn't get the node: " +
@@ -522,7 +522,7 @@ public abstract class AbstractLinkedList implements List {
"list (" + size + ").");
}
// Search the list and get the node
- Node node;
+ Node<E> node;
if (index < (size / 2)) {
// Search forwards
node = header.next;
@@ -542,21 +542,21 @@ public abstract class AbstractLinkedList implements List {
//-----------------------------------------------------------------------
/**
* Creates an iterator for the sublist.
- *
+ *
* @param subList the sublist to get an iterator for
*/
- protected Iterator createSubListIterator(LinkedSubList subList) {
+ protected Iterator<E> createSubListIterator(LinkedSubList<E> subList) {
return createSubListListIterator(subList, 0);
}
/**
* Creates a list iterator for the sublist.
- *
+ *
* @param subList the sublist to get an iterator for
* @param fromIndex the index to start from, relative to the sublist
*/
- protected ListIterator createSubListListIterator(LinkedSubList subList, int fromIndex) {
- return new LinkedSubListIterator(subList, fromIndex);
+ protected ListIterator<E> createSubListListIterator(LinkedSubList<E> subList, int fromIndex) {
+ return new LinkedSubListIterator<E>(subList, fromIndex);
}
//-----------------------------------------------------------------------
@@ -569,7 +569,7 @@ public abstract class AbstractLinkedList implements List {
protected void doWriteObject(ObjectOutputStream outputStream) throws IOException {
// Write the size so we know how many nodes to read back
outputStream.writeInt(size());
- for (Iterator itr = iterator(); itr.hasNext();) {
+ for (Iterator<E> itr = iterator(); itr.hasNext();) {
outputStream.writeObject(itr.next());
}
}
@@ -580,11 +580,12 @@ public abstract class AbstractLinkedList implements List {
* The first serializable subclass must call this method from
* <code>readObject</code>.
*/
+ @SuppressWarnings("unchecked")
protected void doReadObject(ObjectInputStream inputStream) throws IOException, ClassNotFoundException {
init();
int size = inputStream.readInt();
for (int i = 0; i < size; i++) {
- add(inputStream.readObject());
+ add((E) inputStream.readObject());
}
}
@@ -595,14 +596,14 @@ public abstract class AbstractLinkedList implements List {
* From Commons Collections 3.1, all access to the <code>value</code> property
* is via the methods on this class.
*/
- protected static class Node {
+ protected static class Node<E> {
/** A pointer to the node before this node */
- protected Node previous;
+ protected Node<E> previous;
/** A pointer to the node after this node */
- protected Node next;
+ protected Node<E> next;
/** The object contained within this node */
- protected Object value;
+ protected E value;
/**
* Constructs a new header node.
@@ -615,85 +616,85 @@ public abstract class AbstractLinkedList implements List {
/**
* Constructs a new node.
- *
+ *
* @param value the value to store
*/
- protected Node(Object value) {
+ protected Node(E value) {
super();
this.value = value;
}
-
+
/**
* Constructs a new node.
- *
+ *
* @param previous the previous node in the list
* @param next the next node in the list
* @param value the value to store
*/
- protected Node(Node previous, Node next, Object value) {
+ protected Node(Node<E> previous, Node<E> next, E value) {
super();
this.previous = previous;
this.next = next;
this.value = value;
}
-
+
/**
* Gets the value of the node.
- *
+ *
* @return the value
* @since Commons Collections 3.1
*/
- protected Object getValue() {
+ protected E getValue() {
return value;
}
-
+
/**
* Sets the value of the node.
- *
+ *
* @param value the value
* @since Commons Collections 3.1
*/
- protected void setValue(Object value) {
+ protected void setValue(E value) {
this.value = value;
}
-
+
/**
* Gets the previous node.
- *
+ *
* @return the previous node
* @since Commons Collections 3.1
*/
- protected Node getPreviousNode() {
+ protected Node<E> getPreviousNode() {
return previous;
}
-
+
/**
* Sets the previous node.
- *
+ *
* @param previous the previous node
* @since Commons Collections 3.1
*/
- protected void setPreviousNode(Node previous) {
+ protected void setPreviousNode(Node<E> previous) {
this.previous = previous;
}
-
+
/**
* Gets the next node.
- *
+ *
* @return the next node
* @since Commons Collections 3.1
*/
- protected Node getNextNode() {
+ protected Node<E> getNextNode() {
return next;
}
-
+
/**
* Sets the next node.
- *
+ *
* @param next the next node
* @since Commons Collections 3.1
*/
- protected void setNextNode(Node next) {
+ protected void setNextNode(Node<E> next) {
this.next = next;
}
}
@@ -702,16 +703,16 @@ public abstract class AbstractLinkedList implements List {
/**
* A list iterator over the linked list.
*/
- protected static class LinkedListIterator implements ListIterator, OrderedIterator {
-
+ protected static class LinkedListIterator<E> implements ListIterator<E>, OrderedIterator<E> {
+
/** The parent list */
- protected final AbstractLinkedList parent;
+ protected final AbstractLinkedList<E> parent;
/**
* The node that will be returned by {@link #next()}. If this is equal
* to {@link AbstractLinkedList#header} then there are no more values to return.
*/
- protected Node next;
+ protected Node<E> next;
/**
* The index of {@link #next}.
@@ -726,7 +727,7 @@ public abstract class AbstractLinkedList implements List {
* Should be accessed through {@link #getLastNodeReturned()} to enforce
* this behaviour.
*/
- protected Node current;
+ protected Node<E> current;
/**
* The modification count that the list is expected to have. If the list
@@ -738,11 +739,11 @@ public abstract class AbstractLinkedList implements List {
/**
* Create a ListIterator for a list.
- *
+ *
* @param parent the parent list
* @param fromIndex the index to start at
*/
- protected LinkedListIterator(AbstractLinkedList parent, int fromIndex) throws IndexOutOfBoundsException {
+ protected LinkedListIterator(AbstractLinkedList<E> parent, int fromIndex) throws IndexOutOfBoundsException {
super();
this.parent = parent;
this.expectedModCount = parent.modCount;
@@ -753,7 +754,7 @@ public abstract class AbstractLinkedList implements List {
/**
* Checks the modification count of the list is the value that this
* object expects.
- *
+ *
* @throws ConcurrentModificationException If the list's modification
* count isn't the value that was expected.
*/
@@ -765,12 +766,12 @@ public abstract class AbstractLinkedList implements List {
/**
* Gets the last node returned.
- *
+ *
* @throws IllegalStateException If {@link #next()} or
* {@link #previous()} haven't been called, or if the node has been removed
* with {@link #remove()} or a new node added with {@link #add(Object)}.
*/
- protected Node getLastNodeReturned() throws IllegalStateException {
+ protected Node<E> getLastNodeReturned() throws IllegalStateException {
if (current == null) {
throw new IllegalStateException();
}
@@ -781,12 +782,12 @@ public abstract class AbstractLinkedList implements List {
return next != parent.header;
}
- public Object next() {
+ public E next() {
checkModCount();
if (!hasNext()) {
throw new NoSuchElementException("No element at index " + nextIndex + ".");
}
- Object value = next.getValue();
+ E value = next.getValue();
current = next;
next = next.next;
nextIndex++;
@@ -797,13 +798,13 @@ public abstract class AbstractLinkedList implements List {
return next.previous != parent.header;
}
- public Object previous() {
+ public E previous() {
checkModCount();
if (!hasPrevious()) {
throw new NoSuchElementException("Already at start of list.");
}
next = next.previous;
- Object value = next.getValue();
+ E value = next.getValue();
current = next;
nextIndex--;
return value;
@@ -833,12 +834,12 @@ public abstract class AbstractLinkedList implements List {
expectedModCount++;
}
- public void set(Object obj) {
+ public void set(E obj) {
checkModCount();
getLastNodeReturned().setValue(obj);
}
- public void add(Object obj) {
+ public void add(E obj) {
checkModCount();
parent.addNodeBefore(next, obj);
current = null;
@@ -852,12 +853,12 @@ public abstract class AbstractLinkedList implements List {
/**
* A list iterator over the linked sub list.
*/
- protected static class LinkedSubListIterator extends LinkedListIterator {
-
+ protected static class LinkedSubListIterator<E> extends LinkedListIterator<E> {
+
/** The parent list */
- protected final LinkedSubList sub;
-
- protected LinkedSubListIterator(LinkedSubList sub, int startIndex) {
+ protected final LinkedSubList<E> sub;
+
+ protected LinkedSubListIterator(LinkedSubList<E> sub, int startIndex) {
super(sub.parent, startIndex + sub.offset);
this.sub = sub;
}
@@ -874,26 +875,26 @@ public abstract class AbstractLinkedList implements List {
return (super.nextIndex() - sub.offset);
}
- public void add(Object obj) {
+ public void add(E obj) {
super.add(obj);
sub.expectedModCount = parent.modCount;
sub.size++;
}
-
+
public void remove() {
super.remove();
sub.expectedModCount = parent.modCount;
sub.size--;
}
}
-
+
//-----------------------------------------------------------------------
/**
* The sublist implementation for AbstractLinkedList.
*/
- protected static class LinkedSubList extends AbstractList {
+ protected static class LinkedSubList<E> extends AbstractList<E> {
/** The main list */
- AbstractLinkedList parent;
+ AbstractLinkedList<E> parent;
/** Offset from the main list */
int offset;
/** Sublist size */
@@ -901,7 +902,7 @@ public abstract class AbstractLinkedList implements List {
/** Sublist modCount */
int expectedModCount;
- protected LinkedSubList(AbstractLinkedList parent, int fromIndex, int toIndex) {
+ protected LinkedSubList(AbstractLinkedList<E> parent, int fromIndex, int toIndex) {
if (fromIndex < 0) {
throw new IndexOutOfBoundsException("fromIndex = " + fromIndex);
}
@@ -922,13 +923,13 @@ public abstract class AbstractLinkedList implements List {
return size;
}
- public Object get(int index) {
+ public E get(int index) {
rangeCheck(index, size);
checkModCount();
return parent.get(index + offset);
}
- public void add(int index, Object obj) {
+ public void add(int index, E obj) {
rangeCheck(index, size + 1);
checkModCount();
parent.add(index + offset, obj);
@@ -937,21 +938,21 @@ public abstract class AbstractLinkedList implements List {
LinkedSubList.this.modCount++;
}
- public Object remove(int index) {
+ public E remove(int index) {
rangeCheck(index, size);
checkModCount();
- Object result = parent.remove(index + offset);
+ E result = parent.remove(index + offset);
expectedModCount = parent.modCount;
size--;
LinkedSubList.this.modCount++;
return result;
}
- public boolean addAll(Collection coll) {
+ public boolean addAll(Collection<? extends E> coll) {
return addAll(size, coll);
}
- public boolean addAll(int index, Collection coll) {
+ public boolean addAll(int index, Collection<? extends E> coll) {
rangeCheck(index, size + 1);
int cSize = coll.size();
if (cSize == 0) {
@@ -966,7 +967,7 @@ public abstract class AbstractLinkedList implements List {
return true;
}
- public Object set(int index, Object obj) {
+ public E set(int index, E obj) {
rangeCheck(index, size);
checkModCount();
return parent.set(index + offset, obj);
@@ -974,26 +975,26 @@ public abstract class AbstractLinkedList implements List {
public void clear() {
checkModCount();
- Iterator it = iterator();
+ Iterator<E> it = iterator();
while (it.hasNext()) {
it.next();
it.remove();
}
}
- public Iterator iterator() {
+ public Iterator<E> iterator() {
checkModCount();
return parent.createSubListIterator(this);
}
- public ListIterator listIterator(final int index) {
+ public ListIterator<E> listIterator(final int index) {
rangeCheck(index, size + 1);
checkModCount();
return parent.createSubListListIterator(this, index);
}
- public List subList(int fromIndexInclusive, int toIndexExclusive) {
- return new LinkedSubList(parent, fromIndexInclusive + offset, toIndexExclusive + offset);
+ public List<E> subList(int fromIndexInclusive, int toIndexExclusive) {
+ return new LinkedSubList<E>(parent, fromIndexInclusive + offset, toIndexExclusive + offset);
}
protected void rangeCheck(int index, int beyond) {
@@ -1008,5 +1009,5 @@ public abstract class AbstractLinkedList implements List {
}
}
}
-
+
}
http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/java/org/apache/commons/collections/list/AbstractListDecorator.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/commons/collections/list/AbstractListDecorator.java b/src/java/org/apache/commons/collections/list/AbstractListDecorator.java
index ecd48f2..c8550d2 100644
--- a/src/java/org/apache/commons/collections/list/AbstractListDecorator.java
+++ b/src/java/org/apache/commons/collections/list/AbstractListDecorator.java
@@ -33,9 +33,11 @@ import org.apache.commons.collections.collection.AbstractCollectionDecorator;
*
* @author Stephen Colebourne
*/
-public abstract class AbstractListDecorator<E>
- extends AbstractCollectionDecorator<E>
- implements List<E> {
+public abstract class AbstractListDecorator<E> extends AbstractCollectionDecorator<E> implements
+ List<E> {
+
+ /** Serialization version--necessary in an abstract class? */
+ private static final long serialVersionUID = 4500739654952315623L;
/**
* Constructor only used in deserialization, do not use otherwise.
http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/java/org/apache/commons/collections/list/AbstractSerializableListDecorator.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/commons/collections/list/AbstractSerializableListDecorator.java b/src/java/org/apache/commons/collections/list/AbstractSerializableListDecorator.java
index 7793581..eac1c3a 100644
--- a/src/java/org/apache/commons/collections/list/AbstractSerializableListDecorator.java
+++ b/src/java/org/apache/commons/collections/list/AbstractSerializableListDecorator.java
@@ -29,8 +29,8 @@ import java.util.List;
* @author Stephen Colebourne
* @since Commons Collections 3.1
*/
-public abstract class AbstractSerializableListDecorator
- extends AbstractListDecorator
+public abstract class AbstractSerializableListDecorator<E>
+ extends AbstractListDecorator<E>
implements Serializable {
/** Serialization version */
@@ -39,7 +39,7 @@ public abstract class AbstractSerializableListDecorator
/**
* Constructor.
*/
- protected AbstractSerializableListDecorator(List list) {
+ protected AbstractSerializableListDecorator(List<E> list) {
super(list);
}
@@ -62,9 +62,10 @@ public abstract class AbstractSerializableListDecorator
* @throws IOException
* @throws ClassNotFoundException
*/
+ @SuppressWarnings("unchecked")
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
- collection = (Collection) in.readObject();
+ collection = (Collection<E>) in.readObject();
}
}
http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/java/org/apache/commons/collections/list/CursorableLinkedList.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/commons/collections/list/CursorableLinkedList.java b/src/java/org/apache/commons/collections/list/CursorableLinkedList.java
index b6ce57d..022eaaa 100644
--- a/src/java/org/apache/commons/collections/list/CursorableLinkedList.java
+++ b/src/java/org/apache/commons/collections/list/CursorableLinkedList.java
@@ -60,13 +60,13 @@ import java.util.ListIterator;
* @author Simon Kitching
* @author Stephen Colebourne
*/
-public class CursorableLinkedList extends AbstractLinkedList implements Serializable {
+public class CursorableLinkedList<E> extends AbstractLinkedList<E> implements Serializable {
/** Ensure serialization compatibility */
private static final long serialVersionUID = 8836393098519411393L;
/** A list of the cursor currently open on this list */
- protected transient List cursors = new ArrayList();
+ protected transient List<WeakReference<Cursor<E>>> cursors;
//-----------------------------------------------------------------------
/**
@@ -82,7 +82,7 @@ public class CursorableLinkedList extends AbstractLinkedList implements Serializ
*
* @param coll the collection to copy
*/
- public CursorableLinkedList(Collection coll) {
+ public CursorableLinkedList(Collection<E> coll) {
super(coll);
}
@@ -92,7 +92,7 @@ public class CursorableLinkedList extends AbstractLinkedList implements Serializ
*/
protected void init() {
super.init();
- cursors = new ArrayList();
+ cursors = new ArrayList<WeakReference<Cursor<E>>>();
}
//-----------------------------------------------------------------------
@@ -105,7 +105,7 @@ public class CursorableLinkedList extends AbstractLinkedList implements Serializ
*
* @return a new iterator that does <b>not</b> support concurrent modification
*/
- public Iterator iterator() {
+ public Iterator<E> iterator() {
return super.listIterator(0);
}
@@ -124,7 +124,7 @@ public class CursorableLinkedList extends AbstractLinkedList implements Serializ
*
* @return a new cursor iterator
*/
- public ListIterator listIterator() {
+ public ListIterator<E> listIterator() {
return cursor(0);
}
@@ -144,7 +144,7 @@ public class CursorableLinkedList extends AbstractLinkedList implements Serializ
* @param fromIndex the index to start from
* @return a new cursor iterator
*/
- public ListIterator listIterator(int fromIndex) {
+ public ListIterator<E> listIterator(int fromIndex) {
return cursor(fromIndex);
}
@@ -171,7 +171,7 @@ public class CursorableLinkedList extends AbstractLinkedList implements Serializ
*
* @return a new cursor iterator
*/
- public CursorableLinkedList.Cursor cursor() {
+ public CursorableLinkedList.Cursor<E> cursor() {
return cursor(0);
}
@@ -202,8 +202,8 @@ public class CursorableLinkedList extends AbstractLinkedList implements Serializ
* @throws IndexOutOfBoundsException if the index is out of range
* (index < 0 || index > size()).
*/
- public CursorableLinkedList.Cursor cursor(int fromIndex) {
- Cursor cursor = new Cursor(this, fromIndex);
+ public CursorableLinkedList.Cursor<E> cursor(int fromIndex) {
+ Cursor<E> cursor = new Cursor<E>(this, fromIndex);
registerCursor(cursor);
return cursor;
}
@@ -217,7 +217,7 @@ public class CursorableLinkedList extends AbstractLinkedList implements Serializ
* @param node node to update
* @param value new value of the node
*/
- protected void updateNode(Node node, Object value) {
+ protected void updateNode(Node<E> node, E value) {
super.updateNode(node, value);
broadcastNodeChanged(node);
}
@@ -229,7 +229,7 @@ public class CursorableLinkedList extends AbstractLinkedList implements Serializ
* @param insertBeforeNode node to insert before
* @throws NullPointerException if either node is null
*/
- protected void addNode(Node nodeToInsert, Node insertBeforeNode) {
+ protected void addNode(Node<E> nodeToInsert, Node<E> insertBeforeNode) {
super.addNode(nodeToInsert, insertBeforeNode);
broadcastNodeInserted(nodeToInsert);
}
@@ -240,7 +240,7 @@ public class CursorableLinkedList extends AbstractLinkedList implements Serializ
* @param node the node to remove
* @throws NullPointerException if <code>node</code> is null
*/
- protected void removeNode(Node node) {
+ protected void removeNode(Node<E> node) {
super.removeNode(node);
broadcastNodeRemoved(node);
}
@@ -251,7 +251,7 @@ public class CursorableLinkedList extends AbstractLinkedList implements Serializ
protected void removeAllNodes() {
if (size() > 0) {
// superclass implementation would break all the iterators
- Iterator it = iterator();
+ Iterator<E> it = iterator();
while (it.hasNext()) {
it.next();
it.remove();
@@ -265,16 +265,16 @@ public class CursorableLinkedList extends AbstractLinkedList implements Serializ
*
* @param cursor the cursor to register
*/
- protected void registerCursor(Cursor cursor) {
+ protected void registerCursor(Cursor<E> cursor) {
// We take this opportunity to clean the cursors list
// of WeakReference objects to garbage-collected cursors.
- for (Iterator it = cursors.iterator(); it.hasNext();) {
- WeakReference ref = (WeakReference) it.next();
+ for (Iterator<WeakReference<Cursor<E>>> it = cursors.iterator(); it.hasNext();) {
+ WeakReference<Cursor<E>> ref = it.next();
if (ref.get() == null) {
it.remove();
}
}
- cursors.add(new WeakReference(cursor));
+ cursors.add(new WeakReference<Cursor<E>>(cursor));
}
/**
@@ -282,16 +282,15 @@ public class CursorableLinkedList extends AbstractLinkedList implements Serializ
*
* @param cursor the cursor to deregister
*/
- protected void unregisterCursor(Cursor cursor) {
- for (Iterator it = cursors.iterator(); it.hasNext();) {
- WeakReference ref = (WeakReference) it.next();
- Cursor cur = (Cursor) ref.get();
+ protected void unregisterCursor(Cursor<E> cursor) {
+ for (Iterator<WeakReference<Cursor<E>>> it = cursors.iterator(); it.hasNext();) {
+ WeakReference<Cursor<E>> ref = it.next();
+ Cursor<E> cur = ref.get();
if (cur == null) {
// some other unrelated cursor object has been
// garbage-collected; let's take the opportunity to
// clean up the cursors list anyway..
it.remove();
-
} else if (cur == cursor) {
ref.clear();
it.remove();
@@ -307,11 +306,11 @@ public class CursorableLinkedList extends AbstractLinkedList implements Serializ
*
* @param node the node that was changed
*/
- protected void broadcastNodeChanged(Node node) {
- Iterator it = cursors.iterator();
+ protected void broadcastNodeChanged(Node<E> node) {
+ Iterator<WeakReference<Cursor<E>>> it = cursors.iterator();
while (it.hasNext()) {
- WeakReference ref = (WeakReference) it.next();
- Cursor cursor = (Cursor) ref.get();
+ WeakReference<Cursor<E>> ref = it.next();
+ Cursor<E> cursor = ref.get();
if (cursor == null) {
it.remove(); // clean up list
} else {
@@ -326,11 +325,11 @@ public class CursorableLinkedList extends AbstractLinkedList implements Serializ
*
* @param node the node that was changed
*/
- protected void broadcastNodeRemoved(Node node) {
- Iterator it = cursors.iterator();
+ protected void broadcastNodeRemoved(Node<E> node) {
+ Iterator<WeakReference<Cursor<E>>> it = cursors.iterator();
while (it.hasNext()) {
- WeakReference ref = (WeakReference) it.next();
- Cursor cursor = (Cursor) ref.get();
+ WeakReference<Cursor<E>> ref = it.next();
+ Cursor<E> cursor = ref.get();
if (cursor == null) {
it.remove(); // clean up list
} else {
@@ -345,11 +344,11 @@ public class CursorableLinkedList extends AbstractLinkedList implements Serializ
*
* @param node the node that was changed
*/
- protected void broadcastNodeInserted(Node node) {
- Iterator it = cursors.iterator();
+ protected void broadcastNodeInserted(Node<E> node) {
+ Iterator<WeakReference<Cursor<E>>> it = cursors.iterator();
while (it.hasNext()) {
- WeakReference ref = (WeakReference) it.next();
- Cursor cursor = (Cursor) ref.get();
+ WeakReference<Cursor<E>> ref = it.next();
+ Cursor<E> cursor = ref.get();
if (cursor == null) {
it.remove(); // clean up list
} else {
@@ -382,8 +381,8 @@ public class CursorableLinkedList extends AbstractLinkedList implements Serializ
* @param subList the sublist to get an iterator for
* @param fromIndex the index to start from, relative to the sublist
*/
- protected ListIterator createSubListListIterator(LinkedSubList subList, int fromIndex) {
- SubCursor cursor = new SubCursor(subList, fromIndex);
+ protected ListIterator<E> createSubListListIterator(LinkedSubList<E> subList, int fromIndex) {
+ SubCursor<E> cursor = new SubCursor<E>(subList, fromIndex);
registerCursor(cursor);
return cursor;
}
@@ -393,7 +392,7 @@ public class CursorableLinkedList extends AbstractLinkedList implements Serializ
* An extended <code>ListIterator</code> that allows concurrent changes to
* the underlying list.
*/
- public static class Cursor extends AbstractLinkedList.LinkedListIterator {
+ public static class Cursor<E> extends AbstractLinkedList.LinkedListIterator<E> {
/** Is the cursor valid (not closed) */
boolean valid = true;
/** Is the next index valid */
@@ -406,7 +405,7 @@ public class CursorableLinkedList extends AbstractLinkedList implements Serializ
*
* @param index the index to start from
*/
- protected Cursor(CursorableLinkedList parent, int index) {
+ protected Cursor(CursorableLinkedList<E> parent, int index) {
super(parent, index);
valid = true;
}
@@ -443,7 +442,7 @@ public class CursorableLinkedList extends AbstractLinkedList implements Serializ
*
* @param obj the object to add
*/
- public void add(Object obj) {
+ public void add(E obj) {
// overridden, as the nodeInserted() method updates the iterator state
super.add(obj);
// matches the (next.previous == node) clause in nodeInserted()
@@ -467,7 +466,7 @@ public class CursorableLinkedList extends AbstractLinkedList implements Serializ
nextIndex = parent.size();
} else {
int pos = 0;
- Node temp = parent.header.next;
+ Node<E> temp = parent.header.next;
while (temp != next) {
pos++;
temp = temp.next;
@@ -484,7 +483,7 @@ public class CursorableLinkedList extends AbstractLinkedList implements Serializ
*
* @param node the node that changed
*/
- protected void nodeChanged(Node node) {
+ protected void nodeChanged(Node<E> node) {
// do nothing
}
@@ -493,7 +492,7 @@ public class CursorableLinkedList extends AbstractLinkedList implements Serializ
*
* @param node the node that was removed
*/
- protected void nodeRemoved(Node node) {
+ protected void nodeRemoved(Node<E> node) {
if (node == next && node == current) {
// state where next() followed by previous()
next = node.next;
@@ -521,7 +520,7 @@ public class CursorableLinkedList extends AbstractLinkedList implements Serializ
*
* @param node the node that was added
*/
- protected void nodeInserted(Node node) {
+ protected void nodeInserted(Node<E> node) {
if (node.previous == current) {
next = node;
} else if (next.previous == node) {
@@ -550,7 +549,7 @@ public class CursorableLinkedList extends AbstractLinkedList implements Serializ
*/
public void close() {
if (valid) {
- ((CursorableLinkedList) parent).unregisterCursor(this);
+ ((CursorableLinkedList<E>) parent).unregisterCursor(this);
valid = false;
}
}
@@ -562,18 +561,18 @@ public class CursorableLinkedList extends AbstractLinkedList implements Serializ
*
* @since Commons Collections 3.2
*/
- protected static class SubCursor extends Cursor {
+ protected static class SubCursor<E> extends Cursor<E> {
/** The parent list */
- protected final LinkedSubList sub;
+ protected final LinkedSubList<E> sub;
/**
* Constructs a new cursor.
*
* @param index the index to start from
*/
- protected SubCursor(LinkedSubList sub, int index) {
- super((CursorableLinkedList) sub.parent, index + sub.offset);
+ protected SubCursor(LinkedSubList<E> sub, int index) {
+ super((CursorableLinkedList<E>) sub.parent, index + sub.offset);
this.sub = sub;
}
@@ -589,7 +588,7 @@ public class CursorableLinkedList extends AbstractLinkedList implements Serializ
return (super.nextIndex() - sub.offset);
}
- public void add(Object obj) {
+ public void add(E obj) {
super.add(obj);
sub.expectedModCount = parent.modCount;
sub.size++;
http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/java/org/apache/commons/collections/list/FixedSizeList.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/commons/collections/list/FixedSizeList.java b/src/java/org/apache/commons/collections/list/FixedSizeList.java
index 8709bbe..65e0955 100644
--- a/src/java/org/apache/commons/collections/list/FixedSizeList.java
+++ b/src/java/org/apache/commons/collections/list/FixedSizeList.java
@@ -39,9 +39,9 @@ import org.apache.commons.collections.iterators.UnmodifiableIterator;
* @author Stephen Colebourne
* @author Paul Jack
*/
-public class FixedSizeList
- extends AbstractSerializableListDecorator
- implements BoundedCollection {
+public class FixedSizeList<E>
+ extends AbstractSerializableListDecorator<E>
+ implements BoundedCollection<E> {
/** Serialization version */
private static final long serialVersionUID = -2218010673611160319L;
@@ -52,8 +52,8 @@ public class FixedSizeList
* @param list the list to decorate, must not be null
* @throws IllegalArgumentException if list is null
*/
- public static List decorate(List list) {
- return new FixedSizeList(list);
+ public static <E> List<E> decorate(List<E> list) {
+ return new FixedSizeList<E>(list);
}
//-----------------------------------------------------------------------
@@ -63,24 +63,24 @@ public class FixedSizeList
* @param list the list to decorate, must not be null
* @throws IllegalArgumentException if list is null
*/
- protected FixedSizeList(List list) {
+ protected FixedSizeList(List<E> list) {
super(list);
}
//-----------------------------------------------------------------------
- public boolean add(Object object) {
+ public boolean add(E object) {
throw new UnsupportedOperationException("List is fixed size");
}
- public void add(int index, Object object) {
+ public void add(int index, E object) {
throw new UnsupportedOperationException("List is fixed size");
}
- public boolean addAll(Collection coll) {
+ public boolean addAll(Collection<? extends E> coll) {
throw new UnsupportedOperationException("List is fixed size");
}
- public boolean addAll(int index, Collection coll) {
+ public boolean addAll(int index, Collection<? extends E> coll) {
throw new UnsupportedOperationException("List is fixed size");
}
@@ -88,7 +88,7 @@ public class FixedSizeList
throw new UnsupportedOperationException("List is fixed size");
}
- public Object get(int index) {
+ public E get(int index) {
return decorated().get(index);
}
@@ -96,7 +96,7 @@ public class FixedSizeList
return decorated().indexOf(object);
}
- public Iterator iterator() {
+ public Iterator<E> iterator() {
return UnmodifiableIterator.decorate(decorated().iterator());
}
@@ -104,15 +104,15 @@ public class FixedSizeList
return decorated().lastIndexOf(object);
}
- public ListIterator listIterator() {
+ public ListIterator<E> listIterator() {
return new FixedSizeListIterator(decorated().listIterator(0));
}
- public ListIterator listIterator(int index) {
+ public ListIterator<E> listIterator(int index) {
return new FixedSizeListIterator(decorated().listIterator(index));
}
- public Object remove(int index) {
+ public E remove(int index) {
throw new UnsupportedOperationException("List is fixed size");
}
@@ -120,28 +120,28 @@ public class FixedSizeList
throw new UnsupportedOperationException("List is fixed size");
}
- public boolean removeAll(Collection coll) {
+ public boolean removeAll(Collection<?> coll) {
throw new UnsupportedOperationException("List is fixed size");
}
- public boolean retainAll(Collection coll) {
+ public boolean retainAll(Collection<?> coll) {
throw new UnsupportedOperationException("List is fixed size");
}
- public Object set(int index, Object object) {
+ public E set(int index, E object) {
return decorated().set(index, object);
}
- public List subList(int fromIndex, int toIndex) {
- List sub = decorated().subList(fromIndex, toIndex);
- return new FixedSizeList(sub);
+ public List<E> subList(int fromIndex, int toIndex) {
+ List<E> sub = decorated().subList(fromIndex, toIndex);
+ return new FixedSizeList<E>(sub);
}
/**
* List iterator that only permits changes via set()
*/
- static class FixedSizeListIterator extends AbstractListIteratorDecorator {
- protected FixedSizeListIterator(ListIterator iterator) {
+ private class FixedSizeListIterator extends AbstractListIteratorDecorator<E> {
+ protected FixedSizeListIterator(ListIterator<E> iterator) {
super(iterator);
}
public void remove() {
http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/java/org/apache/commons/collections/list/GrowthList.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/commons/collections/list/GrowthList.java b/src/java/org/apache/commons/collections/list/GrowthList.java
index ae2f652..bdf7c21 100644
--- a/src/java/org/apache/commons/collections/list/GrowthList.java
+++ b/src/java/org/apache/commons/collections/list/GrowthList.java
@@ -55,7 +55,7 @@ import java.util.List;
* @author Stephen Colebourne
* @author Paul Legato
*/
-public class GrowthList extends AbstractSerializableListDecorator {
+public class GrowthList<E> extends AbstractSerializableListDecorator<E> {
/** Serialization version */
private static final long serialVersionUID = -3620001881672L;
@@ -66,8 +66,8 @@ public class GrowthList extends AbstractSerializableListDecorator {
* @param list the list to decorate, must not be null
* @throws IllegalArgumentException if list is null
*/
- public static List decorate(List list) {
- return new GrowthList(list);
+ public static <E> List<E> decorate(List<E> list) {
+ return new GrowthList<E>(list);
}
//-----------------------------------------------------------------------
@@ -75,7 +75,7 @@ public class GrowthList extends AbstractSerializableListDecorator {
* Constructor that uses an ArrayList internally.
*/
public GrowthList() {
- super(new ArrayList());
+ super(new ArrayList<E>());
}
/**
@@ -85,7 +85,7 @@ public class GrowthList extends AbstractSerializableListDecorator {
* @throws IllegalArgumentException if initial size is invalid
*/
public GrowthList(int initialSize) {
- super(new ArrayList(initialSize));
+ super(new ArrayList<E>(initialSize));
}
/**
@@ -94,7 +94,7 @@ public class GrowthList extends AbstractSerializableListDecorator {
* @param list the list to decorate, must not be null
* @throws IllegalArgumentException if list is null
*/
- protected GrowthList(List list) {
+ protected GrowthList(List<E> list) {
super(list);
}
@@ -117,10 +117,10 @@ public class GrowthList extends AbstractSerializableListDecorator {
* @throws ClassCastException if the underlying list rejects the element
* @throws IllegalArgumentException if the underlying list rejects the element
*/
- public void add(int index, Object element) {
+ public void add(int index, E element) {
int size = decorated().size();
if (index > size) {
- decorated().addAll(Collections.nCopies(index - size, null));
+ decorated().addAll(Collections.<E>nCopies(index - size, null));
}
decorated().add(index, element);
}
@@ -145,11 +145,11 @@ public class GrowthList extends AbstractSerializableListDecorator {
* @throws ClassCastException if the underlying list rejects the element
* @throws IllegalArgumentException if the underlying list rejects the element
*/
- public boolean addAll(int index, Collection coll) {
+ public boolean addAll(int index, Collection<? extends E> coll) {
int size = decorated().size();
boolean result = false;
if (index > size) {
- decorated().addAll(Collections.nCopies(index - size, null));
+ decorated().addAll(Collections.<E>nCopies(index - size, null));
result = true;
}
return (decorated().addAll(index, coll) | result);
@@ -175,10 +175,10 @@ public class GrowthList extends AbstractSerializableListDecorator {
* @throws ClassCastException if the underlying list rejects the element
* @throws IllegalArgumentException if the underlying list rejects the element
*/
- public Object set(int index, Object element) {
+ public E set(int index, E element) {
int size = decorated().size();
if (index >= size) {
- decorated().addAll(Collections.nCopies((index - size) + 1, null));
+ decorated().addAll(Collections.<E>nCopies((index - size) + 1, null));
}
return decorated().set(index, element);
}
http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/java/org/apache/commons/collections/list/LazyList.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/commons/collections/list/LazyList.java b/src/java/org/apache/commons/collections/list/LazyList.java
index ad83195..f1b11c3 100644
--- a/src/java/org/apache/commons/collections/list/LazyList.java
+++ b/src/java/org/apache/commons/collections/list/LazyList.java
@@ -61,13 +61,13 @@ import org.apache.commons.collections.Factory;
* @author Arron Bates
* @author Paul Jack
*/
-public class LazyList extends AbstractSerializableListDecorator {
+public class LazyList<E> extends AbstractSerializableListDecorator<E> {
/** Serialization version */
private static final long serialVersionUID = -1708388017160694542L;
/** The factory to use to lazily instantiate the objects */
- protected final Factory factory;
+ protected final Factory<? extends E> factory;
/**
* Factory method to create a lazily instantiating list.
@@ -76,8 +76,8 @@ public class LazyList extends AbstractSerializableListDecorator {
* @param factory the factory to use for creation, must not be null
* @throws IllegalArgumentException if list or factory is null
*/
- public static List decorate(List list, Factory factory) {
- return new LazyList(list, factory);
+ public static <E> List<E> decorate(List<E> list, Factory<? extends E> factory) {
+ return new LazyList<E>(list, factory);
}
//-----------------------------------------------------------------------
@@ -88,7 +88,7 @@ public class LazyList extends AbstractSerializableListDecorator {
* @param factory the factory to use for creation, must not be null
* @throws IllegalArgumentException if list or factory is null
*/
- protected LazyList(List list, Factory factory) {
+ protected LazyList(List<E> list, Factory<? extends E> factory) {
super(list);
if (factory == null) {
throw new IllegalArgumentException("Factory must not be null");
@@ -107,36 +107,33 @@ public class LazyList extends AbstractSerializableListDecorator {
*
* @param index the index to retrieve
*/
- public Object get(int index) {
+ public E get(int index) {
int size = decorated().size();
if (index < size) {
// within bounds, get the object
- Object object = decorated().get(index);
+ E object = decorated().get(index);
if (object == null) {
// item is a place holder, create new one, set and return
object = factory.create();
decorated().set(index, object);
return object;
- } else {
- // good and ready to go
- return object;
- }
- } else {
- // we have to grow the list
- for (int i = size; i < index; i++) {
- decorated().add(null);
}
- // create our last object, set and return
- Object object = factory.create();
- decorated().add(object);
+ // good and ready to go
return object;
}
+ // we have to grow the list
+ for (int i = size; i < index; i++) {
+ decorated().add(null);
+ }
+ // create our last object, set and return
+ E object = factory.create();
+ decorated().add(object);
+ return object;
}
-
- public List subList(int fromIndex, int toIndex) {
- List sub = decorated().subList(fromIndex, toIndex);
- return new LazyList(sub, factory);
+ public List<E> subList(int fromIndex, int toIndex) {
+ List<E> sub = decorated().subList(fromIndex, toIndex);
+ return new LazyList<E>(sub, factory);
}
}
http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/java/org/apache/commons/collections/list/NodeCachingLinkedList.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/commons/collections/list/NodeCachingLinkedList.java b/src/java/org/apache/commons/collections/list/NodeCachingLinkedList.java
index f997043..0b5a13f 100644
--- a/src/java/org/apache/commons/collections/list/NodeCachingLinkedList.java
+++ b/src/java/org/apache/commons/collections/list/NodeCachingLinkedList.java
@@ -44,7 +44,7 @@ import java.util.Collection;
* @author Phil Steitz
* @author Stephen Colebourne
*/
-public class NodeCachingLinkedList extends AbstractLinkedList implements Serializable {
+public class NodeCachingLinkedList<E> extends AbstractLinkedList<E> implements Serializable {
/** Serialization version */
private static final long serialVersionUID = 6897789178562232073L;
@@ -59,7 +59,7 @@ public class NodeCachingLinkedList extends AbstractLinkedList implements Seriali
* Cached nodes are stored in a singly-linked list with
* <code>next</code> pointing to the next element.
*/
- protected transient Node firstCachedNode;
+ protected transient Node<E> firstCachedNode;
/**
* The size of the cache.
@@ -84,7 +84,7 @@ public class NodeCachingLinkedList extends AbstractLinkedList implements Seriali
*
* @param coll the collection to copy
*/
- public NodeCachingLinkedList(Collection coll) {
+ public NodeCachingLinkedList(Collection<E> coll) {
super(coll);
this.maximumCacheSize = DEFAULT_MAXIMUM_CACHE_SIZE;
}
@@ -137,11 +137,11 @@ public class NodeCachingLinkedList extends AbstractLinkedList implements Seriali
*
* @return a node, or <code>null</code> if there are no nodes in the cache.
*/
- protected Node getNodeFromCache() {
+ protected Node<E> getNodeFromCache() {
if (cacheSize == 0) {
return null;
}
- Node cachedNode = firstCachedNode;
+ Node<E> cachedNode = firstCachedNode;
firstCachedNode = cachedNode.next;
cachedNode.next = null; // This should be changed anyway, but defensively
// set it to null.
@@ -164,13 +164,13 @@ public class NodeCachingLinkedList extends AbstractLinkedList implements Seriali
*
* @param node the node to add to the cache
*/
- protected void addNodeToCache(Node node) {
+ protected void addNodeToCache(Node<E> node) {
if (isCacheFull()) {
// don't cache the node.
return;
}
// clear the node's contents and add it to the cache.
- Node nextCachedNode = firstCachedNode;
+ Node<E> nextCachedNode = firstCachedNode;
node.previous = null;
node.next = nextCachedNode;
node.setValue(null);
@@ -186,14 +186,13 @@ public class NodeCachingLinkedList extends AbstractLinkedList implements Seriali
* @param value value of the new node
* @return the newly created node
*/
- protected Node createNode(Object value) {
- Node cachedNode = getNodeFromCache();
+ protected Node<E> createNode(E value) {
+ Node<E> cachedNode = getNodeFromCache();
if (cachedNode == null) {
return super.createNode(value);
- } else {
- cachedNode.setValue(value);
- return cachedNode;
}
+ cachedNode.setValue(value);
+ return cachedNode;
}
/**
@@ -202,7 +201,7 @@ public class NodeCachingLinkedList extends AbstractLinkedList implements Seriali
*
* @param node the node to remove
*/
- protected void removeNode(Node node) {
+ protected void removeNode(Node<E> node) {
super.removeNode(node);
addNodeToCache(node);
}
@@ -218,9 +217,9 @@ public class NodeCachingLinkedList extends AbstractLinkedList implements Seriali
// {@link AbstractLinkedList.removeAllNodes()} removes the
// nodes by removing references directly from {@link #header}.
int numberOfNodesToCache = Math.min(size, maximumCacheSize - cacheSize);
- Node node = header.next;
+ Node<E> node = header.next;
for (int currentIndex = 0; currentIndex < numberOfNodesToCache; currentIndex++) {
- Node oldNode = node;
+ Node<E> oldNode = node;
node = node.next;
addNodeToCache(oldNode);
}
http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/java/org/apache/commons/collections/list/SetUniqueList.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/commons/collections/list/SetUniqueList.java b/src/java/org/apache/commons/collections/list/SetUniqueList.java
index f70311c..cc32cbf 100644
--- a/src/java/org/apache/commons/collections/list/SetUniqueList.java
+++ b/src/java/org/apache/commons/collections/list/SetUniqueList.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -46,12 +46,12 @@ import org.apache.commons.collections.set.UnmodifiableSet;
*
* @since Commons Collections 3.0
* @version $Revision$ $Date$
- *
+ *
* @author Matthew Hawthorne
* @author Stephen Colebourne
* @author Tom Dunham
*/
-public class SetUniqueList extends AbstractSerializableListDecorator {
+public class SetUniqueList<E> extends AbstractSerializableListDecorator<E> {
/** Serialization version */
private static final long serialVersionUID = 7196982186153478694L;
@@ -59,30 +59,29 @@ public class SetUniqueList extends AbstractSerializableListDecorator {
/**
* Internal Set to maintain uniqueness.
*/
- protected final Set set;
+ protected final Set<E> set;
/**
* Factory method to create a SetList using the supplied list to retain order.
* <p>
* If the list contains duplicates, these are removed (first indexed one kept).
* A <code>HashSet</code> is used for the set behaviour.
- *
+ *
* @param list the list to decorate, must not be null
* @throws IllegalArgumentException if list is null
*/
- public static SetUniqueList decorate(List list) {
+ public static <E> SetUniqueList<E> decorate(List<E> list) {
if (list == null) {
throw new IllegalArgumentException("List must not be null");
}
if (list.isEmpty()) {
- return new SetUniqueList(list, new HashSet());
- } else {
- List temp = new ArrayList(list);
- list.clear();
- SetUniqueList sl = new SetUniqueList(list, new HashSet());
- sl.addAll(temp);
- return sl;
+ return new SetUniqueList<E>(list, new HashSet<E>());
}
+ List<E> temp = new ArrayList<E>(list);
+ list.clear();
+ SetUniqueList<E> sl = new SetUniqueList<E>(list, new HashSet<E>());
+ sl.addAll(temp);
+ return sl;
}
//-----------------------------------------------------------------------
@@ -90,12 +89,12 @@ public class SetUniqueList extends AbstractSerializableListDecorator {
* Constructor that wraps (not copies) the List and specifies the set to use.
* <p>
* The set and list must both be correctly initialised to the same elements.
- *
+ *
* @param set the set to decorate, must not be null
* @param list the list to decorate, must not be null
* @throws IllegalArgumentException if set or list is null
*/
- protected SetUniqueList(List list, Set set) {
+ protected SetUniqueList(List<E> list, Set<E> set) {
super(list);
if (set == null) {
throw new IllegalArgumentException("Set must not be null");
@@ -106,10 +105,10 @@ public class SetUniqueList extends AbstractSerializableListDecorator {
//-----------------------------------------------------------------------
/**
* Gets an unmodifiable view as a Set.
- *
+ *
* @return an unmodifiable set view
*/
- public Set asSet() {
+ public Set<E> asSet() {
return UnmodifiableSet.decorate(set);
}
@@ -121,11 +120,11 @@ public class SetUniqueList extends AbstractSerializableListDecorator {
* The <code>List</code> interface requires that this method returns
* <code>true</code> always. However this class may return <code>false</code>
* because of the <code>Set</code> behaviour.
- *
+ *
* @param object the object to add
* @return true if object was added
*/
- public boolean add(Object object) {
+ public boolean add(E object) {
// gets initial size
final int sizeBefore = size();
@@ -142,11 +141,11 @@ public class SetUniqueList extends AbstractSerializableListDecorator {
* <i>(Violation)</i>
* The <code>List</code> interface makes the assumption that the element is
* always inserted. This may not happen with this implementation.
- *
+ *
* @param index the index to insert at
* @param object the object to add
*/
- public void add(int index, Object object) {
+ public void add(int index, E object) {
// adds element if it is not contained already
if (set.contains(object) == false) {
super.add(index, object);
@@ -160,10 +159,10 @@ public class SetUniqueList extends AbstractSerializableListDecorator {
* <i>(Violation)</i>
* The <code>List</code> interface makes the assumption that the element is
* always inserted. This may not happen with this implementation.
- *
+ *
* @param coll the collection to add
*/
- public boolean addAll(Collection coll) {
+ public boolean addAll(Collection<? extends E> coll) {
return addAll(size(), coll);
}
@@ -176,22 +175,24 @@ public class SetUniqueList extends AbstractSerializableListDecorator {
* <i>(Violation)</i>
* The <code>List</code> interface makes the assumption that the elements
* are always inserted. This may not happen with this implementation.
- *
+ *
* @param index the index to insert at
* @param coll the collection to add in iterator order
* @return true if this collection changed
*/
- public boolean addAll(int index, Collection coll) {
- // gets initial size
- final int sizeBefore = size();
-
- // adds all elements
- for (final Iterator it = coll.iterator(); it.hasNext();) {
- add(it.next());
+ public boolean addAll(int index, Collection<? extends E> coll) {
+ HashSet<E> temp = new HashSet<E>(coll);
+ temp.removeAll(set);
+ if (temp.isEmpty()) {
+ return false;
}
-
- // compares sizes to detect if collection changed
- return sizeBefore != size();
+ for (E e : coll) {
+ if (temp.contains(e)) {
+ add(index, e);
+ index++;
+ }
+ }
+ return true;
}
//-----------------------------------------------------------------------
@@ -202,18 +203,18 @@ public class SetUniqueList extends AbstractSerializableListDecorator {
* Afterwards, any previous duplicate is removed
* If the object is not already in the list then a normal set occurs.
* If it is present, then the old version is removed.
- *
+ *
* @param index the index to insert at
* @param object the object to set
* @return the previous object
*/
- public Object set(int index, Object object) {
+ public E set(int index, E object) {
int pos = indexOf(object);
- Object removed = super.set(index, object);
+ E removed = super.set(index, object);
if (pos == -1 || pos == index) {
return removed;
}
-
+
// the object is already in the uniq list
// (and it hasn't been swapped with itself)
super.remove(pos); // remove the duplicate by index
@@ -227,19 +228,19 @@ public class SetUniqueList extends AbstractSerializableListDecorator {
return result;
}
- public Object remove(int index) {
- Object result = super.remove(index);
+ public E remove(int index) {
+ E result = super.remove(index);
set.remove(result);
return result;
}
- public boolean removeAll(Collection coll) {
+ public boolean removeAll(Collection<?> coll) {
boolean result = super.removeAll(coll);
set.removeAll(coll);
return result;
}
- public boolean retainAll(Collection coll) {
+ public boolean retainAll(Collection<?> coll) {
boolean result = super.retainAll(coll);
set.retainAll(coll);
return result;
@@ -254,41 +255,61 @@ public class SetUniqueList extends AbstractSerializableListDecorator {
return set.contains(object);
}
- public boolean containsAll(Collection coll) {
+ public boolean containsAll(Collection<?> coll) {
return set.containsAll(coll);
}
- public Iterator iterator() {
- return new SetListIterator(super.iterator(), set);
+ public Iterator<E> iterator() {
+ return new SetListIterator<E>(super.iterator(), set);
+ }
+
+ public ListIterator<E> listIterator() {
+ return new SetListListIterator<E>(super.listIterator(), set);
}
- public ListIterator listIterator() {
- return new SetListListIterator(super.listIterator(), set);
+ public ListIterator<E> listIterator(int index) {
+ return new SetListListIterator<E>(super.listIterator(index), set);
}
- public ListIterator listIterator(int index) {
- return new SetListListIterator(super.listIterator(index), set);
+ public List<E> subList(int fromIndex, int toIndex) {
+ List<E> superSubList = super.subList(fromIndex, toIndex);
+ Set<E> subSet = createSetBasedOnList(set, superSubList);
+ return new SetUniqueList<E>(superSubList, subSet);
}
- public List subList(int fromIndex, int toIndex) {
- return new SetUniqueList(super.subList(fromIndex, toIndex), set);
+ @SuppressWarnings("unchecked")
+ protected Set<E> createSetBasedOnList(Set<E> set, List<E> list) {
+ Set<E> subSet = null;
+ if (set.getClass().equals(HashSet.class)) {
+ subSet = new HashSet<E>();
+ } else {
+ try {
+ subSet = (Set<E>) set.getClass().newInstance();
+ } catch (InstantiationException ie) {
+ subSet = new HashSet<E>();
+ } catch (IllegalAccessException iae) {
+ subSet = new HashSet<E>();
+ }
+ }
+ subSet.addAll(list);
+ return subSet;
}
//-----------------------------------------------------------------------
/**
* Inner class iterator.
*/
- static class SetListIterator extends AbstractIteratorDecorator {
-
- protected final Set set;
- protected Object last = null;
-
- protected SetListIterator(Iterator it, Set set) {
+ static class SetListIterator<E> extends AbstractIteratorDecorator<E> {
+
+ protected final Set<E> set;
+ protected E last = null;
+
+ protected SetListIterator(Iterator<E> it, Set<E> set) {
super(it);
this.set = set;
}
-
- public Object next() {
+
+ public E next() {
last = super.next();
return last;
}
@@ -299,26 +320,26 @@ public class SetUniqueList extends AbstractSerializableListDecorator {
last = null;
}
}
-
+
/**
* Inner class iterator.
*/
- static class SetListListIterator extends AbstractListIteratorDecorator {
-
- protected final Set set;
- protected Object last = null;
-
- protected SetListListIterator(ListIterator it, Set set) {
+ static class SetListListIterator<E> extends AbstractListIteratorDecorator<E> {
+
+ protected final Set<E> set;
+ protected E last = null;
+
+ protected SetListListIterator(ListIterator<E> it, Set<E> set) {
super(it);
this.set = set;
}
-
- public Object next() {
+
+ public E next() {
last = super.next();
return last;
}
- public Object previous() {
+ public E previous() {
last = super.previous();
return last;
}
@@ -329,16 +350,16 @@ public class SetUniqueList extends AbstractSerializableListDecorator {
last = null;
}
- public void add(Object object) {
+ public void add(E object) {
if (set.contains(object) == false) {
super.add(object);
set.add(object);
}
}
-
- public void set(Object object) {
+
+ public void set(E object) {
throw new UnsupportedOperationException("ListIterator does not support set");
}
}
-
+
}
http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/java/org/apache/commons/collections/list/SynchronizedList.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/commons/collections/list/SynchronizedList.java b/src/java/org/apache/commons/collections/list/SynchronizedList.java
index e6f255c..a01e656 100644
--- a/src/java/org/apache/commons/collections/list/SynchronizedList.java
+++ b/src/java/org/apache/commons/collections/list/SynchronizedList.java
@@ -122,7 +122,7 @@ public class SynchronizedList<E> extends SynchronizedCollection<E> implements Li
*
* @return an iterator that must be manually synchronized on the collection
*/
- public ListIterator listIterator() {
+ public ListIterator<E> listIterator() {
return getList().listIterator();
}
@@ -136,7 +136,7 @@ public class SynchronizedList<E> extends SynchronizedCollection<E> implements Li
*
* @return an iterator that must be manually synchronized on the collection
*/
- public ListIterator listIterator(int index) {
+ public ListIterator<E> listIterator(int index) {
return getList().listIterator(index);
}