commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r738956 [17/34] - in /commons/proper/collections/branches/collections_jdk5_branch/src: java/org/apache/commons/collections/ java/org/apache/commons/collections/bag/ java/org/apache/commons/collections/bidimap/ java/org/apache/commons/collec...
Date Thu, 29 Jan 2009 18:48:47 GMT
Modified: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/TransformedSortedMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/TransformedSortedMap.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/TransformedSortedMap.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/TransformedSortedMap.java Thu Jan 29 18:48:37 2009
@@ -43,9 +43,9 @@
  * 
  * @author Stephen Colebourne
  */
-public class TransformedSortedMap
-        extends TransformedMap
-        implements SortedMap {
+public class TransformedSortedMap<K, V>
+        extends TransformedMap<K, V>
+        implements SortedMap<K, V> {
 
     /** Serialization version */
     private static final long serialVersionUID = -8751771676410385778L;
@@ -62,8 +62,10 @@
      * @param valueTransformer  the predicate to validate to values, null means no transformation
      * @throws IllegalArgumentException if the map is null
      */
-    public static SortedMap decorate(SortedMap map, Transformer keyTransformer, Transformer valueTransformer) {
-        return new TransformedSortedMap(map, keyTransformer, valueTransformer);
+    public static <K, V> SortedMap<K, V> decorate(SortedMap<K, V> map,
+            Transformer<? super K, ? extends K> keyTransformer,
+            Transformer<? super V, ? extends V> valueTransformer) {
+        return new TransformedSortedMap<K, V>(map, keyTransformer, valueTransformer);
     }
 
     /**
@@ -80,10 +82,12 @@
      * @throws IllegalArgumentException if map is null
      * @since Commons Collections 3.2
      */
-    public static SortedMap decorateTransform(SortedMap map, Transformer keyTransformer, Transformer valueTransformer) {
-        TransformedSortedMap decorated = new TransformedSortedMap(map, keyTransformer, valueTransformer);
+    public static <K, V> SortedMap<K, V> decorateTransform(SortedMap<K, V> map,
+            Transformer<? super K, ? extends K> keyTransformer,
+            Transformer<? super V, ? extends V> valueTransformer) {
+        TransformedSortedMap<K, V> decorated = new TransformedSortedMap<K, V>(map, keyTransformer, valueTransformer);
         if (map.size() > 0) {
-            Map transformed = decorated.transformMap(map);
+            Map<K, V> transformed = decorated.transformMap(map);
             decorated.clear();
             decorated.decorated().putAll(transformed);  // avoids double transformation
         }
@@ -102,7 +106,9 @@
      * @param valueTransformer  the predicate to validate to values, null means no transformation
      * @throws IllegalArgumentException if the map is null
      */
-    protected TransformedSortedMap(SortedMap map, Transformer keyTransformer, Transformer valueTransformer) {
+    protected TransformedSortedMap(SortedMap<K, V> map,
+            Transformer<? super K, ? extends K> keyTransformer,
+            Transformer<? super V, ? extends V> valueTransformer) {
         super(map, keyTransformer, valueTransformer);
     }
 
@@ -112,36 +118,36 @@
      * 
      * @return the decorated map
      */
-    protected SortedMap getSortedMap() {
-        return (SortedMap) map;
+    protected SortedMap<K, V> getSortedMap() {
+        return (SortedMap<K, V>) map;
     }
 
     //-----------------------------------------------------------------------
-    public Object firstKey() {
+    public K firstKey() {
         return getSortedMap().firstKey();
     }
 
-    public Object lastKey() {
+    public K lastKey() {
         return getSortedMap().lastKey();
     }
 
-    public Comparator comparator() {
+    public Comparator<? super K> comparator() {
         return getSortedMap().comparator();
     }
 
-    public SortedMap subMap(Object fromKey, Object toKey) {
-        SortedMap map = getSortedMap().subMap(fromKey, toKey);
-        return new TransformedSortedMap(map, keyTransformer, valueTransformer);
+    public SortedMap<K, V> subMap(K fromKey, K toKey) {
+        SortedMap<K, V> map = getSortedMap().subMap(fromKey, toKey);
+        return new TransformedSortedMap<K, V>(map, keyTransformer, valueTransformer);
     }
 
-    public SortedMap headMap(Object toKey) {
-        SortedMap map = getSortedMap().headMap(toKey);
-        return new TransformedSortedMap(map, keyTransformer, valueTransformer);
+    public SortedMap<K, V> headMap(K toKey) {
+        SortedMap<K, V> map = getSortedMap().headMap(toKey);
+        return new TransformedSortedMap<K, V>(map, keyTransformer, valueTransformer);
     }
 
-    public SortedMap tailMap(Object fromKey) {
-        SortedMap map = getSortedMap().tailMap(fromKey);
-        return new TransformedSortedMap(map, keyTransformer, valueTransformer);
+    public SortedMap<K, V> tailMap(K fromKey) {
+        SortedMap<K, V> map = getSortedMap().tailMap(fromKey);
+        return new TransformedSortedMap<K, V>(map, keyTransformer, valueTransformer);
     }
 
 }

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/UnmodifiableEntrySet.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/UnmodifiableEntrySet.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/UnmodifiableEntrySet.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/UnmodifiableEntrySet.java Thu Jan 29 18:48:37 2009
@@ -35,8 +35,11 @@
  * 
  * @author Stephen Colebourne
  */
-public final class UnmodifiableEntrySet
-        extends AbstractSetDecorator implements Unmodifiable {
+public final class UnmodifiableEntrySet<K, V>
+        extends AbstractSetDecorator<Map.Entry<K, V>> implements Unmodifiable {
+
+    /** Serialization version */
+    private static final long serialVersionUID = 1678353579659253473L;
 
     /**
      * Factory method to create an unmodifiable set of Map Entry objects.
@@ -44,11 +47,11 @@
      * @param set  the set to decorate, must not be null
      * @throws IllegalArgumentException if set is null
      */
-    public static Set decorate(Set set) {
+    public static <K, V> Set<Map.Entry<K, V>> decorate(Set<Map.Entry<K, V>> set) {
         if (set instanceof Unmodifiable) {
             return set;
         }
-        return new UnmodifiableEntrySet(set);
+        return new UnmodifiableEntrySet<K, V>(set);
     }
 
     //-----------------------------------------------------------------------
@@ -58,16 +61,16 @@
      * @param set  the set to decorate, must not be null
      * @throws IllegalArgumentException if set is null
      */
-    private UnmodifiableEntrySet(Set set) {
+    private UnmodifiableEntrySet(Set<Map.Entry<K, V>> set) {
         super(set);
     }
 
     //-----------------------------------------------------------------------
-    public boolean add(Object object) {
+    public boolean add(Map.Entry<K, V> object) {
         throw new UnsupportedOperationException();
     }
 
-    public boolean addAll(Collection coll) {
+    public boolean addAll(Collection<? extends Map.Entry<K, V>> coll) {
         throw new UnsupportedOperationException();
     }
 
@@ -79,28 +82,30 @@
         throw new UnsupportedOperationException();
     }
 
-    public boolean removeAll(Collection coll) {
+    public boolean removeAll(Collection<?> coll) {
         throw new UnsupportedOperationException();
     }
 
-    public boolean retainAll(Collection coll) {
+    public boolean retainAll(Collection<?> coll) {
         throw new UnsupportedOperationException();
     }
 
     //-----------------------------------------------------------------------
-    public Iterator iterator() {
+    public Iterator<Map.Entry<K, V>> iterator() {
         return new UnmodifiableEntrySetIterator(collection.iterator());
     }
     
+    @SuppressWarnings("unchecked")
     public Object[] toArray() {
         Object[] array = collection.toArray();
         for (int i = 0; i < array.length; i++) {
-            array[i] = new UnmodifiableEntry((Map.Entry) array[i]);
+            array[i] = new UnmodifiableEntry((Map.Entry<K, V>) array[i]);
         }
         return array;
     }
     
-    public Object[] toArray(Object array[]) {
+    @SuppressWarnings("unchecked")
+    public <T> T[] toArray(T[] array) {
         Object[] result = array;
         if (array.length > 0) {
             // we must create a new array to handle multi-threaded situations
@@ -109,15 +114,15 @@
         }
         result = collection.toArray(result);
         for (int i = 0; i < result.length; i++) {
-            result[i] = new UnmodifiableEntry((Map.Entry) result[i]);
+            result[i] = new UnmodifiableEntry((Map.Entry<K, V>) result[i]);
         }
 
         // check to see if result should be returned straight
         if (result.length > array.length) {
-            return result;
+            return (T[]) result;
         }
 
-        // copy back into input array to fulfil the method contract
+        // copy back into input array to fulfill the method contract
         System.arraycopy(result, 0, array, 0, result.length);
         if (array.length > result.length) {
             array[result.length] = null;
@@ -129,17 +134,16 @@
     /**
      * Implementation of an entry set iterator.
      */
-    final static class UnmodifiableEntrySetIterator extends AbstractIteratorDecorator {
-        
-        protected UnmodifiableEntrySetIterator(Iterator iterator) {
+    private class UnmodifiableEntrySetIterator extends AbstractIteratorDecorator<Map.Entry<K, V>> {
+
+        protected UnmodifiableEntrySetIterator(Iterator<Map.Entry<K, V>> iterator) {
             super(iterator);
         }
-        
-        public Object next() {
-            Map.Entry entry = (Map.Entry) iterator.next();
-            return new UnmodifiableEntry(entry);
+
+        public Map.Entry<K, V> next() {
+            return new UnmodifiableEntry(iterator.next());
         }
-        
+
         public void remove() {
             throw new UnsupportedOperationException();
         }
@@ -149,13 +153,13 @@
     /**
      * Implementation of a map entry that is unmodifiable.
      */
-    final static class UnmodifiableEntry extends AbstractMapEntryDecorator {
+    private class UnmodifiableEntry extends AbstractMapEntryDecorator<K, V> {
 
-        protected UnmodifiableEntry(Map.Entry entry) {
+        protected UnmodifiableEntry(Map.Entry<K, V> entry) {
             super(entry);
         }
 
-        public Object setValue(Object obj) {
+        public V setValue(V obj) {
             throw new UnsupportedOperationException();
         }
     }

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/UnmodifiableMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/UnmodifiableMap.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/UnmodifiableMap.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/UnmodifiableMap.java Thu Jan 29 18:48:37 2009
@@ -42,9 +42,9 @@
  * 
  * @author Stephen Colebourne
  */
-public final class UnmodifiableMap
-        extends AbstractMapDecorator
-        implements IterableMap, Unmodifiable, Serializable {
+public final class UnmodifiableMap<K, V>
+        extends AbstractMapDecorator<K, V>
+        implements IterableMap<K, V>, Unmodifiable, Serializable {
 
     /** Serialization version */
     private static final long serialVersionUID = 2737023427269031941L;
@@ -55,11 +55,11 @@
      * @param map  the map to decorate, must not be null
      * @throws IllegalArgumentException if map is null
      */
-    public static Map decorate(Map map) {
+    public static <K, V> Map<K, V> decorate(Map<K, V> map) {
         if (map instanceof Unmodifiable) {
             return map;
         }
-        return new UnmodifiableMap(map);
+        return new UnmodifiableMap<K, V>(map);
     }
 
     //-----------------------------------------------------------------------
@@ -69,7 +69,7 @@
      * @param map  the map to decorate, must not be null
      * @throws IllegalArgumentException if map is null
      */
-    private UnmodifiableMap(Map map) {
+    private UnmodifiableMap(Map<K, V> map) {
         super(map);
     }
 
@@ -94,9 +94,10 @@
      * @throws ClassNotFoundException
      * @since Commons Collections 3.1
      */
+    @SuppressWarnings("unchecked")
     private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
         in.defaultReadObject();
-        map = (Map) in.readObject();
+        map = (Map<K, V>) in.readObject();
     }
 
     //-----------------------------------------------------------------------
@@ -104,40 +105,39 @@
         throw new UnsupportedOperationException();
     }
 
-    public Object put(Object key, Object value) {
+    public V put(K key, V value) {
         throw new UnsupportedOperationException();
     }
 
-    public void putAll(Map mapToCopy) {
+    public void putAll(Map<? extends K, ? extends V> mapToCopy) {
         throw new UnsupportedOperationException();
     }
 
-    public Object remove(Object key) {
+    public V remove(Object key) {
         throw new UnsupportedOperationException();
     }
 
-    public MapIterator mapIterator() {
+    public MapIterator<K, V> mapIterator() {
         if (map instanceof IterableMap) {
-            MapIterator it = ((IterableMap) map).mapIterator();
-            return UnmodifiableMapIterator.decorate(it);
-        } else {
-            MapIterator it = new EntrySetMapIterator(map);
+            MapIterator<K, V> it = ((IterableMap<K, V>) map).mapIterator();
             return UnmodifiableMapIterator.decorate(it);
         }
+        MapIterator<K, V> it = new EntrySetMapIterator<K, V>(map);
+        return UnmodifiableMapIterator.decorate(it);
     }
 
-    public Set entrySet() {
-        Set set = super.entrySet();
+    public Set<Map.Entry<K, V>> entrySet() {
+        Set<Map.Entry<K, V>> set = super.entrySet();
         return UnmodifiableEntrySet.decorate(set);
     }
 
-    public Set keySet() {
-        Set set = super.keySet();
+    public Set<K> keySet() {
+        Set<K> set = super.keySet();
         return UnmodifiableSet.decorate(set);
     }
 
-    public Collection values() {
-        Collection coll = super.values();
+    public Collection<V> values() {
+        Collection<V> coll = super.values();
         return UnmodifiableCollection.decorate(coll);
     }
 

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/UnmodifiableOrderedMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/UnmodifiableOrderedMap.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/UnmodifiableOrderedMap.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/UnmodifiableOrderedMap.java Thu Jan 29 18:48:37 2009
@@ -24,12 +24,10 @@
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.commons.collections.MapIterator;
 import org.apache.commons.collections.OrderedMap;
 import org.apache.commons.collections.OrderedMapIterator;
 import org.apache.commons.collections.Unmodifiable;
 import org.apache.commons.collections.collection.UnmodifiableCollection;
-import org.apache.commons.collections.iterators.UnmodifiableMapIterator;
 import org.apache.commons.collections.iterators.UnmodifiableOrderedMapIterator;
 import org.apache.commons.collections.set.UnmodifiableSet;
 
@@ -43,9 +41,8 @@
  * 
  * @author Stephen Colebourne
  */
-public final class UnmodifiableOrderedMap
-        extends AbstractOrderedMapDecorator
-        implements Unmodifiable, Serializable {
+public final class UnmodifiableOrderedMap<K, V> extends AbstractOrderedMapDecorator<K, V> implements
+        Unmodifiable, Serializable {
 
     /** Serialization version */
     private static final long serialVersionUID = 8136428161720526266L;
@@ -56,11 +53,11 @@
      * @param map  the map to decorate, must not be null
      * @throws IllegalArgumentException if map is null
      */
-    public static OrderedMap decorate(OrderedMap map) {
+    public static <K, V> OrderedMap<K, V> decorate(OrderedMap<K, V> map) {
         if (map instanceof Unmodifiable) {
             return map;
         }
-        return new UnmodifiableOrderedMap(map);
+        return new UnmodifiableOrderedMap<K, V>(map);
     }
 
     //-----------------------------------------------------------------------
@@ -70,7 +67,7 @@
      * @param map  the map to decorate, must not be null
      * @throws IllegalArgumentException if map is null
      */
-    private UnmodifiableOrderedMap(OrderedMap map) {
+    private UnmodifiableOrderedMap(OrderedMap<K, V> map) {
         super(map);
     }
 
@@ -95,19 +92,15 @@
      * @throws ClassNotFoundException
      * @since Commons Collections 3.1
      */
+    @SuppressWarnings("unchecked")
     private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
         in.defaultReadObject();
         map = (Map) in.readObject();
     }
 
     //-----------------------------------------------------------------------
-    public MapIterator mapIterator() {
-        MapIterator it = decorated().mapIterator();
-        return UnmodifiableMapIterator.decorate(it);
-    }
-
-    public OrderedMapIterator orderedMapIterator() {
-        OrderedMapIterator it = decorated().orderedMapIterator();
+    public OrderedMapIterator<K, V> mapIterator() {
+        OrderedMapIterator<K, V> it = decorated().mapIterator();
         return UnmodifiableOrderedMapIterator.decorate(it);
     }
 
@@ -115,30 +108,30 @@
         throw new UnsupportedOperationException();
     }
 
-    public Object put(Object key, Object value) {
+    public V put(K key, V value) {
         throw new UnsupportedOperationException();
     }
 
-    public void putAll(Map mapToCopy) {
+    public void putAll(Map<? extends K, ? extends V> mapToCopy) {
         throw new UnsupportedOperationException();
     }
 
-    public Object remove(Object key) {
+    public V remove(Object key) {
         throw new UnsupportedOperationException();
     }
 
-    public Set entrySet() {
-        Set set = super.entrySet();
+    public Set<Map.Entry<K, V>> entrySet() {
+        Set<Map.Entry<K, V>> set = super.entrySet();
         return UnmodifiableEntrySet.decorate(set);
     }
 
-    public Set keySet() {
-        Set set = super.keySet();
+    public Set<K> keySet() {
+        Set<K> set = super.keySet();
         return UnmodifiableSet.decorate(set);
     }
 
-    public Collection values() {
-        Collection coll = super.values();
+    public Collection<V> values() {
+        Collection<V> coll = super.values();
         return UnmodifiableCollection.decorate(coll);
     }
 

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/UnmodifiableSortedMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/UnmodifiableSortedMap.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/UnmodifiableSortedMap.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/UnmodifiableSortedMap.java Thu Jan 29 18:48:37 2009
@@ -40,8 +40,8 @@
  * 
  * @author Stephen Colebourne
  */
-public final class UnmodifiableSortedMap
-        extends AbstractSortedMapDecorator
+public final class UnmodifiableSortedMap<K, V>
+        extends AbstractSortedMapDecorator<K, V>
         implements Unmodifiable, Serializable {
 
     /** Serialization version */
@@ -53,11 +53,11 @@
      * @param map  the map to decorate, must not be null
      * @throws IllegalArgumentException if map is null
      */
-    public static SortedMap decorate(SortedMap map) {
+    public static <K, V> SortedMap<K, V> decorate(SortedMap<K, V> map) {
         if (map instanceof Unmodifiable) {
             return map;
         }
-        return new UnmodifiableSortedMap(map);
+        return new UnmodifiableSortedMap<K, V>(map);
     }
 
     //-----------------------------------------------------------------------
@@ -67,10 +67,10 @@
      * @param map  the map to decorate, must not be null
      * @throws IllegalArgumentException if map is null
      */
-    private UnmodifiableSortedMap(SortedMap map) {
+    private UnmodifiableSortedMap(SortedMap<K, V> map) {
         super(map);
     }
-
+    
     //-----------------------------------------------------------------------
     /**
      * Write the map out using a custom routine.
@@ -92,9 +92,10 @@
      * @throws ClassNotFoundException
      * @since Commons Collections 3.1
      */
+    @SuppressWarnings("unchecked")
     private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
         in.defaultReadObject();
-        map = (Map) in.readObject();
+        map = (Map<K, V>) in.readObject();
     }
 
     //-----------------------------------------------------------------------
@@ -102,59 +103,53 @@
         throw new UnsupportedOperationException();
     }
 
-    public Object put(Object key, Object value) {
+    public V put(K key, V value) {
         throw new UnsupportedOperationException();
     }
 
-    public void putAll(Map mapToCopy) {
+    public void putAll(Map<? extends K, ? extends V> mapToCopy) {
         throw new UnsupportedOperationException();
     }
 
-    public Object remove(Object key) {
+    public V remove(Object key) {
         throw new UnsupportedOperationException();
     }
 
-    public Set entrySet() {
-        Set set = super.entrySet();
-        return UnmodifiableEntrySet.decorate(set);
+    public Set<Map.Entry<K, V>> entrySet() {
+        return UnmodifiableEntrySet.decorate(super.entrySet());
     }
 
-    public Set keySet() {
-        Set set = super.keySet();
-        return UnmodifiableSet.decorate(set);
+    public Set<K> keySet() {
+        return UnmodifiableSet.decorate(super.keySet());
     }
 
-    public Collection values() {
-        Collection coll = super.values();
-        return UnmodifiableCollection.decorate(coll);
+    public Collection<V> values() {
+        return UnmodifiableCollection.decorate(super.values());
     }
 
     //-----------------------------------------------------------------------
-    public Object firstKey() {
+    public K firstKey() {
         return decorated().firstKey();
     }
 
-    public Object lastKey() {
+    public K lastKey() {
         return decorated().lastKey();
     }
 
-    public Comparator comparator() {
+    public Comparator<? super K> comparator() {
         return decorated().comparator();
     }
 
-    public SortedMap subMap(Object fromKey, Object toKey) {
-        SortedMap map = decorated().subMap(fromKey, toKey);
-        return new UnmodifiableSortedMap(map);
+    public SortedMap<K, V> subMap(K fromKey, K toKey) {
+        return new UnmodifiableSortedMap<K, V>(decorated().subMap(fromKey, toKey));
     }
 
-    public SortedMap headMap(Object toKey) {
-        SortedMap map = decorated().headMap(toKey);
-        return new UnmodifiableSortedMap(map);
+    public SortedMap<K, V> headMap(K toKey) {
+        return new UnmodifiableSortedMap<K, V>(decorated().headMap(toKey));
     }
 
-    public SortedMap tailMap(Object fromKey) {
-        SortedMap map = decorated().tailMap(fromKey);
-        return new UnmodifiableSortedMap(map);
+    public SortedMap<K, V> tailMap(K fromKey) {
+        return new UnmodifiableSortedMap<K, V>(decorated().tailMap(fromKey));
     }
 
 }

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/AbstractSerializableSetDecorator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/AbstractSerializableSetDecorator.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/AbstractSerializableSetDecorator.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/AbstractSerializableSetDecorator.java Thu Jan 29 18:48:37 2009
@@ -29,8 +29,8 @@
  * @author Stephen Colebourne
  * @since Commons Collections 3.1
  */
-public abstract class AbstractSerializableSetDecorator
-        extends AbstractSetDecorator
+public abstract class AbstractSerializableSetDecorator<E>
+        extends AbstractSetDecorator<E>
         implements Serializable {
 
     /** Serialization version */
@@ -39,7 +39,7 @@
     /**
      * Constructor.
      */
-    protected AbstractSerializableSetDecorator(Set set) {
+    protected AbstractSerializableSetDecorator(Set<E> set) {
         super(set);
     }
 
@@ -62,9 +62,10 @@
      * @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();
     }
 
 }

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/AbstractSetDecorator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/AbstractSetDecorator.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/AbstractSetDecorator.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/AbstractSetDecorator.java Thu Jan 29 18:48:37 2009
@@ -31,9 +31,11 @@
  * 
  * @author Stephen Colebourne
  */
-public abstract class AbstractSetDecorator<E>
-        extends AbstractCollectionDecorator<E>
-        implements Set<E> {
+public abstract class AbstractSetDecorator<E> extends AbstractCollectionDecorator<E> implements
+        Set<E> {
+
+    /** Serialization version */
+    private static final long serialVersionUID = -4678668309576958546L;
 
     /**
      * Constructor only used in deserialization, do not use otherwise.

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/AbstractSortedSetDecorator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/AbstractSortedSetDecorator.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/AbstractSortedSetDecorator.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/AbstractSortedSetDecorator.java Thu Jan 29 18:48:37 2009
@@ -35,6 +35,9 @@
         extends AbstractSetDecorator<E>
         implements SortedSet<E> {
 
+    /** Serialization version */
+    private static final long serialVersionUID = -3462240946294214398L;
+
     /**
      * Constructor only used in deserialization, do not use otherwise.
      * @since Commons Collections 3.1

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/CompositeSet.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/CompositeSet.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/CompositeSet.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/CompositeSet.java Thu Jan 29 18:48:37 2009
@@ -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.
@@ -17,7 +17,7 @@
 package org.apache.commons.collections.set;
 
 import java.util.Collection;
-import java.util.Iterator;
+import java.util.List;
 import java.util.Set;
 
 import org.apache.commons.collections.CollectionUtils;
@@ -35,29 +35,30 @@
  *
  * @author Brian McCallister
  */
-public class CompositeSet extends CompositeCollection implements Set {
+public class CompositeSet<E> extends CompositeCollection<E> implements Set<E> {
+
     /**
      * Create an empty CompositeSet
      */
     public CompositeSet() {
         super();
     }
-    
+
     /**
      * Create a CompositeSet with just <code>set</code> composited
      * @param set The initial set in the composite
      */
-    public CompositeSet(Set set) {
+    public CompositeSet(Set<E> set) {
         super(set);
     }
-    
+
     /**
      * Create a composite set with sets as the initial set of composited Sets
      */
-    public CompositeSet(Set[] sets) {
+    public CompositeSet(Set<E>[] sets) {
         super(sets);
     }
-    
+
     /**
      * Add a Set to this composite
      *
@@ -69,14 +70,13 @@
      * @see org.apache.commons.collections.collection.CompositeCollection.CollectionMutator
      * @see SetMutator
      */
-    public synchronized void addComposited(Collection c) {
+    public synchronized void addComposited(Collection<E> c) {
         if (!(c instanceof Set)) {
             throw new IllegalArgumentException("Collections added must implement java.util.Set");
         }
-        
-        for (Iterator i = this.getCollections().iterator(); i.hasNext();) {
-            Set set = (Set) i.next();
-            Collection intersects = CollectionUtils.intersection(set, c);
+
+        for (Set<E> set : getCollections()) {
+            Collection<E> intersects = CollectionUtils.intersection(set, c);
             if (intersects.size() > 0) {
                 if (this.mutator == null) {
                     throw new UnsupportedOperationException(
@@ -86,38 +86,48 @@
                     throw new UnsupportedOperationException(
                         "Collision adding composited collection to a CompositeSet with a CollectionMutator instead of a SetMutator");
                 }
-                ((SetMutator) this.mutator).resolveCollision(this, set, (Set) c, intersects);
+                getMutator().resolveCollision(this, set, (Set<E>) c, intersects);
                 if (CollectionUtils.intersection(set, c).size() > 0) {
                     throw new IllegalArgumentException(
                         "Attempt to add illegal entry unresolved by SetMutator.resolveCollision()");
                 }
             }
         }
-        super.addComposited(new Collection[]{c});
+        super.addComposited(c);
     }
-    
+
+    /**
+     * {@inheritDoc}
+     */
+    @SuppressWarnings("unchecked")
+    @Override
+    public List<? extends Set<E>> getCollections() {
+        return (List<Set<E>>) super.getCollections();
+    }
+
     /**
      * Add two sets to this composite
      *
      * @throws IllegalArgumentException if c or d does not implement java.util.Set
      */
-    public synchronized void addComposited(Collection c, Collection d) {
+    @SuppressWarnings("unchecked")
+    public synchronized void addComposited(Collection<E> c, Collection<E> d) {
         if (!(c instanceof Set)) throw new IllegalArgumentException("Argument must implement java.util.Set");
         if (!(d instanceof Set)) throw new IllegalArgumentException("Argument must implement java.util.Set");
-        this.addComposited(new Set[]{(Set) c, (Set) d});
+        this.addComposited(new Set[] { (Set<? extends E>) c, (Set<? extends E>) d });
     }
-    
+
     /**
      * Add an array of sets to this composite
      * @param comps
      * @throws IllegalArgumentException if any of the collections in comps do not implement Set
      */
-    public synchronized void addComposited(Collection[] comps) {
+    public synchronized void addComposited(Collection<E>[] comps) {
         for (int i = comps.length - 1; i >= 0; --i) {
             this.addComposited(comps[i]);
         }
     }
-    
+
     /**
      * This can receive either a <code>CompositeCollection.CollectionMutator</code>
      * or a <code>CompositeSet.SetMutator</code>. If a
@@ -125,12 +135,12 @@
      * composited sets will throw IllegalArgumentException
      * <p>
      */
-    public void setMutator(CollectionMutator mutator) {
+    public void setMutator(CollectionMutator<E> mutator) {
         super.setMutator(mutator);
     }
-    
+
     /* Set operations */
-    
+
     /**
      * If a <code>CollectionMutator</code> is defined for this CompositeSet then this
      * method will be called anyway.
@@ -139,46 +149,51 @@
      * @return true if the object is removed, false otherwise
      */
     public boolean remove(Object obj) {
-        for (Iterator i = this.getCollections().iterator(); i.hasNext();) {
-            Set set = (Set) i.next();
+        for (Set<? extends E> set : getCollections()) {
             if (set.contains(obj)) return set.remove(obj);
         }
         return false;
     }
-    
-    
+
     /**
      * @see Set#equals
      */
+    @SuppressWarnings("unchecked")
     public boolean equals(Object obj) {
         if (obj instanceof Set) {
             Set set = (Set) obj;
-            if (set.containsAll(this) && set.size() == this.size()) {
-                return true;
-            }
+            return set.containsAll(this) && set.size() == this.size();
         }
         return false;
     }
-    
+
     /**
      * @see Set#hashCode
      */
     public int hashCode() {
         int code = 0;
-        for (Iterator i = this.iterator(); i.hasNext();) {
-            Object next = i.next();
-            code += (next != null ? next.hashCode() : 0);
+        for (E e : this) {
+            code += (e == null ? 0 : e.hashCode());
         }
         return code;
     }
-    
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected SetMutator<E> getMutator() {
+        return (SetMutator<E>) super.getMutator();
+    }
+
     /**
      * Define callbacks for mutation operations.
      * <p>
      * Defining remove() on implementations of SetMutator is pointless
      * as they are never called by CompositeSet.
      */
-    public static interface SetMutator extends CompositeCollection.CollectionMutator {
+    public static interface SetMutator<E> extends CompositeCollection.CollectionMutator<E> {
+
         /**
          * <p>
          * Called when a Set is added to the CompositeSet and there is a
@@ -193,6 +208,6 @@
          * @param added the Set being added to the composite
          * @param intersects the intersection of th existing and added sets
          */
-        public void resolveCollision(CompositeSet comp, Set existing, Set added, Collection intersects);
+        public void resolveCollision(CompositeSet<E> comp, Set<E> existing, Set<E> added, Collection<E> intersects);
     }
 }

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/ListOrderedSet.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/ListOrderedSet.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/ListOrderedSet.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/ListOrderedSet.java Thu Jan 29 18:48:37 2009
@@ -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.
@@ -36,7 +36,7 @@
  * <p>
  * The ListOrderedSet also has various useful direct methods. These include many
  * from <code>List</code>, such as <code>get(int)</code>, <code>remove(int)</code>
- * and <code>indexOf(int)</code>. An unmodifiable <code>List</code> view of 
+ * and <code>indexOf(int)</code>. An unmodifiable <code>List</code> view of
  * the set can be obtained via <code>asList()</code>.
  * <p>
  * This class cannot implement the <code>List</code> interface directly as
@@ -46,30 +46,30 @@
  *
  * @since Commons Collections 3.0
  * @version $Revision$ $Date$
- * 
+ *
  * @author Stephen Colebourne
  * @author Henning P. Schmiedehausen
  */
-public class ListOrderedSet extends AbstractSerializableSetDecorator implements Set {
+public class ListOrderedSet<E> extends AbstractSerializableSetDecorator<E> implements Set<E> {
 
     /** Serialization version */
     private static final long serialVersionUID = -228664372470420141L;
 
     /** Internal list to hold the sequence of objects */
-    protected final List setOrder;
+    protected final List<E> setOrder;
 
     /**
      * Factory method to create an ordered set specifying the list and set to use.
      * <p>
      * The list and set must both be empty.
-     * 
+     *
      * @param set  the set to decorate, must be empty and not null
      * @param list  the list to decorate, must be empty and not null
      * @throws IllegalArgumentException if set or list is null
      * @throws IllegalArgumentException if either the set or list is not empty
      * @since Commons Collections 3.1
      */
-    public static ListOrderedSet decorate(Set set, List list) {
+    public static <E> ListOrderedSet<E> decorate(Set<E> set, List<E> list) {
         if (set == null) {
             throw new IllegalArgumentException("Set must not be null");
         }
@@ -79,19 +79,19 @@
         if (set.size() > 0 || list.size() > 0) {
             throw new IllegalArgumentException("Set and List must be empty");
         }
-        return new ListOrderedSet(set, list);
+        return new ListOrderedSet<E>(set, list);
     }
 
     /**
      * Factory method to create an ordered set.
      * <p>
      * An <code>ArrayList</code> is used to retain order.
-     * 
+     *
      * @param set  the set to decorate, must not be null
      * @throws IllegalArgumentException if set is null
      */
-    public static ListOrderedSet decorate(Set set) {
-        return new ListOrderedSet(set);
+    public static <E> ListOrderedSet<E> decorate(Set<E> set) {
+        return new ListOrderedSet<E>(set);
     }
 
     /**
@@ -101,53 +101,53 @@
      * <p>
      * NOTE: If the list contains duplicates, the duplicates are removed,
      * altering the specified list.
-     * 
+     *
      * @param list  the list to decorate, must not be null
      * @throws IllegalArgumentException if list is null
      */
-    public static ListOrderedSet decorate(List list) {
+    public static <E> ListOrderedSet<E> decorate(List<E> list) {
         if (list == null) {
             throw new IllegalArgumentException("List must not be null");
         }
-        Set set = new HashSet(list);
+        Set<E> set = new HashSet<E>(list);
         list.retainAll(set);
-        
-        return new ListOrderedSet(set, list);
+
+        return new ListOrderedSet<E>(set, list);
     }
 
     //-----------------------------------------------------------------------
     /**
      * Constructs a new empty <code>ListOrderedSet</code> using
      * a <code>HashSet</code> and an <code>ArrayList</code> internally.
-     * 
+     *
      * @since Commons Collections 3.1
      */
     public ListOrderedSet() {
-        super(new HashSet());
-        setOrder = new ArrayList();
+        super(new HashSet<E>());
+        setOrder = new ArrayList<E>();
     }
 
     /**
      * Constructor that wraps (not copies).
-     * 
+     *
      * @param set  the set to decorate, must not be null
      * @throws IllegalArgumentException if set is null
      */
-    protected ListOrderedSet(Set set) {
+    protected ListOrderedSet(Set<E> set) {
         super(set);
-        setOrder = new ArrayList(set);
+        setOrder = new ArrayList<E>(set);
     }
 
     /**
      * Constructor that wraps (not copies) the Set and specifies the list 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 ListOrderedSet(Set set, List list) {
+    protected ListOrderedSet(Set<E> set, List<E> list) {
         super(set);
         if (list == null) {
             throw new IllegalArgumentException("List must not be null");
@@ -158,10 +158,10 @@
     //-----------------------------------------------------------------------
     /**
      * Gets an unmodifiable view of the order of the Set.
-     * 
+     *
      * @return an unmodifiable list view
      */
-    public List asList() {
+    public List<E> asList() {
         return UnmodifiableList.decorate(setOrder);
     }
 
@@ -171,27 +171,22 @@
         setOrder.clear();
     }
 
-    public Iterator iterator() {
-        return new OrderedSetIterator(setOrder.iterator(), collection);
+    public Iterator<E> iterator() {
+        return new OrderedSetIterator<E>(setOrder.iterator(), collection);
     }
 
-    public boolean add(Object object) {
-        if (collection.contains(object)) {
-            // re-adding doesn't change order
-            return collection.add(object);
-        } else {
-            // first add, so add to both set and list
-            boolean result = collection.add(object);
+    public boolean add(E object) {
+        if (collection.add(object)) {
             setOrder.add(object);
-            return result;
+            return true;
         }
+        return false;
     }
 
-    public boolean addAll(Collection coll) {
+    public boolean addAll(Collection<? extends E> coll) {
         boolean result = false;
-        for (Iterator it = coll.iterator(); it.hasNext();) {
-            Object object = it.next();
-            result = result | add(object);
+        for (E e : coll) {
+            result |= add(e);
         }
         return result;
     }
@@ -202,25 +197,24 @@
         return result;
     }
 
-    public boolean removeAll(Collection coll) {
+    public boolean removeAll(Collection<?> coll) {
         boolean result = false;
-        for (Iterator it = coll.iterator(); it.hasNext();) {
-            Object object = it.next();
-            result = result | remove(object);
+        for (Iterator<?> it = coll.iterator(); it.hasNext();) {
+            result |= remove(it.next());
         }
         return result;
     }
 
-    public boolean retainAll(Collection coll) {
+    public boolean retainAll(Collection<?> coll) {
         boolean result = collection.retainAll(coll);
         if (result == false) {
             return false;
-        } else if (collection.size() == 0) {
+        }
+        if (collection.size() == 0) {
             setOrder.clear();
         } else {
-            for (Iterator it = setOrder.iterator(); it.hasNext();) {
-                Object object = it.next();
-                if (collection.contains(object) == false) {
+            for (Iterator<E> it = setOrder.iterator(); it.hasNext();) {
+                if (!collection.contains(it.next())) {
                     it.remove();
                 }
             }
@@ -232,12 +226,12 @@
         return setOrder.toArray();
     }
 
-    public Object[] toArray(Object a[]) {
+    public <T> T[] toArray(T a[]) {
         return setOrder.toArray(a);
     }
 
     //-----------------------------------------------------------------------
-    public Object get(int index) {
+    public E get(int index) {
         return setOrder.get(index);
     }
 
@@ -245,23 +239,22 @@
         return setOrder.indexOf(object);
     }
 
-    public void add(int index, Object object) {
-        if (contains(object) == false) {
+    public void add(int index, E object) {
+        if (!contains(object)) {
             collection.add(object);
             setOrder.add(index, object);
         }
     }
 
-    public boolean addAll(int index, Collection coll) {
+    public boolean addAll(int index, Collection<? extends E> coll) {
         boolean changed = false;
-        for (Iterator it = coll.iterator(); it.hasNext();) {
-            Object object = it.next();
-            if (contains(object) == false) {
-                collection.add(object);
-                setOrder.add(index, object);
-                index++;
-                changed = true;
+        for (E e : coll) {
+            if (contains(e)) {
+                continue;
             }
+            collection.add(e);
+            setOrder.add(index++, e);
+            changed = true;
         }
         return changed;
     }
@@ -273,9 +266,9 @@
     }
 
     /**
-     * Uses the underlying List's toString so that order is achieved. 
-     * This means that the decorated Set's toString is not used, so 
-     * any custom toStrings will be ignored. 
+     * Uses the underlying List's toString so that order is achieved.
+     * This means that the decorated Set's toString is not used, so
+     * any custom toStrings will be ignored.
      */
     // Fortunately List.toString and Set.toString look the same
     public String toString() {
@@ -286,19 +279,19 @@
     /**
      * Internal iterator handle remove.
      */
-    static class OrderedSetIterator extends AbstractIteratorDecorator {
-        
+    static class OrderedSetIterator<E> extends AbstractIteratorDecorator<E> {
+
         /** Object we iterate on */
-        protected final Collection set;
+        protected final Collection<E> set;
         /** Last object retrieved */
-        protected Object last;
+        protected E last;
 
-        private OrderedSetIterator(Iterator iterator, Collection set) {
+        private OrderedSetIterator(Iterator<E> iterator, Collection<E> set) {
             super(iterator);
             this.set = set;
         }
 
-        public Object next() {
+        public E next() {
             last = iterator.next();
             return last;
         }

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/MapBackedSet.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/MapBackedSet.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/MapBackedSet.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/MapBackedSet.java Thu Jan 29 18:48:37 2009
@@ -37,15 +37,16 @@
  * 
  * @author Stephen Colebourne
  */
-public final class MapBackedSet implements Set, Serializable {
+public final class MapBackedSet<E, V> implements Set<E>, Serializable {
 
     /** Serialization version */
     private static final long serialVersionUID = 6723912213766056587L;
 
     /** The map being used as the backing store */
-    protected final Map map;
+    protected final Map<E, ? super V> map;
+
     /** The dummyValue to use */
-    protected final Object dummyValue;
+    protected final V dummyValue;
 
     /**
      * Factory method to create a set from a map.
@@ -53,7 +54,7 @@
      * @param map  the map to decorate, must not be null
      * @throws IllegalArgumentException if set is null
      */
-    public static Set decorate(Map map) {
+    public static <E, V> Set<E> decorate(Map<E, ? super V> map) {
         return decorate(map, null);
     }
 
@@ -64,11 +65,11 @@
      * @param dummyValue  the dummy value to use
      * @throws IllegalArgumentException if map is null
      */
-    public static Set decorate(Map map, Object dummyValue) {
+    public static <E, V> Set<E> decorate(Map<E, ? super V> map, V dummyValue) {
         if (map == null) {
             throw new IllegalArgumentException("The map must not be null");
         }
-        return new MapBackedSet(map, dummyValue);
+        return new MapBackedSet<E, V>(map, dummyValue);
     }
 
     //-----------------------------------------------------------------------
@@ -79,7 +80,7 @@
      * @param dummyValue  the dummy value to use
      * @throws IllegalArgumentException if map is null
      */
-    private MapBackedSet(Map map, Object dummyValue) {
+    private MapBackedSet(Map<E, ? super V> map, V dummyValue) {
         super();
         this.map = map;
         this.dummyValue = dummyValue;
@@ -94,7 +95,7 @@
         return map.isEmpty();
     }
 
-    public Iterator iterator() {
+    public Iterator<E> iterator() {
         return map.keySet().iterator();
     }
 
@@ -102,21 +103,20 @@
         return map.containsKey(obj);
     }
 
-    public boolean containsAll(Collection coll) {
+    public boolean containsAll(Collection<?> coll) {
         return map.keySet().containsAll(coll);
     }
 
-    public boolean add(Object obj) {
+    public boolean add(E obj) {
         int size = map.size();
         map.put(obj, dummyValue);
         return (map.size() != size);
     }
 
-    public boolean addAll(Collection coll) {
+    public boolean addAll(Collection<? extends E> coll) {
         int size = map.size();
-        for (Iterator it = coll.iterator(); it.hasNext();) {
-            Object obj = it.next();
-            map.put(obj, dummyValue);
+        for (E e : coll) {
+            map.put(e, dummyValue);
         }
         return (map.size() != size);
     }
@@ -127,11 +127,11 @@
         return (map.size() != size);
     }
 
-    public boolean removeAll(Collection coll) {
+    public boolean removeAll(Collection<?> coll) {
         return map.keySet().removeAll(coll);
     }
 
-    public boolean retainAll(Collection coll) {
+    public boolean retainAll(Collection<?> coll) {
         return map.keySet().retainAll(coll);
     }
 
@@ -143,7 +143,7 @@
         return map.keySet().toArray();
     }
 
-    public Object[] toArray(Object[] array) {
+    public <T> T[] toArray(T[] array) {
         return map.keySet().toArray(array);
     }
 

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/SynchronizedSet.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/SynchronizedSet.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/SynchronizedSet.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/SynchronizedSet.java Thu Jan 29 18:48:37 2009
@@ -75,8 +75,8 @@
      * 
      * @return the decorated set
      */
-    protected Set getSet() {
-        return (Set) collection;
+    protected Set<E> getSet() {
+        return (Set<E>) collection;
     }
 
 }

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/SynchronizedSortedSet.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/SynchronizedSortedSet.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/SynchronizedSortedSet.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/SynchronizedSortedSet.java Thu Jan 29 18:48:37 2009
@@ -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.
@@ -31,7 +31,7 @@
  *
  * @since Commons Collections 3.0
  * @version $Revision$ $Date$
- * 
+ *
  * @author Stephen Colebourne
  */
 public class SynchronizedSortedSet<E> extends SynchronizedCollection<E> implements SortedSet<E> {
@@ -41,18 +41,18 @@
 
     /**
      * Factory method to create a synchronized set.
-     * 
+     *
      * @param set  the set to decorate, must not be null
      * @throws IllegalArgumentException if set is null
      */
     public static <T> SortedSet<T> decorate(SortedSet<T> set) {
         return new SynchronizedSortedSet<T>(set);
     }
-    
+
     //-----------------------------------------------------------------------
     /**
      * Constructor that wraps (not copies).
-     * 
+     *
      * @param set  the set to decorate, must not be null
      * @throws IllegalArgumentException if set is null
      */
@@ -62,7 +62,7 @@
 
     /**
      * Constructor that wraps (not copies).
-     * 
+     *
      * @param set  the set to decorate, must not be null
      * @param lock  the lock object to use, must not be null
      * @throws IllegalArgumentException if set is null
@@ -73,7 +73,7 @@
 
     /**
      * Gets the decorated set.
-     * 
+     *
      * @return the decorated set
      */
     protected SortedSet<E> getSortedSet() {
@@ -83,28 +83,28 @@
     //-----------------------------------------------------------------------
     public SortedSet<E> subSet(E fromElement, E toElement) {
         synchronized (lock) {
-            SortedSet set = getSortedSet().subSet(fromElement, toElement);
+            SortedSet<E> set = getSortedSet().subSet(fromElement, toElement);
             // the lock is passed into the constructor here to ensure that the
             // subset is synchronized on the same lock as the parent
-            return new SynchronizedSortedSet(set, lock);
+            return new SynchronizedSortedSet<E>(set, lock);
         }
     }
 
     public SortedSet<E> headSet(E toElement) {
         synchronized (lock) {
-            SortedSet set = getSortedSet().headSet(toElement);
+            SortedSet<E> set = getSortedSet().headSet(toElement);
             // the lock is passed into the constructor here to ensure that the
             // headset is synchronized on the same lock as the parent
-            return new SynchronizedSortedSet(set, lock);
+            return new SynchronizedSortedSet<E>(set, lock);
         }
     }
 
     public SortedSet<E> tailSet(E fromElement) {
         synchronized (lock) {
-            SortedSet set = getSortedSet().tailSet(fromElement);
+            SortedSet<E> set = getSortedSet().tailSet(fromElement);
             // the lock is passed into the constructor here to ensure that the
             // tailset is synchronized on the same lock as the parent
-            return new SynchronizedSortedSet(set, lock);
+            return new SynchronizedSortedSet<E>(set, lock);
         }
     }
 
@@ -120,7 +120,7 @@
         }
     }
 
-    public Comparator comparator() {
+    public Comparator<? super E> comparator() {
         synchronized (lock) {
             return getSortedSet().comparator();
         }

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/TransformedSet.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/TransformedSet.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/TransformedSet.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/TransformedSet.java Thu Jan 29 18:48:37 2009
@@ -36,7 +36,7 @@
  * 
  * @author Stephen Colebourne
  */
-public class TransformedSet extends TransformedCollection implements Set {
+public class TransformedSet<E> extends TransformedCollection<E> implements Set<E> {
 
     /** Serialization version */
     private static final long serialVersionUID = 306127383500410386L;
@@ -51,8 +51,8 @@
      * @param transformer  the transformer to use for conversion, must not be null
      * @throws IllegalArgumentException if set or transformer is null
      */
-    public static Set decorate(Set set, Transformer transformer) {
-        return new TransformedSet(set, transformer);
+    public static <E> Set<E> decorate(Set<E> set, Transformer<? super E, ? extends E> transformer) {
+        return new TransformedSet<E>(set, transformer);
     }
     
     //-----------------------------------------------------------------------
@@ -66,7 +66,7 @@
      * @param transformer  the transformer to use for conversion, must not be null
      * @throws IllegalArgumentException if set or transformer is null
      */
-    protected TransformedSet(Set set, Transformer transformer) {
+    protected TransformedSet(Set<E> set, Transformer<? super E, ? extends E> transformer) {
         super(set, transformer);
     }
 

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/TransformedSortedSet.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/TransformedSortedSet.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/TransformedSortedSet.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/TransformedSortedSet.java Thu Jan 29 18:48:37 2009
@@ -36,7 +36,7 @@
  * 
  * @author Stephen Colebourne
  */
-public class TransformedSortedSet extends TransformedSet implements SortedSet {
+public class TransformedSortedSet<E> extends TransformedSet<E> implements SortedSet<E> {
 
     /** Serialization version */
     private static final long serialVersionUID = -1675486811351124386L;
@@ -51,8 +51,8 @@
      * @param transformer  the transformer to use for conversion, must not be null
      * @throws IllegalArgumentException if set or transformer is null
      */
-    public static SortedSet decorate(SortedSet set, Transformer transformer) {
-        return new TransformedSortedSet(set, transformer);
+    public static <E> SortedSet<E> decorate(SortedSet<E> set, Transformer<? super E, ? extends E> transformer) {
+        return new TransformedSortedSet<E>(set, transformer);
     }
     
     //-----------------------------------------------------------------------
@@ -66,7 +66,7 @@
      * @param transformer  the transformer to use for conversion, must not be null
      * @throws IllegalArgumentException if set or transformer is null
      */
-    protected TransformedSortedSet(SortedSet set, Transformer transformer) {
+    protected TransformedSortedSet(SortedSet<E> set, Transformer<? super E, ? extends E> transformer) {
         super(set, transformer);
     }
 
@@ -75,37 +75,37 @@
      * 
      * @return the decorated set
      */
-    protected SortedSet getSortedSet() {
-        return (SortedSet) collection;
+    protected SortedSet<E> getSortedSet() {
+        return (SortedSet<E>) collection;
     }
 
     //-----------------------------------------------------------------------
-    public Object first() {
+    public E first() {
         return getSortedSet().first();
     }
 
-    public Object last() {
+    public E last() {
         return getSortedSet().last();
     }
 
-    public Comparator comparator() {
+    public Comparator<? super E> comparator() {
         return getSortedSet().comparator();
     }
 
     //-----------------------------------------------------------------------
-    public SortedSet subSet(Object fromElement, Object toElement) {
-        SortedSet set = getSortedSet().subSet(fromElement, toElement);
-        return new TransformedSortedSet(set, transformer);
+    public SortedSet<E> subSet(E fromElement, E toElement) {
+        SortedSet<E> set = getSortedSet().subSet(fromElement, toElement);
+        return new TransformedSortedSet<E>(set, transformer);
     }
 
-    public SortedSet headSet(Object toElement) {
-        SortedSet set = getSortedSet().headSet(toElement);
-        return new TransformedSortedSet(set, transformer);
+    public SortedSet<E> headSet(E toElement) {
+        SortedSet<E> set = getSortedSet().headSet(toElement);
+        return new TransformedSortedSet<E>(set, transformer);
     }
 
-    public SortedSet tailSet(Object fromElement) {
-        SortedSet set = getSortedSet().tailSet(fromElement);
-        return new TransformedSortedSet(set, transformer);
+    public SortedSet<E> tailSet(E fromElement) {
+        SortedSet<E> set = getSortedSet().tailSet(fromElement);
+        return new TransformedSortedSet<E>(set, transformer);
     }
 
 }

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/UnmodifiableSet.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/UnmodifiableSet.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/UnmodifiableSet.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/UnmodifiableSet.java Thu Jan 29 18:48:37 2009
@@ -33,8 +33,8 @@
  * 
  * @author Stephen Colebourne
  */
-public final class UnmodifiableSet
-        extends AbstractSerializableSetDecorator
+public final class UnmodifiableSet<E>
+        extends AbstractSerializableSetDecorator<E>
         implements Unmodifiable {
 
     /** Serialization version */
@@ -46,11 +46,11 @@
      * @param set  the set to decorate, must not be null
      * @throws IllegalArgumentException if set is null
      */
-    public static Set decorate(Set set) {
+    public static <E> Set<E> decorate(Set<E> set) {
         if (set instanceof Unmodifiable) {
             return set;
         }
-        return new UnmodifiableSet(set);
+        return new UnmodifiableSet<E>(set);
     }
 
     //-----------------------------------------------------------------------
@@ -60,20 +60,20 @@
      * @param set  the set to decorate, must not be null
      * @throws IllegalArgumentException if set is null
      */
-    private UnmodifiableSet(Set set) {
+    private UnmodifiableSet(Set<E> set) {
         super(set);
     }
 
     //-----------------------------------------------------------------------
-    public Iterator iterator() {
-        return UnmodifiableIterator.decorate(decorated().iterator());
+    public Iterator<E> iterator() {
+        return UnmodifiableIterator.<E>decorate(decorated().iterator());
     }
 
-    public boolean add(Object object) {
+    public boolean add(E object) {
         throw new UnsupportedOperationException();
     }
 
-    public boolean addAll(Collection coll) {
+    public boolean addAll(Collection<? extends E> coll) {
         throw new UnsupportedOperationException();
     }
 
@@ -85,11 +85,11 @@
         throw new UnsupportedOperationException();
     }
 
-    public boolean removeAll(Collection coll) {
+    public boolean removeAll(Collection<?> coll) {
         throw new UnsupportedOperationException();
     }
 
-    public boolean retainAll(Collection coll) {
+    public boolean retainAll(Collection<?> coll) {
         throw new UnsupportedOperationException();
     }
 

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/UnmodifiableSortedSet.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/UnmodifiableSortedSet.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/UnmodifiableSortedSet.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/UnmodifiableSortedSet.java Thu Jan 29 18:48:37 2009
@@ -54,7 +54,7 @@
         if (set instanceof Unmodifiable) {
             return set;
         }
-        return new UnmodifiableSortedSet(set);
+        return new UnmodifiableSortedSet<T>(set);
     }
 
     //-----------------------------------------------------------------------
@@ -76,6 +76,7 @@
      * @throws IOException
      * @throws ClassNotFoundException
      */
+    @SuppressWarnings("unchecked")
     private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
         in.defaultReadObject();
         collection = (Collection) in.readObject();
@@ -93,7 +94,7 @@
     }
 
     //-----------------------------------------------------------------------
-    public Iterator iterator() {
+    public Iterator<E> iterator() {
         return UnmodifiableIterator.decorate(decorated().iterator());
     }
 
@@ -124,17 +125,17 @@
     //-----------------------------------------------------------------------
     public SortedSet<E> subSet(E fromElement, E toElement) {
         SortedSet<E> sub = decorated().subSet(fromElement, toElement);
-        return new UnmodifiableSortedSet(sub);
+        return new UnmodifiableSortedSet<E>(sub);
     }
 
     public SortedSet<E> headSet(E toElement) {
         SortedSet<E> sub = decorated().headSet(toElement);
-        return new UnmodifiableSortedSet(sub);
+        return new UnmodifiableSortedSet<E>(sub);
     }
 
     public SortedSet<E> tailSet(E fromElement) {
         SortedSet<E> sub = decorated().tailSet(fromElement);
-        return new UnmodifiableSortedSet(sub);
+        return new UnmodifiableSortedSet<E>(sub);
     }
 
 }

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/AbstractTestObject.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/AbstractTestObject.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/AbstractTestObject.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/AbstractTestObject.java Thu Jan 29 18:48:37 2009
@@ -167,7 +167,7 @@
         Object o = makeObject();
         if (o instanceof Serializable && isTestSerialization()) {
             byte[] objekt = writeExternalFormToBytes((Serializable) o);
-            Object p = readExternalFormFromBytes(objekt);
+            readExternalFormFromBytes(objekt);
         }
     }
 

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/BulkTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/BulkTest.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/BulkTest.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/BulkTest.java Thu Jan 29 18:48:37 2009
@@ -246,7 +246,7 @@
      *  @return  a {@link TestSuite} containing all the simple and bulk tests
      *    defined by that class
      */
-    public static TestSuite makeSuite(Class c) {
+    public static TestSuite makeSuite(Class<? extends BulkTest> c) {
         if (Modifier.isAbstract(c.getModifiers())) {
             throw new IllegalArgumentException("Class must not be abstract.");
         }
@@ -265,10 +265,10 @@
 class BulkTestSuiteMaker {
 
     /** The class that defines simple and bulk tests methods. */
-    private Class startingClass;
+    private Class<? extends BulkTest> startingClass;
 
     /** List of ignored simple test names. */
-    private List ignored;
+    private List<String> ignored;
    
     /** The TestSuite we're currently populating.  Can change over time. */
     private TestSuite result;
@@ -284,7 +284,7 @@
      *
      *  @param startingClass  the starting class
      */     
-    public BulkTestSuiteMaker(Class startingClass) {
+    public BulkTestSuiteMaker(Class<? extends BulkTest> startingClass) {
         this.startingClass = startingClass;
     }
 
@@ -299,7 +299,7 @@
          result.setName(prefix);
 
          BulkTest bulk = makeFirstTestCase(startingClass);
-         ignored = new ArrayList();
+         ignored = new ArrayList<String>();
          String[] s = bulk.ignoredTests();
          if (s != null) {
              ignored.addAll(Arrays.asList(s));
@@ -316,7 +316,7 @@
      *    tests for us to append
      */
     void make(BulkTest bulk) {
-        Class c = bulk.getClass();
+        Class<? extends BulkTest> c = bulk.getClass();
         Method[] all = c.getMethods();
         for (int i = 0; i < all.length; i++) {
             if (isTest(all[i])) addTest(bulk, all[i]);
@@ -388,7 +388,7 @@
      *  @param c  the class
      *  @return the name of that class, minus any package names
      */
-    private static String getBaseName(Class c) {
+    private static String getBaseName(Class<?> c) {
         String name = c.getName();
         int p = name.lastIndexOf('.');
         if (p > 0) {
@@ -401,7 +401,7 @@
     // These three methods are used to create a valid BulkTest instance
     // from a class.
 
-    private static Constructor getTestCaseConstructor(Class c) {
+    private static <T> Constructor<T> getTestCaseConstructor(Class<T> c) {
         try {
             return c.getConstructor(new Class[] { String.class });
         } catch (NoSuchMethodException e) {
@@ -410,10 +410,10 @@
         }
     }
 
-    private static BulkTest makeTestCase(Class c, Method m) {
-        Constructor con = getTestCaseConstructor(c);
+    private static <T extends BulkTest> BulkTest makeTestCase(Class<T> c, Method m) {
+        Constructor<T> con = getTestCaseConstructor(c);
         try {
-            return (BulkTest)con.newInstance(new Object[] {m.getName()});
+            return (BulkTest) con.newInstance(new Object[] { m.getName() });
         } catch (InvocationTargetException e) {
             e.printStackTrace();
             throw new RuntimeException(); // FIXME;
@@ -424,7 +424,7 @@
         }
     }
 
-    private static BulkTest makeFirstTestCase(Class c) {
+    private static <T extends BulkTest> BulkTest makeFirstTestCase(Class<T> c) {
         Method[] all = c.getMethods();
         for (int i = 0; i < all.length; i++) {
             if (isTest(all[i])) return makeTestCase(c, all[i]);

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/LocalTestNode.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/LocalTestNode.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/LocalTestNode.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/LocalTestNode.java Thu Jan 29 18:48:37 2009
@@ -23,46 +23,50 @@
  *
  * @author Marc Johnson (marcj at users dot sourceforge dot net)
  */
-class LocalTestNode implements Comparable {
+class LocalTestNode<K extends Comparable<K>, V extends Comparable<V>> implements Comparable<LocalTestNode<K, V>> {
 
-    private Comparable key;
-    private Comparable value;
+    private K key;
+    private V value;
+
+    static LocalTestNode<Integer, String> createLocalTestNode(final int key) {
+        return new LocalTestNode<Integer, String>(key, String.valueOf(key));
+    }
 
     /**
      * construct a LocalTestNode
      *
      * @param key value used to create the key and value
      */
-    LocalTestNode(final int key) {
-        this.key   = new Integer(key);
-        this.value = String.valueOf(key);
+    private LocalTestNode(K key, V value) {
+        this.key = key;
+        this.value = value;
     }
 
     /**
      * @param key the unique key associated with the current node.
      */
-    void setKey(Comparable key) {
+    void setKey(K key) {
         this.key = key;
     }
 
     /**
      * @return the unique key associated with the current node
      */
-    Comparable getKey() {
+    K getKey() {
         return key;
     }
 
     /**
      * @param value the unique value associated with the current node.
      */
-    void setValue(Comparable value) {
+    void setValue(V value) {
         this.value = value;
     }
 
     /**
      * @return the unique value associated with the current node
      */
-    Comparable getValue() {
+    V getValue() {
         return value;
     }
 
@@ -73,10 +77,9 @@
      *
      * @return
      */
-    public int compareTo(Object o) {
+    public int compareTo(LocalTestNode<K, V> other) {
 
-        LocalTestNode other = (LocalTestNode) o;
-        int           rval  = getKey().compareTo(other.getKey());
+        int rval = getKey().compareTo(other.getKey());
 
         if (rval == 0) {
             rval = getValue().compareTo(other.getValue());
@@ -92,6 +95,7 @@
      *
      * @return true if equal
      */
+    @SuppressWarnings("unchecked")
     public boolean equals(Object o) {
 
         if (o == null) {

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/MapPerformance.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/MapPerformance.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/MapPerformance.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/MapPerformance.java Thu Jan 29 18:48:37 2009
@@ -17,11 +17,11 @@
 package org.apache.commons.collections;
 
 import java.util.Collection;
-import java.util.Collections;
+//import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
-import java.util.TreeMap;
+//import java.util.TreeMap;
 
 import org.apache.commons.collections.map.Flat3Map;
 
@@ -43,17 +43,17 @@
     }
     
     private static void testAll() {
-        Map dummyMap = new DummyMap();
-        Map hashMap = new HashMap();
+        Map<String, String> dummyMap = new DummyMap<String, String>();
+        Map<String, String> hashMap = new HashMap<String, String>();
 //        hashMap.put("Alpha", "A");
 //        hashMap.put("Beta", "B");
 //        hashMap.put("Gamma", "C");
 //        hashMap.put("Delta", "D");
-        Map flatMap = new Flat3Map(hashMap);
+        Map<String, String> flatMap = new Flat3Map<String, String>(hashMap);
         System.out.println(flatMap);
-        Map unmodHashMap = Collections.unmodifiableMap(new HashMap(hashMap));
+//        Map<String, String> unmodHashMap = Collections.unmodifiableMap(new HashMap<String, String>(hashMap));
 //        Map fastHashMap = new FastHashMap(hashMap);
-        Map treeMap = new TreeMap(hashMap);
+//        Map<String, String> treeMap = new TreeMap<String, String>(hashMap);
 //        Map linkedMap = new LinkedHashMap(hashMap);
 //        Map syncMap = Collections.unmodifiableMap(new HashMap(hashMap));
 //        Map bucketMap = new StaticBucketMap();
@@ -109,9 +109,9 @@
 //        test(doubleMap,     "     DoubleMap ");
     }
 
-    private static void test(Map map, String name) {
+    private static void test(Map<String, String> map, String name) {
         long start = 0, end = 0;
-        int total = 0;
+//        int total = 0;
         start = System.currentTimeMillis();
         for (int i = RUNS; i > 0; i--) {
 //            if (map.get("Alpha") != null) total++;
@@ -133,7 +133,7 @@
 
     // ----------------------------------------------------------------------
 
-    private static class DummyMap implements Map {
+    private static class DummyMap<K, V> implements Map<K, V> {
         public void clear() {
         }
         public boolean containsKey(Object key) {
@@ -142,30 +142,30 @@
         public boolean containsValue(Object value) {
             return false;
         }
-        public Set entrySet() {
+        public Set<Map.Entry<K, V>> entrySet() {
             return null;
         }
-        public Object get(Object key) {
+        public V get(Object key) {
             return null;
         }
         public boolean isEmpty() {
             return false;
         }
-        public Set keySet() {
+        public Set<K> keySet() {
             return null;
         }
-        public Object put(Object key, Object value) {
+        public V put(K key, V value) {
             return null;
         }
-        public void putAll(Map t) {
+        public void putAll(Map<? extends K, ? extends V> t) {
         }
-        public Object remove(Object key) {
+        public V remove(Object key) {
             return null;
         }
         public int size() {
             return 0;
         }
-        public Collection values() {
+        public Collection<V> values() {
             return null;
         }
     }

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/MockTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/MockTestCase.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/MockTestCase.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/MockTestCase.java Thu Jan 29 18:48:37 2009
@@ -17,7 +17,6 @@
 package org.apache.commons.collections;
 
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 import java.util.ListIterator;
 
@@ -50,13 +49,13 @@
 	}
 
 	protected final void replay() {
-		for (Iterator i = mockObjects.iterator(); i.hasNext();) {
-			EasyMock.replay(i.next());
+		for (Object o : mockObjects) {
+			EasyMock.replay(o);
 		}
 	}
 
 	protected final void verify() {
-		for (ListIterator i = mockObjects.listIterator(); i.hasNext();) {
+		for (ListIterator<Object> i = mockObjects.listIterator(); i.hasNext();) {
 			try {
 				EasyMock.verify(i.next());
 			} catch (AssertionError e) {

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/TestArrayList.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/TestArrayList.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/TestArrayList.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/TestArrayList.java Thu Jan 29 18:48:37 2009
@@ -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.
@@ -25,15 +25,13 @@
 
 /**
  * Abstract test class for ArrayList.
- * 
+ *
  * @version $Revision$ $Date$
- * 
+ *
  * @author Jason van Zyl
  */
-public abstract class TestArrayList extends AbstractTestList {
-    
-    protected ArrayList list = null;
-    
+public abstract class TestArrayList<E> extends AbstractTestList<E> {
+
     public TestArrayList(String testName) {
         super(testName);
     }
@@ -47,12 +45,15 @@
         junit.textui.TestRunner.main(testCaseName);
     }
 
-    public void setUp() {
-        list = (ArrayList) makeEmptyList();
-    }
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public abstract ArrayList<E> makeObject();
 
     //-----------------------------------------------------------------------
     public void testNewArrayList() {
+        ArrayList<E> list = makeObject();
         assertTrue("New list is empty", list.isEmpty());
         assertEquals("New list has size zero", list.size(), 0);
 
@@ -64,9 +65,11 @@
         }
     }
 
+    @SuppressWarnings("unchecked")
     public void testSearch() {
-        list.add("First Item");
-        list.add("Last Item");
+        ArrayList<E> list = makeObject();
+        list.add((E) "First Item");
+        list.add((E) "Last Item");
         assertEquals("First item is 'First Item'", list.get(0), "First Item");
         assertEquals("Last Item is 'Last Item'", list.get(1), "Last Item");
     }

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/TestArrayStack.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/TestArrayStack.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/TestArrayStack.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/TestArrayStack.java Thu Jan 29 18:48:37 2009
@@ -17,7 +17,6 @@
 package org.apache.commons.collections;
 
 import java.util.EmptyStackException;
-import java.util.List;
 
 import junit.framework.Test;
 
@@ -28,10 +27,8 @@
  * 
  * @author Craig McClanahan
  */
-public class TestArrayStack extends TestArrayList {
+public class TestArrayStack<E> extends TestArrayList<E> {
     
-    protected ArrayStack stack = null;
-
     public TestArrayStack(String testName) {
         super(testName);
     }
@@ -45,18 +42,13 @@
         junit.textui.TestRunner.main(testCaseName);
     }
 
-    public List makeEmptyList() {
-        return new ArrayStack();
-    }
-
-    public void setUp() {
-        stack = (ArrayStack) makeEmptyList();
-        list = stack;
+    public ArrayStack<E> makeObject() {
+        return new ArrayStack<E>();
     }
 
     //-----------------------------------------------------------------------
     public void testNewStack() {
-
+        ArrayStack<E> stack = makeObject();
         assertTrue("New stack is empty", stack.empty());
         assertEquals("New stack has size zero", stack.size(), 0);
 
@@ -76,16 +68,18 @@
 
     }
 
+    @SuppressWarnings("unchecked")
     public void testPushPeekPop() {
+        ArrayStack<E> stack = makeObject();
 
-        stack.push("First Item");
+        stack.push((E) "First Item");
         assertTrue("Stack is not empty", !stack.empty());
         assertEquals("Stack size is one", stack.size(), 1);
         assertEquals("Top item is 'First Item'",
                      (String) stack.peek(), "First Item");
         assertEquals("Stack size is one", stack.size(), 1);
 
-        stack.push("Second Item");
+        stack.push((E) "Second Item");
         assertEquals("Stack size is two", stack.size(), 2);
         assertEquals("Top item is 'Second Item'",
                      (String) stack.peek(), "Second Item");
@@ -103,10 +97,12 @@
 
     }
 
+    @SuppressWarnings("unchecked")
     public void testSearch() {
+        ArrayStack<E> stack = makeObject();
 
-        stack.push("First Item");
-        stack.push("Second Item");
+        stack.push((E) "First Item");
+        stack.push((E) "Second Item");
         assertEquals("Top item is 'Second Item'",
                      stack.search("Second Item"), 1);
         assertEquals("Next Item is 'First Item'",



Mime
View raw message