You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ba...@apache.org on 2009/09/15 07:30:02 UTC

svn commit: r814997 [6/18] - in /commons/proper/collections/trunk/src: java/org/apache/commons/collections/ java/org/apache/commons/collections/bag/ java/org/apache/commons/collections/bidimap/ java/org/apache/commons/collections/buffer/ java/org/apach...

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/IteratorChain.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/IteratorChain.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/IteratorChain.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/IteratorChain.java Tue Sep 15 05:29:56 2009
@@ -26,45 +26,50 @@
 /**
  * An IteratorChain is an Iterator that wraps a number of Iterators.
  * <p>
- * This class makes multiple iterators look like one to the caller
- * When any method from the Iterator interface is called, the IteratorChain
- * will delegate to a single underlying Iterator. The IteratorChain will
- * invoke the Iterators in sequence until all Iterators are exhausted.
+ * This class makes multiple iterators look like one to the caller When any
+ * method from the Iterator interface is called, the IteratorChain will delegate
+ * to a single underlying Iterator. The IteratorChain will invoke the Iterators
+ * in sequence until all Iterators are exhausted.
  * <p>
- * Under many circumstances, linking Iterators together in this manner is
- * more efficient (and convenient) than reading out the contents of each
- * Iterator into a List and creating a new Iterator.
+ * Under many circumstances, linking Iterators together in this manner is more
+ * efficient (and convenient) than reading out the contents of each Iterator
+ * into a List and creating a new Iterator.
  * <p>
  * Calling a method that adds new Iterator<i>after a method in the Iterator
- * interface has been called</i> will result in an UnsupportedOperationException.
- * Subclasses should <i>take care</i> to not alter the underlying List of Iterators.
+ * interface has been called</i> will result in an
+ * UnsupportedOperationException. Subclasses should <i>take care</i> to not
+ * alter the underlying List of Iterators.
  * <p>
- * NOTE: As from version 3.0, the IteratorChain may contain no
- * iterators. In this case the class will function as an empty iterator.
+ * NOTE: As from version 3.0, the IteratorChain may contain no iterators. In
+ * this case the class will function as an empty iterator.
  *
  * @since Commons Collections 2.1
- * @version $Revision$ $Date$
+ * @version $Revision$ $Date: 2006-10-27 19:52:37 -0500 (Fri, 27 Oct
+ * 2006) $
  *
  * @author Morgan Delagrange
  * @author Stephen Colebourne
  */
-public class IteratorChain implements Iterator {
+public class IteratorChain<E> implements Iterator<E> {
 
     /** The chain of iterators */
-    protected final List iteratorChain = new ArrayList();
+    protected final List<Iterator<? extends E>> iteratorChain = new ArrayList<Iterator<? extends E>>();
+
     /** The index of the current iterator */
     protected int currentIteratorIndex = 0;
+
     /** The current iterator */
-    protected Iterator currentIterator = null;
+    protected Iterator<? extends E> currentIterator = null;
+
     /**
-     * The "last used" Iterator is the Iterator upon which
-     * next() or hasNext() was most recently called
-     * used for the remove() operation only
+     * The "last used" Iterator is the Iterator upon which next() or hasNext()
+     * was most recently called used for the remove() operation only
      */
-    protected Iterator lastUsedIterator = null;
+    protected Iterator<? extends E> lastUsedIterator = null;
+
     /**
-     * ComparatorChain is "locked" after the first time
-     * compare(Object,Object) is called
+     * ComparatorChain is "locked" after the first time compare(Object,Object)
+     * is called
      */
     protected boolean isLocked = false;
 
@@ -72,8 +77,8 @@
     /**
      * Construct an IteratorChain with no Iterators.
      * <p>
-     * You will normally use {@link #addIterator(Iterator)} to add
-     * some iterators after using this constructor.
+     * You will normally use {@link #addIterator(Iterator)} to add some
+     * iterators after using this constructor.
      */
     public IteratorChain() {
         super();
@@ -82,49 +87,47 @@
     /**
      * Construct an IteratorChain with a single Iterator.
      * <p>
-     * This method takes one iterator. The newly constructed iterator
-     * will iterate through that iterator. Thus calling this constructor
-     * on its own will have no effect other than decorating the input iterator.
+     * This method takes one iterator. The newly constructed iterator will
+     * iterate through that iterator. Thus calling this constructor on its own
+     * will have no effect other than decorating the input iterator.
      * <p>
-     * You will normally use {@link #addIterator(Iterator)} to add
-     * some more iterators after using this constructor.
-     *
-     * @param iterator  the first child iterator in the IteratorChain, not null
+     * You will normally use {@link #addIterator(Iterator)} to add some more
+     * iterators after using this constructor.
+     * 
+     * @param iterator the first child iterator in the IteratorChain, not null
      * @throws NullPointerException if the iterator is null
      */
-    public IteratorChain(Iterator iterator) {
+    public IteratorChain(Iterator<? extends E> iterator) {
         super();
         addIterator(iterator);
     }
 
     /**
-     * Constructs a new <code>IteratorChain</code> over the two
-     * given iterators.
+     * Constructs a new <code>IteratorChain</code> over the two given iterators.
      * <p>
-     * This method takes two iterators. The newly constructed iterator
-     * will iterate through each one of the input iterators in turn.
-     *
-     * @param first  the first child iterator in the IteratorChain, not null
-     * @param second  the second child iterator in the IteratorChain, not null
+     * This method takes two iterators. The newly constructed iterator will
+     * iterate through each one of the input iterators in turn.
+     * 
+     * @param first the first child iterator in the IteratorChain, not null
+     * @param second the second child iterator in the IteratorChain, not null
      * @throws NullPointerException if either iterator is null
      */
-    public IteratorChain(Iterator first, Iterator second) {
+    public IteratorChain(Iterator<? extends E> first, Iterator<? extends E> second) {
         super();
         addIterator(first);
         addIterator(second);
     }
 
     /**
-     * Constructs a new <code>IteratorChain</code> over the array
-     * of iterators.
+     * Constructs a new <code>IteratorChain</code> over the array of iterators.
      * <p>
      * This method takes an array of iterators. The newly constructed iterator
      * will iterate through each one of the input iterators in turn.
-     *
-     * @param iteratorChain  the array of iterators, not null
+     * 
+     * @param iteratorChain the array of iterators, not null
      * @throws NullPointerException if iterators array is or contains null
      */
-    public IteratorChain(Iterator[] iteratorChain) {
+    public IteratorChain(Iterator<? extends E>[] iteratorChain) {
         super();
         for (int i = 0; i < iteratorChain.length; i++) {
             addIterator(iteratorChain[i]);
@@ -132,33 +135,33 @@
     }
 
     /**
-     * Constructs a new <code>IteratorChain</code> over the collection
-     * of iterators.
+     * Constructs a new <code>IteratorChain</code> over the collection of
+     * iterators.
      * <p>
-     * This method takes a collection of iterators. The newly constructed iterator
-     * will iterate through each one of the input iterators in turn.
-     *
-     * @param iteratorChain  the collection of iterators, not null
+     * This method takes a collection of iterators. The newly constructed
+     * iterator will iterate through each one of the input iterators in turn.
+     * 
+     * @param iteratorChain the collection of iterators, not null
      * @throws NullPointerException if iterators collection is or contains null
-     * @throws ClassCastException if iterators collection doesn't contain an iterator
+     * @throws ClassCastException if iterators collection doesn't contain an
+     * iterator
      */
-    public IteratorChain(Collection iteratorChain) {
+    public IteratorChain(Collection<Iterator<? extends E>> iteratorChain) {
         super();
-        for (Iterator it = iteratorChain.iterator(); it.hasNext();) {
-            Iterator item = (Iterator) it.next();
-            addIterator(item);
+        for (Iterator<? extends E> iterator : iteratorChain) {
+            addIterator(iterator);
         }
     }
 
     //-----------------------------------------------------------------------
     /**
      * Add an Iterator to the end of the chain
-     *
+     * 
      * @param iterator Iterator to add
      * @throws IllegalStateException if I've already started iterating
      * @throws NullPointerException if the iterator is null
      */
-    public void addIterator(Iterator iterator) {
+    public void addIterator(Iterator<? extends E> iterator) {
         checkLocked();
         if (iterator == null) {
             throw new NullPointerException("Iterator must not be null");
@@ -168,14 +171,15 @@
 
     /**
      * Set the Iterator at the given index
-     *
-     * @param index      index of the Iterator to replace
-     * @param iterator   Iterator to place at the given index
+     * 
+     * @param index index of the Iterator to replace
+     * @param iterator Iterator to place at the given index
      * @throws IndexOutOfBoundsException if index &lt; 0 or index &gt; size()
      * @throws IllegalStateException if I've already started iterating
      * @throws NullPointerException if the iterator is null
      */
-    public void setIterator(int index, Iterator iterator) throws IndexOutOfBoundsException {
+    public void setIterator(int index, Iterator<? extends E> iterator)
+            throws IndexOutOfBoundsException {
         checkLocked();
         if (iterator == null) {
             throw new NullPointerException("Iterator must not be null");
@@ -185,16 +189,16 @@
 
     /**
      * Get the list of Iterators (unmodifiable)
-     *
+     * 
      * @return the unmodifiable list of iterators added
      */
-    public List getIterators() {
+    public List<Iterator<? extends E>> getIterators() {
         return UnmodifiableList.decorate(iteratorChain);
     }
 
     /**
      * Number of Iterators in the current IteratorChain.
-     *
+     * 
      * @return Iterator count
      */
     public int size() {
@@ -203,9 +207,9 @@
 
     /**
      * Determine if modifications can still be made to the IteratorChain.
-     * IteratorChains cannot be modified once they have executed a method
-     * from the Iterator interface.
-     *
+     * IteratorChains cannot be modified once they have executed a method from
+     * the Iterator interface.
+     * 
      * @return true if IteratorChain cannot be modified, false if it can
      */
     public boolean isLocked() {
@@ -217,13 +221,14 @@
      */
     private void checkLocked() {
         if (isLocked == true) {
-            throw new UnsupportedOperationException("IteratorChain cannot be changed after the first use of a method from the Iterator interface");
+            throw new UnsupportedOperationException(
+                    "IteratorChain cannot be changed after the first use of a method from the Iterator interface");
         }
     }
 
     /**
-     * Lock the chain so no more iterators can be added.
-     * This must be called from all Iterator interface methods.
+     * Lock the chain so no more iterators can be added. This must be called
+     * from all Iterator interface methods.
      */
     private void lockChain() {
         if (isLocked == false) {
@@ -232,31 +237,32 @@
     }
 
     /**
-     * Updates the current iterator field to ensure that the current Iterator
-     * is not exhausted
+     * Updates the current iterator field to ensure that the current Iterator is
+     * not exhausted
      */
     protected void updateCurrentIterator() {
         if (currentIterator == null) {
             if (iteratorChain.isEmpty()) {
-                currentIterator = EmptyIterator.INSTANCE;
+                currentIterator = EmptyIterator.<E> getInstance();
             } else {
-                currentIterator = (Iterator) iteratorChain.get(0);
+                currentIterator = iteratorChain.get(0);
             }
             // set last used iterator here, in case the user calls remove
             // before calling hasNext() or next() (although they shouldn't)
             lastUsedIterator = currentIterator;
         }
 
-        while (currentIterator.hasNext() == false && currentIteratorIndex < iteratorChain.size() - 1) {
+        while (currentIterator.hasNext() == false
+                && currentIteratorIndex < iteratorChain.size() - 1) {
             currentIteratorIndex++;
-            currentIterator = (Iterator) iteratorChain.get(currentIteratorIndex);
+            currentIterator = iteratorChain.get(currentIteratorIndex);
         }
     }
 
     //-----------------------------------------------------------------------
     /**
      * Return true if any Iterator in the IteratorChain has a remaining element.
-     *
+     * 
      * @return true if elements remain
      */
     public boolean hasNext() {
@@ -269,11 +275,12 @@
 
     /**
      * Returns the next Object of the current Iterator
-     *
+     * 
      * @return Object from the current Iterator
-     * @throws java.util.NoSuchElementException if all the Iterators are exhausted
+     * @throws java.util.NoSuchElementException if all the Iterators are
+     * exhausted
      */
-    public Object next() {
+    public E next() {
         lockChain();
         updateCurrentIterator();
         lastUsedIterator = currentIterator;
@@ -282,18 +289,17 @@
     }
 
     /**
-     * Removes from the underlying collection the last element
-     * returned by the Iterator.  As with next() and hasNext(),
-     * this method calls remove() on the underlying Iterator.
-     * Therefore, this method may throw an
-     * UnsupportedOperationException if the underlying
-     * Iterator does not support this method.
-     *
-     * @throws UnsupportedOperationException
-     *   if the remove operator is not supported by the underlying Iterator
-     * @throws IllegalStateException
-     *   if the next method has not yet been called, or the remove method has
-     *   already been called after the last call to the next method.
+     * Removes from the underlying collection the last element returned by the
+     * Iterator. As with next() and hasNext(), this method calls remove() on the
+     * underlying Iterator. Therefore, this method may throw an
+     * UnsupportedOperationException if the underlying Iterator does not support
+     * this method.
+     * 
+     * @throws UnsupportedOperationException if the remove operator is not
+     * supported by the underlying Iterator
+     * @throws IllegalStateException if the next method has not yet been called,
+     * or the remove method has already been called after the last call to the
+     * next method.
      */
     public void remove() {
         lockChain();

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/IteratorEnumeration.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/IteratorEnumeration.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/IteratorEnumeration.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/IteratorEnumeration.java Tue Sep 15 05:29:56 2009
@@ -19,36 +19,35 @@
 import java.util.Enumeration;
 import java.util.Iterator;
 
-/** 
- * Adapter to make an {@link Iterator Iterator} instance appear to be
- * an {@link Enumeration Enumeration} instance.
+/**
+ * Adapter to make an {@link Iterator Iterator} instance appear to be an
+ * {@link Enumeration Enumeration} instance.
  *
  * @since Commons Collections 1.0
  * @version $Revision$ $Date$
  *
  * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  */
-public class IteratorEnumeration implements Enumeration {
-    
+public class IteratorEnumeration<E> implements Enumeration<E> {
+
     /** The iterator being decorated. */
-    private Iterator iterator;
-    
+    private Iterator<? extends E> iterator;
+
     /**
-     * Constructs a new <code>IteratorEnumeration</code> that will not 
-     * function until {@link #setIterator(Iterator) setIterator} is  
-     * invoked.
+     * Constructs a new <code>IteratorEnumeration</code> that will not function
+     * until {@link #setIterator(Iterator) setIterator} is invoked.
      */
     public IteratorEnumeration() {
         super();
     }
 
     /**
-     * Constructs a new <code>IteratorEnumeration</code> that will use
-     * the given iterator. 
+     * Constructs a new <code>IteratorEnumeration</code> that will use the given
+     * iterator.
      * 
-     * @param iterator  the iterator to use
+     * @param iterator the iterator to use
      */
-    public IteratorEnumeration( Iterator iterator ) {
+    public IteratorEnumeration(Iterator<? extends E> iterator) {
         super();
         this.iterator = iterator;
     }
@@ -57,22 +56,22 @@
     //-------------------------------------------------------------------------
 
     /**
-     *  Returns true if the underlying iterator has more elements.
-     *
-     *  @return true if the underlying iterator has more elements
+     * Returns true if the underlying iterator has more elements.
+     * 
+     * @return true if the underlying iterator has more elements
      */
     public boolean hasMoreElements() {
         return iterator.hasNext();
     }
 
     /**
-     *  Returns the next element from the underlying iterator.
-     *
-     *  @return the next element from the underlying iterator.
-     *  @throws java.util.NoSuchElementException  if the underlying iterator has no
-     *    more elements
+     * Returns the next element from the underlying iterator.
+     * 
+     * @return the next element from the underlying iterator.
+     * @throws java.util.NoSuchElementException if the underlying iterator has
+     * no more elements
      */
-    public Object nextElement() {
+    public E nextElement() {
         return iterator.next();
     }
 
@@ -80,21 +79,21 @@
     //-------------------------------------------------------------------------
 
     /**
-     *  Returns the underlying iterator.
+     * Returns the underlying iterator.
      * 
-     *  @return the underlying iterator
+     * @return the underlying iterator
      */
-    public Iterator getIterator() {
+    public Iterator<? extends E> getIterator() {
         return iterator;
     }
 
     /**
-     *  Sets the underlying iterator.
-     *
-     *  @param iterator  the new underlying iterator
+     * Sets the underlying iterator.
+     * 
+     * @param iterator the new underlying iterator
      */
-    public void setIterator( Iterator iterator ) {
+    public void setIterator(Iterator<? extends E> iterator) {
         this.iterator = iterator;
     }
-    
+
 }

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/LoopingIterator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/LoopingIterator.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/LoopingIterator.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/LoopingIterator.java Tue Sep 15 05:29:56 2009
@@ -38,12 +38,12 @@
  * @author <a href="mailto:joncrlsn@users.sf.net">Jonathan Carlson</a>
  * @author Stephen Colebourne
  */
-public class LoopingIterator implements ResettableIterator {
+public class LoopingIterator<E> implements ResettableIterator<E> {
     
     /** The collection to base the iterator on */
-    private Collection collection;
+    private Collection<? extends E> collection;
     /** The current iterator */
-    private Iterator iterator;
+    private Iterator<? extends E> iterator;
 
     /**
      * Constructor that wraps a collection.
@@ -54,7 +54,7 @@
      * @param coll  the collection to wrap
      * @throws NullPointerException if the collection is null
      */
-    public LoopingIterator(Collection coll) {
+    public LoopingIterator(Collection<? extends E> coll) {
         if (coll == null) {
             throw new NullPointerException("The collection must not be null");
         }
@@ -82,7 +82,7 @@
      * @throws NoSuchElementException if there are no elements
      *         at all.  Use {@link #hasNext} to avoid this error.
      */
-    public Object next() {
+    public E next() {
         if (collection.size() == 0) {
             throw new NoSuchElementException("There are no elements for this iterator to loop on");
         }

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/LoopingListIterator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/LoopingListIterator.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/LoopingListIterator.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/LoopingListIterator.java Tue Sep 15 05:29:56 2009
@@ -39,12 +39,12 @@
  *
  * @author Eric Crampton <cc...@eonomine.com>
  */
-public class LoopingListIterator implements ResettableListIterator {
+public class LoopingListIterator<E> implements ResettableListIterator<E> {
 
     /** The list to base the iterator on */
-    private List list;
+    private List<E> list;
     /** The current list iterator */
-    private ListIterator iterator;
+    private ListIterator<E> iterator;
 
     /**
      * Constructor that wraps a list.
@@ -56,7 +56,7 @@
      * @param list the list to wrap
      * @throws NullPointerException if the list it null
      */
-    public LoopingListIterator(List list) {
+    public LoopingListIterator(List<E> list) {
         if (list == null) {
             throw new NullPointerException("The list must not be null");
         }
@@ -84,7 +84,7 @@
      * @return the object after the last element returned
      * @throws NoSuchElementException if there are no elements in the list
      */
-    public Object next() {
+    public E next() {
         if (list.isEmpty()) {
             throw new NoSuchElementException(
                 "There are no elements for this iterator to loop on");
@@ -113,9 +113,8 @@
         }
         if (iterator.hasNext() == false) {
             return 0;
-        } else {
-            return iterator.nextIndex();
         }
+        return iterator.nextIndex();
     }
 
     /**
@@ -139,21 +138,20 @@
      * @return the object before the last element returned
      * @throws NoSuchElementException if there are no elements in the list
      */
-    public Object previous() {
+    public E previous() {
         if (list.isEmpty()) {
             throw new NoSuchElementException(
                 "There are no elements for this iterator to loop on");
         }
         if (iterator.hasPrevious() == false) {
-            Object result = null;
+            E result = null;
             while (iterator.hasNext()) {
                 result = iterator.next();
             }
             iterator.previous();
             return result;
-        } else {
-            return iterator.previous();
         }
+        return iterator.previous();
     }
 
     /**
@@ -174,9 +172,8 @@
         }
         if (iterator.hasPrevious() == false) {
             return list.size() - 1;
-        } else {
-            return iterator.previousIndex();
         }
+        return iterator.previousIndex();
     }
 
     /**
@@ -216,7 +213,7 @@
      * @throws UnsupportedOperationException if the add method is not
      *  supported by the iterator implementation of the underlying list
      */
-    public void add(Object obj) {
+    public void add(E obj) {
         iterator.add(obj);
     }
 
@@ -232,7 +229,7 @@
      * @throws UnsupportedOperationException if the set method is not
      *  supported by the iterator implementation of the underlying list
      */
-    public void set(Object obj) {
+    public void set(E obj) {
         iterator.set(obj);
     }
 

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/ObjectArrayIterator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/ObjectArrayIterator.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/ObjectArrayIterator.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/ObjectArrayIterator.java Tue Sep 15 05:29:56 2009
@@ -40,11 +40,11 @@
  * @author Stephen Colebourne
  * @author Phil Steitz
  */
-public class ObjectArrayIterator
-        implements Iterator, ResettableIterator {
+public class ObjectArrayIterator<E>
+        implements Iterator<E>, ResettableIterator<E> {
 
     /** The array */
-    protected Object[] array = null;
+    protected E[] array = null;
     /** The start index to loop from */
     protected int startIndex = 0;
     /** The end index to loop to */
@@ -69,7 +69,7 @@
      * @param array the array to iterate over
      * @throws NullPointerException if <code>array</code> is <code>null</code>
      */
-    public ObjectArrayIterator(Object[] array) {
+    public ObjectArrayIterator(E[] array) {
         this(array, 0, array.length);
     }
 
@@ -82,7 +82,7 @@
      * @throws NullPointerException if <code>array</code> is <code>null</code>
      * @throws IndexOutOfBoundsException if the start index is out of bounds
      */
-    public ObjectArrayIterator(Object array[], int start) {
+    public ObjectArrayIterator(E array[], int start) {
         this(array, start, array.length);
     }
 
@@ -97,7 +97,7 @@
      * @throws IllegalArgumentException if end index is before the start
      * @throws NullPointerException if <code>array</code> is <code>null</code>
      */
-    public ObjectArrayIterator(Object array[], int start, int end) {
+    public ObjectArrayIterator(E array[], int start, int end) {
         super();
         if (start < 0) {
             throw new ArrayIndexOutOfBoundsException("Start index must not be less than zero");
@@ -136,7 +136,7 @@
      * @throws NoSuchElementException if all the elements in the array
      *    have already been returned
      */
-    public Object next() {
+    public E next() {
         if (hasNext() == false) {
             throw new NoSuchElementException();
         }
@@ -162,7 +162,7 @@
      * the no-arg constructor was used and {@link #setArray} has never
      * been called with a valid array.
      */
-    public Object[] getArray() {
+    public E[] getArray() {
         return this.array;
     }
 
@@ -178,7 +178,7 @@
      * @throws IllegalStateException if the <code>array</code> was set in the constructor
      * @throws NullPointerException if <code>array</code> is <code>null</code>
      */
-    public void setArray(Object[] array) {
+    public void setArray(E[] array) {
         if (this.array != null) {
             throw new IllegalStateException("The array to iterate over has already been set");
         }

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/ReverseListIterator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/ReverseListIterator.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/ReverseListIterator.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/ReverseListIterator.java Tue Sep 15 05:29:56 2009
@@ -38,12 +38,12 @@
  * @since Commons Collections 3.2
  * @version $Revision: $ $Date$
  */
-public class ReverseListIterator implements ResettableListIterator {
+public class ReverseListIterator<E> implements ResettableListIterator<E> {
 
     /** The list being wrapped. */
-    private final List list;
+    private final List<E> list;
     /** The list iterator being wrapped. */
-    private ListIterator iterator;
+    private ListIterator<E> iterator;
     /** Flag to indicate if updating is possible at the moment. */
     private boolean validForUpdate = true;
 
@@ -53,7 +53,7 @@
      * @param list  the list to create a reversed iterator for
      * @throws NullPointerException if the list is null
      */
-    public ReverseListIterator(List list) {
+    public ReverseListIterator(List<E> list) {
         super();
         this.list = list;
         iterator = list.listIterator(list.size());
@@ -75,8 +75,8 @@
      *
      * @return the next element in the iterator
      */
-    public Object next() {
-        Object obj = iterator.previous();
+    public E next() {
+        E obj = iterator.previous();
         validForUpdate = true;
         return obj;
     }
@@ -105,8 +105,8 @@
      *
      * @return the previous element in the iterator
      */
-    public Object previous() {
-        Object obj = iterator.next();
+    public E previous() {
+        E obj = iterator.next();
         validForUpdate = true;
         return obj;
     }
@@ -140,7 +140,7 @@
      * @throws UnsupportedOperationException if the list is unmodifiable
      * @throws IllegalStateException if the iterator is not in a valid state for set
      */
-    public void set(Object obj) {
+    public void set(E obj) {
         if (validForUpdate == false) {
             throw new IllegalStateException("Cannot set to list until next() or previous() called");
         }
@@ -154,7 +154,7 @@
      * @throws UnsupportedOperationException if the list is unmodifiable
      * @throws IllegalStateException if the iterator is not in a valid state for set
      */
-    public void add(Object obj) {
+    public void add(E obj) {
         // the validForUpdate flag is needed as the necessary previous()
         // method call re-enables remove and add
         if (validForUpdate == false) {

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/SingletonListIterator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/SingletonListIterator.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/SingletonListIterator.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/SingletonListIterator.java Tue Sep 15 05:29:56 2009
@@ -31,19 +31,19 @@
  * @author Stephen Colebourne
  * @author Rodney Waldhoff
  */
-public class SingletonListIterator implements ListIterator, ResettableListIterator {
+public class SingletonListIterator<E> implements ListIterator<E>, ResettableListIterator<E> {
 
     private boolean beforeFirst = true;
     private boolean nextCalled = false;
     private boolean removed = false;
-    private Object object;
+    private E object;
 
     /**
      * Constructs a new <code>SingletonListIterator</code>.
      *
      * @param object  the single object to return from the iterator
      */
-    public SingletonListIterator(Object object) {
+    public SingletonListIterator(E object) {
         super();
         this.object = object;
     }
@@ -100,7 +100,7 @@
      * @throws NoSuchElementException if the single object has already 
      *    been returned
      */
-    public Object next() {
+    public E next() {
         if (!beforeFirst || removed) {
             throw new NoSuchElementException();
         }
@@ -118,7 +118,7 @@
      * @throws NoSuchElementException if the single object has not already 
      *    been returned
      */
-    public Object previous() {
+    public E previous() {
         if (beforeFirst || removed) {
             throw new NoSuchElementException();
         }
@@ -147,7 +147,7 @@
      *
      * @throws UnsupportedOperationException always
      */
-    public void add(Object obj) {
+    public void add(E obj) {
         throw new UnsupportedOperationException("add() is not supported by this iterator");
     }
     
@@ -158,7 +158,7 @@
      * @throws IllegalStateException if <tt>next</tt> has not been called 
      *          or the object has been removed
      */
-    public void set(Object obj) {
+    public void set(E obj) {
         if (!nextCalled || removed) {
             throw new IllegalStateException();
         }

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/TransformIterator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/TransformIterator.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/TransformIterator.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/TransformIterator.java Tue Sep 15 05:29:56 2009
@@ -29,18 +29,18 @@
  * @author James Strachan
  * @author Stephen Colebourne
  */
-public class TransformIterator implements Iterator {
+public class TransformIterator<I, O> implements Iterator<O> {
 
     /** The iterator being used */
-    private Iterator iterator;
+    private Iterator<? extends I> iterator;
     /** The transformer being used */
-    private Transformer transformer;
+    private Transformer<? super I, ? extends O> transformer;
 
     //-----------------------------------------------------------------------
     /**
      * Constructs a new <code>TransformIterator</code> that will not function
-     * until the {@link #setIterator(Iterator) setIterator} method is 
-     * invoked.
+     * until the {@link #setIterator(Iterator) setIterator} and 
+     * {@link #setTransformer(Transformer)} methods are invoked.
      */
     public TransformIterator() {
         super();
@@ -52,7 +52,7 @@
      *
      * @param iterator  the iterator to use
      */
-    public TransformIterator(Iterator iterator) {
+    public TransformIterator(Iterator<? extends I> iterator) {
         super();
         this.iterator = iterator;
     }
@@ -65,7 +65,7 @@
      * @param iterator  the iterator to use
      * @param transformer  the transformer to use
      */
-    public TransformIterator(Iterator iterator, Transformer transformer) {
+    public TransformIterator(Iterator<? extends I> iterator, Transformer<? super I, ? extends O> transformer) {
         super();
         this.iterator = iterator;
         this.transformer = transformer;
@@ -84,7 +84,7 @@
      * @return the next object
      * @throws java.util.NoSuchElementException if there are no more elements
      */
-    public Object next() {
+    public O next() {
         return transform(iterator.next());
     }
 
@@ -98,7 +98,7 @@
      * 
      * @return the iterator.
      */
-    public Iterator getIterator() {
+    public Iterator<? extends I> getIterator() {
         return iterator;
     }
 
@@ -108,7 +108,7 @@
      * 
      * @param iterator  the iterator to use
      */
-    public void setIterator(Iterator iterator) {
+    public void setIterator(Iterator<? extends I> iterator) {
         this.iterator = iterator;
     }
 
@@ -118,7 +118,7 @@
      * 
      * @return the transformer.
      */
-    public Transformer getTransformer() {
+    public Transformer<? super I, ? extends O> getTransformer() {
         return transformer;
     }
 
@@ -128,7 +128,7 @@
      * 
      * @param transformer  the transformer to use
      */
-    public void setTransformer(Transformer transformer) {
+    public void setTransformer(Transformer<? super I, ? extends O> transformer) {
         this.transformer = transformer;
     }
 
@@ -140,10 +140,7 @@
      * @param source  the object to transform
      * @return the transformed object
      */
-    protected Object transform(Object source) {
-        if (transformer != null) {
-            return transformer.transform(source);
-        }
-        return source;
+    protected O transform(I source) {
+        return transformer.transform(source);
     }
 }

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/UniqueFilterIterator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/UniqueFilterIterator.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/UniqueFilterIterator.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/UniqueFilterIterator.java Tue Sep 15 05:29:56 2009
@@ -20,7 +20,7 @@
 
 import org.apache.commons.collections.functors.UniquePredicate;
 
-/** 
+/**
  * A FilterIterator which only returns "unique" Objects.  Internally,
  * the Iterator maintains a Set of objects it has already encountered,
  * and duplicate Objects are skipped.
@@ -30,16 +30,16 @@
  *
  * @author Morgan Delagrange
  */
-public class UniqueFilterIterator extends FilterIterator {
-       
+public class UniqueFilterIterator<E> extends FilterIterator<E> {
+
     //-------------------------------------------------------------------------
-    
+
     /**
      *  Constructs a new <code>UniqueFilterIterator</code>.
      *
      *  @param iterator  the iterator to use
      */
-    public UniqueFilterIterator( Iterator iterator ) {
+    public UniqueFilterIterator(Iterator<E> iterator) {
         super(iterator, UniquePredicate.getInstance());
     }
 

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/UnmodifiableIterator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/UnmodifiableIterator.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/UnmodifiableIterator.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/UnmodifiableIterator.java Tue Sep 15 05:29:56 2009
@@ -30,10 +30,10 @@
  *
  * @author Stephen Colebourne
  */
-public final class UnmodifiableIterator implements Iterator, Unmodifiable {
+public final class UnmodifiableIterator<E> implements Iterator<E>, Unmodifiable {
 
     /** The iterator being decorated */
-    private Iterator iterator;
+    private Iterator<E> iterator;
 
     //-----------------------------------------------------------------------
     /**
@@ -44,23 +44,23 @@
      * @param iterator  the iterator to decorate
      * @throws IllegalArgumentException if the iterator is null
      */
-    public static Iterator decorate(Iterator iterator) {
+    public static <E> Iterator<E> decorate(Iterator<E> iterator) {
         if (iterator == null) {
             throw new IllegalArgumentException("Iterator must not be null");
         }
         if (iterator instanceof Unmodifiable) {
             return iterator;
         }
-        return new UnmodifiableIterator(iterator);
+        return new UnmodifiableIterator<E>(iterator);
     }
-    
+
     //-----------------------------------------------------------------------
     /**
      * Constructor.
      *
      * @param iterator  the iterator to decorate
      */
-    private UnmodifiableIterator(Iterator iterator) {
+    private UnmodifiableIterator(Iterator<E> iterator) {
         super();
         this.iterator = iterator;
     }
@@ -70,7 +70,7 @@
         return iterator.hasNext();
     }
 
-    public Object next() {
+    public E next() {
         return iterator.next();
     }
 

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/UnmodifiableListIterator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/UnmodifiableListIterator.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/UnmodifiableListIterator.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/UnmodifiableListIterator.java Tue Sep 15 05:29:56 2009
@@ -30,10 +30,10 @@
  *
  * @author Stephen Colebourne
  */
-public final class UnmodifiableListIterator implements ListIterator, Unmodifiable {
+public final class UnmodifiableListIterator<E> implements ListIterator<E>, Unmodifiable {
 
     /** The iterator being decorated */
-    private ListIterator iterator;
+    private ListIterator<E> iterator;
 
     //-----------------------------------------------------------------------
     /**
@@ -42,14 +42,14 @@
      * @param iterator  the iterator to decorate
      * @throws IllegalArgumentException if the iterator is null
      */
-    public static ListIterator decorate(ListIterator iterator) {
+    public static <E> ListIterator<E> decorate(ListIterator<E> iterator) {
         if (iterator == null) {
             throw new IllegalArgumentException("ListIterator must not be null");
         }
         if (iterator instanceof Unmodifiable) {
             return iterator;
         }
-        return new UnmodifiableListIterator(iterator);
+        return new UnmodifiableListIterator<E>(iterator);
     }
     
     //-----------------------------------------------------------------------
@@ -58,7 +58,7 @@
      *
      * @param iterator  the iterator to decorate
      */
-    private UnmodifiableListIterator(ListIterator iterator) {
+    private UnmodifiableListIterator(ListIterator<E> iterator) {
         super();
         this.iterator = iterator;
     }
@@ -68,7 +68,7 @@
         return iterator.hasNext();
     }
 
-    public Object next() {
+    public E next() {
         return iterator.next();
     }
 
@@ -80,7 +80,7 @@
         return iterator.hasPrevious();
     }
 
-    public Object previous() {
+    public E previous() {
         return iterator.previous();
     }
 
@@ -92,11 +92,11 @@
         throw new UnsupportedOperationException("remove() is not supported");
     }
 
-    public void set(Object obj) {
+    public void set(E obj) {
         throw new UnsupportedOperationException("set() is not supported");
     }
 
-    public void add(Object obj) {
+    public void add(E obj) {
         throw new UnsupportedOperationException("add() is not supported");
     }
 

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/UnmodifiableMapIterator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/UnmodifiableMapIterator.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/UnmodifiableMapIterator.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/UnmodifiableMapIterator.java Tue Sep 15 05:29:56 2009
@@ -29,10 +29,10 @@
  *
  * @author Stephen Colebourne
  */
-public final class UnmodifiableMapIterator implements MapIterator, Unmodifiable {
+public final class UnmodifiableMapIterator<K, V> implements MapIterator<K, V>, Unmodifiable {
 
     /** The iterator being decorated */
-    private MapIterator iterator;
+    private MapIterator<K, V> iterator;
 
     //-----------------------------------------------------------------------
     /**
@@ -41,23 +41,23 @@
      * @param iterator  the iterator to decorate
      * @throws IllegalArgumentException if the iterator is null
      */
-    public static MapIterator decorate(MapIterator iterator) {
+    public static <K, V> MapIterator<K, V> decorate(MapIterator<K, V> iterator) {
         if (iterator == null) {
             throw new IllegalArgumentException("MapIterator must not be null");
         }
         if (iterator instanceof Unmodifiable) {
             return iterator;
         }
-        return new UnmodifiableMapIterator(iterator);
+        return new UnmodifiableMapIterator<K, V>(iterator);
     }
-    
+
     //-----------------------------------------------------------------------
     /**
      * Constructor.
      *
      * @param iterator  the iterator to decorate
      */
-    private UnmodifiableMapIterator(MapIterator iterator) {
+    private UnmodifiableMapIterator(MapIterator<K, V> iterator) {
         super();
         this.iterator = iterator;
     }
@@ -67,19 +67,19 @@
         return iterator.hasNext();
     }
 
-    public Object next() {
+    public K next() {
         return iterator.next();
     }
 
-    public Object getKey() {
+    public K getKey() {
         return iterator.getKey();
     }
 
-    public Object getValue() {
+    public V getValue() {
         return iterator.getValue();
     }
 
-    public Object setValue(Object value) {
+    public V setValue(V value) {
         throw new UnsupportedOperationException("setValue() is not supported");
     }
 

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/UnmodifiableOrderedMapIterator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/UnmodifiableOrderedMapIterator.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/UnmodifiableOrderedMapIterator.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/UnmodifiableOrderedMapIterator.java Tue Sep 15 05:29:56 2009
@@ -19,7 +19,7 @@
 import org.apache.commons.collections.OrderedMapIterator;
 import org.apache.commons.collections.Unmodifiable;
 
-/** 
+/**
  * Decorates an ordered map iterator such that it cannot be modified.
  * <p>
  * Attempts to modify it will result in an UnsupportedOperationException. 
@@ -29,10 +29,11 @@
  *
  * @author Stephen Colebourne
  */
-public final class UnmodifiableOrderedMapIterator implements OrderedMapIterator, Unmodifiable {
+public final class UnmodifiableOrderedMapIterator<K, V> implements OrderedMapIterator<K, V>,
+        Unmodifiable {
 
     /** The iterator being decorated */
-    private OrderedMapIterator iterator;
+    private OrderedMapIterator<K, V> iterator;
 
     //-----------------------------------------------------------------------
     /**
@@ -41,23 +42,23 @@
      * @param iterator  the iterator to decorate
      * @throws IllegalArgumentException if the iterator is null
      */
-    public static OrderedMapIterator decorate(OrderedMapIterator iterator) {
+    public static <K, V> OrderedMapIterator<K, V> decorate(OrderedMapIterator<K, V> iterator) {
         if (iterator == null) {
             throw new IllegalArgumentException("OrderedMapIterator must not be null");
         }
         if (iterator instanceof Unmodifiable) {
             return iterator;
         }
-        return new UnmodifiableOrderedMapIterator(iterator);
+        return new UnmodifiableOrderedMapIterator<K, V>(iterator);
     }
-    
+
     //-----------------------------------------------------------------------
     /**
      * Constructor.
      *
      * @param iterator  the iterator to decorate
      */
-    private UnmodifiableOrderedMapIterator(OrderedMapIterator iterator) {
+    private UnmodifiableOrderedMapIterator(OrderedMapIterator<K, V> iterator) {
         super();
         this.iterator = iterator;
     }
@@ -67,7 +68,7 @@
         return iterator.hasNext();
     }
 
-    public Object next() {
+    public K next() {
         return iterator.next();
     }
 
@@ -75,19 +76,19 @@
         return iterator.hasPrevious();
     }
 
-    public Object previous() {
+    public K previous() {
         return iterator.previous();
     }
 
-    public Object getKey() {
+    public K getKey() {
         return iterator.getKey();
     }
 
-    public Object getValue() {
+    public V getValue() {
         return iterator.getValue();
     }
 
-    public Object setValue(Object value) {
+    public V setValue(V value) {
         throw new UnsupportedOperationException("setValue() is not supported");
     }
 

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/keyvalue/AbstractKeyValue.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/keyvalue/AbstractKeyValue.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/keyvalue/AbstractKeyValue.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/keyvalue/AbstractKeyValue.java Tue Sep 15 05:29:56 2009
@@ -30,12 +30,12 @@
  * @author Neil O'Toole
  * @author Stephen Colebourne
  */
-public abstract class AbstractKeyValue implements KeyValue {
+public abstract class AbstractKeyValue<K, V> implements KeyValue<K, V> {
 
     /** The key */
-    protected Object key;
+    protected K key;
     /** The value */
-    protected Object value;
+    protected V value;
 
     /**
      * Constructs a new pair with the specified key and given value.
@@ -43,7 +43,7 @@
      * @param key  the key for the entry, may be null
      * @param value  the value for the entry, may be null
      */
-    protected AbstractKeyValue(Object key, Object value) {
+    protected AbstractKeyValue(K key, V value) {
         super();
         this.key = key;
         this.value = value;
@@ -54,7 +54,7 @@
      *
      * @return the key 
      */
-    public Object getKey() {
+    public K getKey() {
         return key;
     }
 
@@ -63,7 +63,7 @@
      *
      * @return the value
      */
-    public Object getValue() {
+    public V getValue() {
         return value;
     }
 

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/keyvalue/AbstractMapEntry.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/keyvalue/AbstractMapEntry.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/keyvalue/AbstractMapEntry.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/keyvalue/AbstractMapEntry.java Tue Sep 15 05:29:56 2009
@@ -30,7 +30,7 @@
  * @author Neil O'Toole
  * @author Stephen Colebourne
  */
-public abstract class AbstractMapEntry extends AbstractKeyValue implements Map.Entry {
+public abstract class AbstractMapEntry<K, V> extends AbstractKeyValue<K, V> implements Map.Entry<K, V> {
 
     /**
      * Constructs a new entry with the given key and given value.
@@ -38,7 +38,7 @@
      * @param key  the key for the entry, may be null
      * @param value  the value for the entry, may be null
      */
-    protected AbstractMapEntry(Object key, Object value) {
+    protected AbstractMapEntry(K key, V value) {
         super(key, value);
     }
 
@@ -53,8 +53,8 @@
      * @param value  the new value
      * @return the previous value
      */
-    public Object setValue(Object value) {
-        Object answer = this.value;
+    public V setValue(V value) {
+        V answer = this.value;
         this.value = value;
         return answer;
     }
@@ -67,6 +67,7 @@
      * @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;

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/keyvalue/AbstractMapEntryDecorator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/keyvalue/AbstractMapEntryDecorator.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/keyvalue/AbstractMapEntryDecorator.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/keyvalue/AbstractMapEntryDecorator.java Tue Sep 15 05:29:56 2009
@@ -29,10 +29,10 @@
  *
  * @author Stephen Colebourne
  */
-public abstract class AbstractMapEntryDecorator implements Map.Entry, KeyValue {
+public abstract class AbstractMapEntryDecorator<K, V> implements Map.Entry<K, V>, KeyValue<K, V> {
     
     /** The <code>Map.Entry</code> to decorate */
-    protected final Map.Entry entry;
+    protected final Map.Entry<K, V> entry;
 
     /**
      * Constructor that wraps (not copies).
@@ -40,7 +40,7 @@
      * @param entry  the <code>Map.Entry</code> to decorate, must not be null
      * @throws IllegalArgumentException if the collection is null
      */
-    public AbstractMapEntryDecorator(Map.Entry entry) {
+    public AbstractMapEntryDecorator(Map.Entry<K, V> entry) {
         if (entry == null) {
             throw new IllegalArgumentException("Map Entry must not be null");
         }
@@ -52,20 +52,20 @@
      * 
      * @return the decorated map
      */
-    protected Map.Entry getMapEntry() {
+    protected Map.Entry<K, V> getMapEntry() {
         return entry;
     }
 
     //-----------------------------------------------------------------------
-    public Object getKey() {
+    public K getKey() {
         return entry.getKey();
     }
 
-    public Object getValue() {
+    public V getValue() {
         return entry.getValue();
     }
 
-    public Object setValue(Object object) {
+    public V setValue(V object) {
         return entry.setValue(object);
     }
    

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/keyvalue/DefaultKeyValue.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/keyvalue/DefaultKeyValue.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/keyvalue/DefaultKeyValue.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/keyvalue/DefaultKeyValue.java Tue Sep 15 05:29:56 2009
@@ -35,7 +35,7 @@
  * @author Neil O'Toole
  * @author Stephen Colebourne
  */
-public class DefaultKeyValue extends AbstractKeyValue {
+public class DefaultKeyValue<K, V> extends AbstractKeyValue<K, V> {
 
     /**
      * Constructs a new pair with a null key and null value.
@@ -50,7 +50,7 @@
      * @param key  the key for the entry, may be null
      * @param value  the value for the entry, may be null
      */
-    public DefaultKeyValue(final Object key, final Object value) {
+    public DefaultKeyValue(final K key, final V value) {
         super(key, value);
     }
 
@@ -60,7 +60,7 @@
      * @param pair  the pair to copy, must not be null
      * @throws NullPointerException if the entry is null
      */
-    public DefaultKeyValue(final KeyValue pair) {
+    public DefaultKeyValue(final KeyValue<K, V> pair) {
         super(pair.getKey(), pair.getValue());
     }
 
@@ -70,7 +70,7 @@
      * @param entry  the entry to copy, must not be null
      * @throws NullPointerException if the entry is null
      */
-    public DefaultKeyValue(final Map.Entry entry) {
+    public DefaultKeyValue(final Map.Entry<K, V> entry) {
         super(entry.getKey(), entry.getValue());
     }
 
@@ -82,12 +82,12 @@
      * @return the old key
      * @throws IllegalArgumentException if key is this object
      */
-    public Object setKey(final Object key) {
+    public K setKey(final K key) {
         if (key == this) {
             throw new IllegalArgumentException("DefaultKeyValue may not contain itself as a key.");
         }
 
-        final Object old = this.key;
+        final K old = this.key;
         this.key = key;
         return old;
     }
@@ -99,12 +99,12 @@
      * @param value the new value
      * @throws IllegalArgumentException if value is this object
      */
-    public Object setValue(final Object value) {
+    public V setValue(final V value) {
         if (value == this) {
             throw new IllegalArgumentException("DefaultKeyValue may not contain itself as a value.");
         }
 
-        final Object old = this.value;
+        final V old = this.value;
         this.value = value;
         return old;
     }
@@ -115,8 +115,8 @@
      * 
      * @return a MapEntry instance
      */
-    public Map.Entry toMapEntry() {
-        return new DefaultMapEntry(this);
+    public Map.Entry<K, V> toMapEntry() {
+        return new DefaultMapEntry<K, V>(this);
     }
 
     //-----------------------------------------------------------------------
@@ -129,6 +129,7 @@
      * @param obj  the object to compare to
      * @return true if equal key and value
      */
+    @SuppressWarnings("unchecked")
     public boolean equals(final Object obj) {
         if (obj == this) {
             return true;

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/keyvalue/DefaultMapEntry.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/keyvalue/DefaultMapEntry.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/keyvalue/DefaultMapEntry.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/keyvalue/DefaultMapEntry.java Tue Sep 15 05:29:56 2009
@@ -32,7 +32,7 @@
  * @author Neil O'Toole
  * @author Stephen Colebourne
  */
-public final class DefaultMapEntry extends AbstractMapEntry {
+public final class DefaultMapEntry<K, V> extends AbstractMapEntry<K, V> {
 
     /**
      * Constructs a new entry with the specified key and given value.
@@ -40,7 +40,7 @@
      * @param key  the key for the entry, may be null
      * @param value  the value for the entry, may be null
      */
-    public DefaultMapEntry(final Object key, final Object value) {
+    public DefaultMapEntry(final K key, final V value) {
         super(key, value);
     }
 
@@ -50,7 +50,7 @@
      * @param pair  the pair to copy, must not be null
      * @throws NullPointerException if the entry is null
      */
-    public DefaultMapEntry(final KeyValue pair) {
+    public DefaultMapEntry(final KeyValue<K, V> pair) {
         super(pair.getKey(), pair.getValue());
     }
 
@@ -60,7 +60,7 @@
      * @param entry  the entry to copy, must not be null
      * @throws NullPointerException if the entry is null
      */
-    public DefaultMapEntry(final Map.Entry entry) {
+    public DefaultMapEntry(final Map.Entry<K, V> entry) {
         super(entry.getKey(), entry.getValue());
     }
 

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/keyvalue/MultiKey.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/keyvalue/MultiKey.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/keyvalue/MultiKey.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/keyvalue/MultiKey.java Tue Sep 15 05:29:56 2009
@@ -45,17 +45,17 @@
  * @author Howard Lewis Ship
  * @author Stephen Colebourne
  */
-public class MultiKey implements Serializable {
+public class MultiKey<K> implements Serializable {
     // This class could implement List, but that would confuse it's purpose
 
     /** Serialisation version */
     private static final long serialVersionUID = 4465448607415788805L;
 
     /** The individual keys */
-    private final Object[] keys;
+    private final K[] keys;
     /** The cached hashCode */
     private transient int hashCode;
-    
+
     /**
      * Constructor taking two keys.
      * <p>
@@ -65,10 +65,11 @@
      * @param key1  the first key
      * @param key2  the second key
      */
-    public MultiKey(Object key1, Object key2) {
-        this(new Object[] {key1, key2}, false);
+    @SuppressWarnings("unchecked")
+    public MultiKey(K key1, K key2) {
+        this((K[]) new Object[] { key1, key2 }, false);
     }
-    
+
     /**
      * Constructor taking three keys.
      * <p>
@@ -79,10 +80,11 @@
      * @param key2  the second key
      * @param key3  the third key
      */
-    public MultiKey(Object key1, Object key2, Object key3) {
-        this(new Object[] {key1, key2, key3}, false);
+    @SuppressWarnings("unchecked")
+    public MultiKey(K key1, K key2, K key3) {
+        this((K[]) new Object[] {key1, key2, key3}, false);
     }
-    
+
     /**
      * Constructor taking four keys.
      * <p>
@@ -94,10 +96,11 @@
      * @param key3  the third key
      * @param key4  the fourth key
      */
-    public MultiKey(Object key1, Object key2, Object key3, Object key4) {
-        this(new Object[] {key1, key2, key3, key4}, false);
+    @SuppressWarnings("unchecked")
+    public MultiKey(K key1, K key2, K key3, K key4) {
+        this((K[]) new Object[] {key1, key2, key3, key4}, false);
     }
-    
+
     /**
      * Constructor taking five keys.
      * <p>
@@ -110,10 +113,11 @@
      * @param key4  the fourth key
      * @param key5  the fifth key
      */
-    public MultiKey(Object key1, Object key2, Object key3, Object key4, Object key5) {
-        this(new Object[] {key1, key2, key3, key4, key5}, false);
+    @SuppressWarnings("unchecked")
+    public MultiKey(K key1, K key2, K key3, K key4, K key5) {
+        this((K[]) new Object[] {key1, key2, key3, key4, key5}, false);
     }
-    
+
     /**
      * Constructor taking an array of keys which is cloned.
      * <p>
@@ -125,10 +129,10 @@
      * @param keys  the array of keys, not null
      * @throws IllegalArgumentException if the key array is null
      */
-    public MultiKey(Object[] keys) {
+    public MultiKey(K[] keys) {
         this(keys, true);
     }
-    
+
     /**
      * Constructor taking an array of keys, optionally choosing whether to clone.
      * <p>
@@ -153,20 +157,20 @@
      * @throws IllegalArgumentException if the key array is null
      * @since Commons Collections 3.1
      */
-    public MultiKey(Object[] keys, boolean makeClone) {
+    public MultiKey(K[] keys, boolean makeClone) {
         super();
         if (keys == null) {
             throw new IllegalArgumentException("The array of keys must not be null");
         }
         if (makeClone) {
-            this.keys = (Object[]) keys.clone();
+            this.keys = keys.clone();
         } else {
             this.keys = keys;
         }
-        
+
         calculateHashCode(keys);
     }
-    
+
     //-----------------------------------------------------------------------
     /**
      * Gets a clone of the array of keys.
@@ -176,10 +180,10 @@
      * 
      * @return the individual keys
      */
-    public Object[] getKeys() {
-        return (Object[]) keys.clone();
+    public K[] getKeys() {
+        return keys.clone();
     }
-    
+
     /**
      * Gets the key at the specified index.
      * <p>
@@ -191,10 +195,10 @@
      * @throws IndexOutOfBoundsException if the index is invalid
      * @since Commons Collections 3.1
      */
-    public Object getKey(int index) {
+    public K getKey(int index) {
         return keys[index];
     }
-    
+
     /**
      * Gets the size of the list of keys.
      * 
@@ -204,7 +208,7 @@
     public int size() {
         return keys.length;
     }
-    
+
     //-----------------------------------------------------------------------
     /**
      * Compares this object to another.
@@ -220,7 +224,7 @@
             return true;
         }
         if (other instanceof MultiKey) {
-            MultiKey otherMulti = (MultiKey) other;
+            MultiKey<?> otherMulti = (MultiKey<?>) other;
             return Arrays.equals(keys, otherMulti.keys);
         }
         return false;

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/keyvalue/TiedMapEntry.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/keyvalue/TiedMapEntry.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/keyvalue/TiedMapEntry.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/keyvalue/TiedMapEntry.java Tue Sep 15 05:29:56 2009
@@ -32,15 +32,16 @@
  *
  * @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 @@
      * @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 @@
      * 
      * @return the key
      */
-    public Object getKey() {
+    public K getKey() {
         return key;
     }
 
@@ -70,7 +71,7 @@
      * 
      * @return the value
      */
-    public Object getValue() {
+    public V getValue() {
         return map.get(key);
     }
 
@@ -81,7 +82,7 @@
      * @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 @@
      * @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;

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/keyvalue/UnmodifiableMapEntry.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/keyvalue/UnmodifiableMapEntry.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/keyvalue/UnmodifiableMapEntry.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/keyvalue/UnmodifiableMapEntry.java Tue Sep 15 05:29:56 2009
@@ -30,7 +30,7 @@
  *
  * @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 @@
      * @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 @@
      * @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 @@
      * @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 @@
      * @return the previous value
      * @throws UnsupportedOperationException always
      */
-    public Object setValue(Object value) {
+    public V setValue(V value) {
         throw new UnsupportedOperationException("setValue() is not supported");
     }