http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/java/org/apache/commons/collections/map/DefaultedMap.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/commons/collections/map/DefaultedMap.java 
b/src/java/org/apache/commons/collections/map/DefaultedMap.java
index 3b6c827..2ecd36e 100644
--- a/src/java/org/apache/commons/collections/map/DefaultedMap.java
+++ b/src/java/org/apache/commons/collections/map/DefaultedMap.java
@@ -63,15 +63,13 @@ import 
org.apache.commons.collections.functors.FactoryTransformer;
  * @author Rafael U.C. Afonso
  * @see LazyMap
  */
-public class DefaultedMap
-        extends AbstractMapDecorator
-        implements Map, Serializable {
+public class DefaultedMap<K, V> extends AbstractMapDecorator<K, V> implements 
Serializable {
 
     /** Serialization version */
     private static final long serialVersionUID = 19698628745827L;
 
     /** The transformer to use if the map does not contain a key */
-    protected final Object value;
+    private final Transformer<? super K, ? extends V> value;
 
     //-----------------------------------------------------------------------
     /**
@@ -83,11 +81,8 @@ public class DefaultedMap
      * @param defaultValue  the default value to return when the key is not 
found
      * @throws IllegalArgumentException if map is null
      */
-    public static Map decorate(Map map, Object defaultValue) {
-        if (defaultValue instanceof Transformer) {
-            defaultValue = ConstantTransformer.getInstance(defaultValue);
-        }
-        return new DefaultedMap(map, defaultValue);
+    public static <K, V> Map<K, V> decorate(Map<K, V> map, V defaultValue) {
+        return new DefaultedMap<K, V>(map, 
ConstantTransformer.getInstance(defaultValue));
     }
 
     /**
@@ -100,11 +95,11 @@ public class DefaultedMap
      * @param factory  the factory to use to create entries, must not be null
      * @throws IllegalArgumentException if map or factory is null
      */
-    public static Map decorate(Map map, Factory factory) {
+    public static <K, V> Map<K, V> decorate(Map<K, V> map, Factory<? extends 
V> factory) {
         if (factory == null) {
             throw new IllegalArgumentException("Factory must not be null");
         }
-        return new DefaultedMap(map, FactoryTransformer.getInstance(factory));
+        return new DefaultedMap<K, V>(map, 
FactoryTransformer.getInstance(factory));
     }
 
     /**
@@ -118,11 +113,11 @@ public class DefaultedMap
      * @param transformer  the transformer to use as a factory to create 
entries, must not be null
      * @throws IllegalArgumentException if map or factory is null
      */
-    public static Map decorate(Map map, Transformer transformer) {
+    public static <K, V> Map<K, V> decorate(Map<K, V> map, Transformer<? super 
K, ? extends V> transformer) {
         if (transformer == null) {
            throw new IllegalArgumentException("Transformer must not be null");
        }
-       return new DefaultedMap(map, transformer);
+       return new DefaultedMap<K, V>(map, transformer);
     }
 
     //-----------------------------------------------------------------------
@@ -135,12 +130,18 @@ public class DefaultedMap
      * 
      * @param defaultValue  the default value to return when the key is not 
found
      */
-    public DefaultedMap(Object defaultValue) {
-        super(new HashMap());
-        if (defaultValue instanceof Transformer) {
-            defaultValue = ConstantTransformer.getInstance(defaultValue);
-        }
-        this.value = defaultValue;
+    public DefaultedMap(V defaultValue) {
+        this(ConstantTransformer.getInstance(defaultValue));
+    }
+
+    /**
+     * Constructs a new empty <code>DefaultedMap</code> that decorates
+     * a <code>HashMap</code>.
+     * <p>
+     * @param defaultValueTransformer transformer to use to generate missing 
values.
+     */
+    public DefaultedMap(Transformer<? super K, ? extends V> 
defaultValueTransformer) {
+        this(new HashMap<K, V>(), defaultValueTransformer);
     }
 
     /**
@@ -150,9 +151,9 @@ public class DefaultedMap
      * @param value  the value to use
      * @throws IllegalArgumentException if map or transformer is null
      */
-    protected DefaultedMap(Map map, Object value) {
+    protected DefaultedMap(Map<K, V> map, Transformer<? super K, ? extends V> 
defaultValueTransformer) {
         super(map);
-        this.value = value;
+        this.value = defaultValueTransformer;
     }
 
     //-----------------------------------------------------------------------
@@ -174,19 +175,18 @@ public class DefaultedMap
      * @throws IOException
      * @throws ClassNotFoundException
      */
+    @SuppressWarnings("unchecked")
     private void readObject(ObjectInputStream in) throws IOException, 
ClassNotFoundException {
         in.defaultReadObject();
         map = (Map) in.readObject();
     }
 
     //-----------------------------------------------------------------------
-    public Object get(Object key) {
+    @SuppressWarnings("unchecked")
+    public V get(Object key) {
         // create value for key if key is not currently in the map
         if (map.containsKey(key) == false) {
-            if (value instanceof Transformer) {
-                return ((Transformer) value).transform(key);
-            }
-            return value;
+            return value.transform((K) key);
         }
         return map.get(key);
     }

http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/java/org/apache/commons/collections/map/FixedSizeMap.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/commons/collections/map/FixedSizeMap.java 
b/src/java/org/apache/commons/collections/map/FixedSizeMap.java
index 2947f15..6c4ab3f 100644
--- a/src/java/org/apache/commons/collections/map/FixedSizeMap.java
+++ b/src/java/org/apache/commons/collections/map/FixedSizeMap.java
@@ -21,7 +21,6 @@ import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.io.Serializable;
 import java.util.Collection;
-import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 
@@ -56,9 +55,9 @@ import org.apache.commons.collections.set.UnmodifiableSet;
  * @author Stephen Colebourne
  * @author Paul Jack
  */
-public class FixedSizeMap
-        extends AbstractMapDecorator
-        implements Map, BoundedMap, Serializable {
+public class FixedSizeMap<K, V>
+        extends AbstractMapDecorator<K, V>
+        implements Map<K, V>, BoundedMap<K, V>, Serializable {
 
     /** Serialization version */
     private static final long serialVersionUID = 7450927208116179316L;
@@ -69,8 +68,8 @@ public class FixedSizeMap
      * @param map  the map to decorate, must not be null
      * @throws IllegalArgumentException if map is null
      */
-    public static Map decorate(Map map) {
-        return new FixedSizeMap(map);
+    public static <K, V> Map<K, V> decorate(Map<K, V> map) {
+        return new FixedSizeMap<K, V>(map);
     }
 
     //-----------------------------------------------------------------------
@@ -80,7 +79,7 @@ public class FixedSizeMap
      * @param map  the map to decorate, must not be null
      * @throws IllegalArgumentException if map is null
      */
-    protected FixedSizeMap(Map map) {
+    protected FixedSizeMap(Map<K, V> map) {
         super(map);
     }
 
@@ -105,22 +104,23 @@ public class FixedSizeMap
      * @throws ClassNotFoundException
      * @since Commons Collections 3.1
      */
+    @SuppressWarnings("unchecked")
     private void readObject(ObjectInputStream in) throws IOException, 
ClassNotFoundException {
         in.defaultReadObject();
         map = (Map) in.readObject();
     }
 
     //-----------------------------------------------------------------------
-    public Object put(Object key, Object value) {
+    public V put(K key, V value) {
         if (map.containsKey(key) == false) {
             throw new IllegalArgumentException("Cannot put new key/value pair 
- Map is fixed size");
         }
         return map.put(key, value);
     }
 
-    public void putAll(Map mapToCopy) {
-        for (Iterator it = mapToCopy.keySet().iterator(); it.hasNext(); ) {
-            if (mapToCopy.containsKey(it.next()) == false) {
+    public void putAll(Map<? extends K, ? extends V> mapToCopy) {
+        for (K key : mapToCopy.keySet()) {
+            if (!containsKey(key)) {
                 throw new IllegalArgumentException("Cannot put new key/value 
pair - Map is fixed size");
             }
         }
@@ -131,23 +131,23 @@ public class FixedSizeMap
         throw new UnsupportedOperationException("Map is fixed size");
     }
 
-    public Object remove(Object key) {
+    public V remove(Object key) {
         throw new UnsupportedOperationException("Map is fixed size");
     }
 
-    public Set entrySet() {
-        Set set = map.entrySet();
+    public Set<Map.Entry<K, V>> entrySet() {
+        Set<Map.Entry<K, V>> set = map.entrySet();
         // unmodifiable set will still allow modification via Map.Entry objects
         return UnmodifiableSet.decorate(set);
     }
 
-    public Set keySet() {
-        Set set = map.keySet();
+    public Set<K> keySet() {
+        Set<K> set = map.keySet();
         return UnmodifiableSet.decorate(set);
     }
 
-    public Collection values() {
-        Collection coll = map.values();
+    public Collection<V> values() {
+        Collection<V> coll = map.values();
         return UnmodifiableCollection.decorate(coll);
     }
 
@@ -158,5 +158,5 @@ public class FixedSizeMap
     public int maxSize() {
         return size();
     }
-   
+
 }

http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/java/org/apache/commons/collections/map/FixedSizeSortedMap.java
----------------------------------------------------------------------
diff --git 
a/src/java/org/apache/commons/collections/map/FixedSizeSortedMap.java 
b/src/java/org/apache/commons/collections/map/FixedSizeSortedMap.java
index 7f48b60..eb50fb7 100644
--- a/src/java/org/apache/commons/collections/map/FixedSizeSortedMap.java
+++ b/src/java/org/apache/commons/collections/map/FixedSizeSortedMap.java
@@ -21,12 +21,12 @@ import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.io.Serializable;
 import java.util.Collection;
-import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 import java.util.SortedMap;
 
 import org.apache.commons.collections.BoundedMap;
+import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.collections.collection.UnmodifiableCollection;
 import org.apache.commons.collections.set.UnmodifiableSet;
 
@@ -57,9 +57,9 @@ import org.apache.commons.collections.set.UnmodifiableSet;
  * @author Stephen Colebourne
  * @author Paul Jack
  */
-public class FixedSizeSortedMap
-        extends AbstractSortedMapDecorator
-        implements SortedMap, BoundedMap, Serializable {
+public class FixedSizeSortedMap<K, V>
+        extends AbstractSortedMapDecorator<K, V>
+        implements SortedMap<K, V>, BoundedMap<K, V>, Serializable {
 
     /** Serialization version */
     private static final long serialVersionUID = 3126019624511683653L;
@@ -70,8 +70,8 @@ public class FixedSizeSortedMap
      * @param map  the map to decorate, must not be null
      * @throws IllegalArgumentException if map is null
      */
-    public static SortedMap decorate(SortedMap map) {
-        return new FixedSizeSortedMap(map);
+    public static <K, V> SortedMap<K, V> decorate(SortedMap<K, V> map) {
+        return new FixedSizeSortedMap<K, V>(map);
     }
 
     //-----------------------------------------------------------------------
@@ -81,7 +81,7 @@ public class FixedSizeSortedMap
      * @param map  the map to decorate, must not be null
      * @throws IllegalArgumentException if map is null
      */
-    protected FixedSizeSortedMap(SortedMap map) {
+    protected FixedSizeSortedMap(SortedMap<K, V> map) {
         super(map);
     }
 
@@ -90,8 +90,8 @@ public class FixedSizeSortedMap
      * 
      * @return the decorated map
      */
-    protected SortedMap getSortedMap() {
-        return (SortedMap) map;
+    protected SortedMap<K, V> getSortedMap() {
+        return (SortedMap<K, V>) map;
     }
 
     //-----------------------------------------------------------------------
@@ -106,24 +106,23 @@ public class FixedSizeSortedMap
     /**
      * Read the map in using a custom routine.
      */
+    @SuppressWarnings("unchecked")
     private void readObject(ObjectInputStream in) throws IOException, 
ClassNotFoundException {
         in.defaultReadObject();
         map = (Map) in.readObject();
     }
 
     //-----------------------------------------------------------------------
-    public Object put(Object key, Object value) {
+    public V put(K key, V value) {
         if (map.containsKey(key) == false) {
             throw new IllegalArgumentException("Cannot put new key/value pair 
- Map is fixed size");
         }
         return map.put(key, value);
     }
 
-    public void putAll(Map mapToCopy) {
-        for (Iterator it = mapToCopy.keySet().iterator(); it.hasNext(); ) {
-            if (mapToCopy.containsKey(it.next()) == false) {
-                throw new IllegalArgumentException("Cannot put new key/value 
pair - Map is fixed size");
-            }
+    public void putAll(Map<? extends K, ? extends V> mapToCopy) {
+        if (CollectionUtils.isSubCollection(mapToCopy.keySet(), keySet())) {
+            throw new IllegalArgumentException("Cannot put new key/value pair 
- Map is fixed size");
         }
         map.putAll(mapToCopy);
     }
@@ -132,39 +131,33 @@ public class FixedSizeSortedMap
         throw new UnsupportedOperationException("Map is fixed size");
     }
 
-    public Object remove(Object key) {
+    public V remove(Object key) {
         throw new UnsupportedOperationException("Map is fixed size");
     }
 
-    public Set entrySet() {
-        Set set = map.entrySet();
-        return UnmodifiableSet.decorate(set);
+    public Set<Map.Entry<K, V>> entrySet() {
+        return UnmodifiableSet.decorate(map.entrySet());
     }
 
-    public Set keySet() {
-        Set set = map.keySet();
-        return UnmodifiableSet.decorate(set);
+    public Set<K> keySet() {
+        return UnmodifiableSet.decorate(map.keySet());
     }
 
-    public Collection values() {
-        Collection coll = map.values();
-        return UnmodifiableCollection.decorate(coll);
+    public Collection<V> values() {
+        return UnmodifiableCollection.decorate(map.values());
     }
 
     //-----------------------------------------------------------------------
-    public SortedMap subMap(Object fromKey, Object toKey) {
-        SortedMap map = getSortedMap().subMap(fromKey, toKey);
-        return new FixedSizeSortedMap(map);
+    public SortedMap<K, V> subMap(K fromKey, K toKey) {
+        return new FixedSizeSortedMap<K, V>(getSortedMap().subMap(fromKey, 
toKey));
     }
 
-    public SortedMap headMap(Object toKey) {
-        SortedMap map = getSortedMap().headMap(toKey);
-        return new FixedSizeSortedMap(map);
+    public SortedMap<K, V> headMap(K toKey) {
+        return new FixedSizeSortedMap<K, V>(getSortedMap().headMap(toKey));
     }
 
-    public SortedMap tailMap(Object fromKey) {
-        SortedMap map = getSortedMap().tailMap(fromKey);
-        return new FixedSizeSortedMap(map);
+    public SortedMap<K, V> tailMap(K fromKey) {
+        return new FixedSizeSortedMap<K, V>(getSortedMap().tailMap(fromKey));
     }
 
     public boolean isFull() {

http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/java/org/apache/commons/collections/map/Flat3Map.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/commons/collections/map/Flat3Map.java 
b/src/java/org/apache/commons/collections/map/Flat3Map.java
index 5759a73..b371092 100644
--- a/src/java/org/apache/commons/collections/map/Flat3Map.java
+++ b/src/java/org/apache/commons/collections/map/Flat3Map.java
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -64,7 +64,7 @@ import 
org.apache.commons.collections.iterators.EmptyMapIterator;
  * <strong>Note that Flat3Map is not synchronized and is not 
thread-safe.</strong>
  * If you wish to use this map from multiple threads concurrently, you must use
  * appropriate synchronization. The simplest approach is to wrap this map
- * using {@link java.util.Collections#synchronizedMap(Map)}. This class may 
throw 
+ * using {@link java.util.Collections#synchronizedMap(Map)}. This class may 
throw
  * exceptions when accessed by concurrent threads without synchronization.
  *
  * @since Commons Collections 3.0
@@ -72,7 +72,7 @@ import 
org.apache.commons.collections.iterators.EmptyMapIterator;
  *
  * @author Stephen Colebourne
  */
-public class Flat3Map implements IterableMap, Serializable, Cloneable {
+public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, 
Cloneable {
 
     /** Serialization version */
     private static final long serialVersionUID = -6701087419741928296L;
@@ -86,19 +86,19 @@ public class Flat3Map implements IterableMap, Serializable, 
Cloneable {
     /** Hash, used while in flat mode */
     private transient int hash3;
     /** Key, used while in flat mode */
-    private transient Object key1;
+    private transient K key1;
     /** Key, used while in flat mode */
-    private transient Object key2;
+    private transient K key2;
     /** Key, used while in flat mode */
-    private transient Object key3;
+    private transient K key3;
     /** Value, used while in flat mode */
-    private transient Object value1;
+    private transient V value1;
     /** Value, used while in flat mode */
-    private transient Object value2;
+    private transient V value2;
     /** Value, used while in flat mode */
-    private transient Object value3;
+    private transient V value3;
     /** Map, used while in delegate mode */
-    private transient AbstractHashedMap delegateMap;
+    private transient AbstractHashedMap<K, V> delegateMap;
 
     /**
      * Constructor.
@@ -113,7 +113,7 @@ public class Flat3Map implements IterableMap, Serializable, 
Cloneable {
      * @param map  the map to copy
      * @throws NullPointerException if the map is null
      */
-    public Flat3Map(Map map) {
+    public Flat3Map(Map<? extends K, ? extends V> map) {
         super();
         putAll(map);
     }
@@ -121,11 +121,11 @@ public class Flat3Map implements IterableMap, 
Serializable, Cloneable {
     //-----------------------------------------------------------------------
     /**
      * Gets the value mapped to the key specified.
-     * 
+     *
      * @param key  the key
      * @return the mapped value, null if no match
      */
-    public Object get(Object key) {
+    public V get(Object key) {
         if (delegateMap != null) {
             return delegateMap.get(key);
         }
@@ -158,7 +158,7 @@ public class Flat3Map implements IterableMap, Serializable, 
Cloneable {
 
     /**
      * Gets the size of the map.
-     * 
+     *
      * @return the size
      */
     public int size() {
@@ -170,7 +170,7 @@ public class Flat3Map implements IterableMap, Serializable, 
Cloneable {
 
     /**
      * Checks whether the map is currently empty.
-     * 
+     *
      * @return true if the map is currently size zero
      */
     public boolean isEmpty() {
@@ -180,7 +180,7 @@ public class Flat3Map implements IterableMap, Serializable, 
Cloneable {
     //-----------------------------------------------------------------------
     /**
      * Checks whether the map contains the specified key.
-     * 
+     *
      * @param key  the key to search for
      * @return true if the map contains the key
      */
@@ -215,7 +215,7 @@ public class Flat3Map implements IterableMap, Serializable, 
Cloneable {
 
     /**
      * Checks whether the map contains the specified value.
-     * 
+     *
      * @param value  the value to search for
      * @return true if the map contains the key
      */
@@ -248,12 +248,12 @@ public class Flat3Map implements IterableMap, 
Serializable, Cloneable {
     //-----------------------------------------------------------------------
     /**
      * Puts a key-value mapping into this map.
-     * 
+     *
      * @param key  the key to add
      * @param value  the value to add
      * @return the value previously mapped to this key, null if none
      */
-    public Object put(Object key, Object value) {
+    public V put(K key, V value) {
         if (delegateMap != null) {
             return delegateMap.put(key, value);
         }
@@ -262,19 +262,19 @@ public class Flat3Map implements IterableMap, 
Serializable, Cloneable {
             switch (size) {  // drop through
                 case 3:
                     if (key3 == null) {
-                        Object old = value3;
+                        V old = value3;
                         value3 = value;
                         return old;
                     }
                 case 2:
                     if (key2 == null) {
-                        Object old = value2;
+                        V old = value2;
                         value2 = value;
                         return old;
                     }
                 case 1:
                     if (key1 == null) {
-                        Object old = value1;
+                        V old = value1;
                         value1 = value;
                         return old;
                     }
@@ -285,26 +285,26 @@ public class Flat3Map implements IterableMap, 
Serializable, Cloneable {
                 switch (size) {  // drop through
                     case 3:
                         if (hash3 == hashCode && key.equals(key3)) {
-                            Object old = value3;
+                            V old = value3;
                             value3 = value;
                             return old;
                         }
                     case 2:
                         if (hash2 == hashCode && key.equals(key2)) {
-                            Object old = value2;
+                            V old = value2;
                             value2 = value;
                             return old;
                         }
                     case 1:
                         if (hash1 == hashCode && key.equals(key1)) {
-                            Object old = value1;
+                            V old = value1;
                             value1 = value;
                             return old;
                         }
                 }
             }
         }
-        
+
         // add new mapping
         switch (size) {
             default:
@@ -333,11 +333,11 @@ public class Flat3Map implements IterableMap, 
Serializable, Cloneable {
 
     /**
      * Puts all the values from the specified map into this map.
-     * 
+     *
      * @param map  the map to add
      * @throws NullPointerException if the map is null
      */
-    public void putAll(Map map) {
+    public void putAll(Map<? extends K, ? extends V> map) {
         int size = map.size();
         if (size == 0) {
             return;
@@ -347,8 +347,7 @@ public class Flat3Map implements IterableMap, Serializable, 
Cloneable {
             return;
         }
         if (size < 4) {
-            for (Iterator it = map.entrySet().iterator(); it.hasNext();) {
-                Map.Entry entry = (Map.Entry) it.next();
+            for (Map.Entry<? extends K, ? extends V> entry : map.entrySet()) {
                 put(entry.getKey(), entry.getValue());
             }
         } else {
@@ -370,7 +369,7 @@ public class Flat3Map implements IterableMap, Serializable, 
Cloneable {
             case 1:
                 delegateMap.put(key1, value1);
         }
-        
+
         size = 0;
         hash1 = hash2 = hash3 = 0;
         key1 = key2 = key3 = null;
@@ -387,17 +386,17 @@ public class Flat3Map implements IterableMap, 
Serializable, Cloneable {
      * @return a new AbstractHashedMap or subclass
      * @since Commons Collections 3.1
      */
-    protected AbstractHashedMap createDelegateMap() {
-        return new HashedMap();
+    protected AbstractHashedMap<K, V> createDelegateMap() {
+        return new HashedMap<K, V>();
     }
 
     /**
      * Removes the specified mapping from this map.
-     * 
+     *
      * @param key  the mapping to remove
      * @return the value mapped to the removed key, null if key not in map
      */
-    public Object remove(Object key) {
+    public V remove(Object key) {
         if (delegateMap != null) {
             return delegateMap.remove(key);
         }
@@ -408,7 +407,7 @@ public class Flat3Map implements IterableMap, Serializable, 
Cloneable {
             switch (size) {  // drop through
                 case 3:
                     if (key3 == null) {
-                        Object old = value3;
+                        V old = value3;
                         hash3 = 0;
                         key3 = null;
                         value3 = null;
@@ -416,7 +415,7 @@ public class Flat3Map implements IterableMap, Serializable, 
Cloneable {
                         return old;
                     }
                     if (key2 == null) {
-                        Object old = value3;
+                        V old = value3;
                         hash2 = hash3;
                         key2 = key3;
                         value2 = value3;
@@ -427,7 +426,7 @@ public class Flat3Map implements IterableMap, Serializable, 
Cloneable {
                         return old;
                     }
                     if (key1 == null) {
-                        Object old = value3;
+                        V old = value3;
                         hash1 = hash3;
                         key1 = key3;
                         value1 = value3;
@@ -440,7 +439,7 @@ public class Flat3Map implements IterableMap, Serializable, 
Cloneable {
                     return null;
                 case 2:
                     if (key2 == null) {
-                        Object old = value2;
+                        V old = value2;
                         hash2 = 0;
                         key2 = null;
                         value2 = null;
@@ -448,7 +447,7 @@ public class Flat3Map implements IterableMap, Serializable, 
Cloneable {
                         return old;
                     }
                     if (key1 == null) {
-                        Object old = value2;
+                        V old = value2;
                         hash1 = hash2;
                         key1 = key2;
                         value1 = value2;
@@ -461,7 +460,7 @@ public class Flat3Map implements IterableMap, Serializable, 
Cloneable {
                     return null;
                 case 1:
                     if (key1 == null) {
-                        Object old = value1;
+                        V old = value1;
                         hash1 = 0;
                         key1 = null;
                         value1 = null;
@@ -475,7 +474,7 @@ public class Flat3Map implements IterableMap, Serializable, 
Cloneable {
                 switch (size) {  // drop through
                     case 3:
                         if (hash3 == hashCode && key.equals(key3)) {
-                            Object old = value3;
+                            V old = value3;
                             hash3 = 0;
                             key3 = null;
                             value3 = null;
@@ -483,7 +482,7 @@ public class Flat3Map implements IterableMap, Serializable, 
Cloneable {
                             return old;
                         }
                         if (hash2 == hashCode && key.equals(key2)) {
-                            Object old = value3;
+                            V old = value3;
                             hash2 = hash3;
                             key2 = key3;
                             value2 = value3;
@@ -494,7 +493,7 @@ public class Flat3Map implements IterableMap, Serializable, 
Cloneable {
                             return old;
                         }
                         if (hash1 == hashCode && key.equals(key1)) {
-                            Object old = value3;
+                            V old = value3;
                             hash1 = hash3;
                             key1 = key3;
                             value1 = value3;
@@ -507,7 +506,7 @@ public class Flat3Map implements IterableMap, Serializable, 
Cloneable {
                         return null;
                     case 2:
                         if (hash2 == hashCode && key.equals(key2)) {
-                            Object old = value2;
+                            V old = value2;
                             hash2 = 0;
                             key2 = null;
                             value2 = null;
@@ -515,7 +514,7 @@ public class Flat3Map implements IterableMap, Serializable, 
Cloneable {
                             return old;
                         }
                         if (hash1 == hashCode && key.equals(key1)) {
-                            Object old = value2;
+                            V old = value2;
                             hash1 = hash2;
                             key1 = key2;
                             value1 = value2;
@@ -528,7 +527,7 @@ public class Flat3Map implements IterableMap, Serializable, 
Cloneable {
                         return null;
                     case 1:
                         if (hash1 == hashCode && key.equals(key1)) {
-                            Object old = value1;
+                            V old = value1;
                             hash1 = 0;
                             key1 = null;
                             value1 = null;
@@ -566,28 +565,28 @@ public class Flat3Map implements IterableMap, 
Serializable, Cloneable {
      * methods to get the key and value, and set the value.
      * It avoids the need to create an entrySet/keySet/values object.
      * It also avoids creating the Map Entry object.
-     * 
+     *
      * @return the map iterator
      */
-    public MapIterator mapIterator() {
+    public MapIterator<K, V> mapIterator() {
         if (delegateMap != null) {
             return delegateMap.mapIterator();
         }
         if (size == 0) {
-            return EmptyMapIterator.INSTANCE;
+            return EmptyMapIterator.<K, V>getInstance();
         }
-        return new FlatMapIterator(this);
+        return new FlatMapIterator<K, V>(this);
     }
 
     /**
      * FlatMapIterator
      */
-    static class FlatMapIterator implements MapIterator, ResettableIterator {
-        private final Flat3Map parent;
+    static class FlatMapIterator<K, V> implements MapIterator<K, V>, 
ResettableIterator<K> {
+        private final Flat3Map<K, V> parent;
         private int nextIndex = 0;
         private boolean canRemove = false;
-        
-        FlatMapIterator(Flat3Map parent) {
+
+        FlatMapIterator(Flat3Map<K, V> parent) {
             super();
             this.parent = parent;
         }
@@ -596,7 +595,7 @@ public class Flat3Map implements IterableMap, Serializable, 
Cloneable {
             return (nextIndex < parent.size);
         }
 
-        public Object next() {
+        public K next() {
             if (hasNext() == false) {
                 throw new 
NoSuchElementException(AbstractHashedMap.NO_NEXT_ENTRY);
             }
@@ -614,7 +613,7 @@ public class Flat3Map implements IterableMap, Serializable, 
Cloneable {
             canRemove = false;
         }
 
-        public Object getKey() {
+        public K getKey() {
             if (canRemove == false) {
                 throw new 
IllegalStateException(AbstractHashedMap.GETKEY_INVALID);
             }
@@ -629,7 +628,7 @@ public class Flat3Map implements IterableMap, Serializable, 
Cloneable {
             throw new IllegalStateException("Invalid map index");
         }
 
-        public Object getValue() {
+        public V getValue() {
             if (canRemove == false) {
                 throw new 
IllegalStateException(AbstractHashedMap.GETVALUE_INVALID);
             }
@@ -644,13 +643,13 @@ public class Flat3Map implements IterableMap, 
Serializable, Cloneable {
             throw new IllegalStateException("Invalid map index");
         }
 
-        public Object setValue(Object value) {
+        public V setValue(V value) {
             if (canRemove == false) {
                 throw new 
IllegalStateException(AbstractHashedMap.SETVALUE_INVALID);
             }
-            Object old = getValue();
+            V old = getValue();
             switch (nextIndex) {
-                case 3: 
+                case 3:
                     parent.value3 = value;
                     break;
                 case 2:
@@ -662,44 +661,43 @@ public class Flat3Map implements IterableMap, 
Serializable, Cloneable {
             }
             return old;
         }
-        
+
         public void reset() {
             nextIndex = 0;
             canRemove = false;
         }
-        
+
         public String toString() {
             if (canRemove) {
                 return "Iterator[" + getKey() + "=" + getValue() + "]";
-            } else {
-                return "Iterator[]";
             }
+            return "Iterator[]";
         }
     }
-    
+
     /**
      * Gets the entrySet view of the map.
      * Changes made to the view affect this map.
-     * The Map Entry is not an independent object and changes as the 
+     * The Map Entry is not an independent object and changes as the
      * iterator progresses.
      * To simply iterate through the entries, use {@link #mapIterator()}.
-     * 
+     *
      * @return the entrySet view
      */
-    public Set entrySet() {
+    public Set<Map.Entry<K, V>> entrySet() {
         if (delegateMap != null) {
             return delegateMap.entrySet();
         }
-        return new EntrySet(this);
+        return new EntrySet<K, V>(this);
     }
-    
+
     /**
      * EntrySet
      */
-    static class EntrySet extends AbstractSet {
-        private final Flat3Map parent;
-        
-        EntrySet(Flat3Map parent) {
+    static class EntrySet<K, V> extends AbstractSet<Map.Entry<K, V>> {
+        private final Flat3Map<K, V> parent;
+
+        EntrySet(Flat3Map<K, V> parent) {
             super();
             this.parent = parent;
         }
@@ -707,43 +705,42 @@ public class Flat3Map implements IterableMap, 
Serializable, Cloneable {
         public int size() {
             return parent.size();
         }
-        
+
         public void clear() {
             parent.clear();
         }
-        
+
         public boolean remove(Object obj) {
             if (obj instanceof Map.Entry == false) {
                 return false;
             }
-            Map.Entry entry = (Map.Entry) obj;
+            Map.Entry<?, ?> entry = (Map.Entry<?, ?>) obj;
             Object key = entry.getKey();
             boolean result = parent.containsKey(key);
             parent.remove(key);
             return result;
         }
 
-        public Iterator iterator() {
+        public Iterator<Map.Entry<K, V>> iterator() {
             if (parent.delegateMap != null) {
                 return parent.delegateMap.entrySet().iterator();
             }
             if (parent.size() == 0) {
-                return EmptyIterator.INSTANCE;
+                return EmptyIterator.<Map.Entry<K, V>>getInstance();
             }
-            return new EntrySetIterator(parent);
+            return new EntrySetIterator<K, V>(parent);
         }
     }
 
-    /**
-     * EntrySetIterator and MapEntry
-     */
-    static class EntrySetIterator implements Iterator, Map.Entry {
-        private final Flat3Map parent;
+    static abstract class EntryIterator<K, V> implements Map.Entry<K, V> {
+        private final Flat3Map<K, V> parent;
         private int nextIndex = 0;
-        private boolean canRemove = false;
-        
-        EntrySetIterator(Flat3Map parent) {
-            super();
+        protected boolean canRemove = false;
+
+        /**
+         * Create a new Flat3Map.EntryIterator.
+         */
+        public EntryIterator(Flat3Map<K, V> parent) {
             this.parent = parent;
         }
 
@@ -751,7 +748,7 @@ public class Flat3Map implements IterableMap, Serializable, 
Cloneable {
             return (nextIndex < parent.size);
         }
 
-        public Object next() {
+        public Map.Entry<K, V> nextEntry() {
             if (hasNext() == false) {
                 throw new 
NoSuchElementException(AbstractHashedMap.NO_NEXT_ENTRY);
             }
@@ -769,7 +766,7 @@ public class Flat3Map implements IterableMap, Serializable, 
Cloneable {
             canRemove = false;
         }
 
-        public Object getKey() {
+        public K getKey() {
             if (canRemove == false) {
                 throw new 
IllegalStateException(AbstractHashedMap.GETKEY_INVALID);
             }
@@ -784,7 +781,7 @@ public class Flat3Map implements IterableMap, Serializable, 
Cloneable {
             throw new IllegalStateException("Invalid map index");
         }
 
-        public Object getValue() {
+        public V getValue() {
             if (canRemove == false) {
                 throw new 
IllegalStateException(AbstractHashedMap.GETVALUE_INVALID);
             }
@@ -799,13 +796,13 @@ public class Flat3Map implements IterableMap, 
Serializable, Cloneable {
             throw new IllegalStateException("Invalid map index");
         }
 
-        public Object setValue(Object value) {
+        public V setValue(V value) {
             if (canRemove == false) {
                 throw new 
IllegalStateException(AbstractHashedMap.SETVALUE_INVALID);
             }
-            Object old = getValue();
+            V old = getValue();
             switch (nextIndex) {
-                case 3: 
+                case 3:
                     parent.value3 = value;
                     break;
                 case 2:
@@ -817,7 +814,21 @@ public class Flat3Map implements IterableMap, 
Serializable, Cloneable {
             }
             return old;
         }
-        
+    }
+
+    /**
+     * EntrySetIterator and MapEntry
+     */
+    static class EntrySetIterator<K, V> extends EntryIterator<K, V> implements 
Iterator<Map.Entry<K, V>> {
+
+        EntrySetIterator(Flat3Map<K, V> parent) {
+            super(parent);
+        }
+
+        public Map.Entry<K, V> next() {
+            return nextEntry();
+        }
+
         public boolean equals(Object obj) {
             if (canRemove == false) {
                 return false;
@@ -825,13 +836,13 @@ public class Flat3Map implements IterableMap, 
Serializable, Cloneable {
             if (obj instanceof Map.Entry == false) {
                 return false;
             }
-            Map.Entry other = (Map.Entry) obj;
+            Map.Entry<?, ?> other = (Map.Entry<?, ?>) obj;
             Object key = getKey();
             Object value = getValue();
             return (key == null ? other.getKey() == null : 
key.equals(other.getKey())) &&
                    (value == null ? other.getValue() == null : 
value.equals(other.getValue()));
         }
-        
+
         public int hashCode() {
             if (canRemove == false) {
                 return 0;
@@ -841,37 +852,36 @@ public class Flat3Map implements IterableMap, 
Serializable, Cloneable {
             return (key == null ? 0 : key.hashCode()) ^
                    (value == null ? 0 : value.hashCode());
         }
-        
+
         public String toString() {
             if (canRemove) {
                 return getKey() + "=" + getValue();
-            } else {
-                return "";
             }
+            return "";
         }
     }
-    
+
     /**
      * Gets the keySet view of the map.
      * Changes made to the view affect this map.
      * To simply iterate through the keys, use {@link #mapIterator()}.
-     * 
+     *
      * @return the keySet view
      */
-    public Set keySet() {
+    public Set<K> keySet() {
         if (delegateMap != null) {
             return delegateMap.keySet();
         }
-        return new KeySet(this);
+        return new KeySet<K>(this);
     }
 
     /**
      * KeySet
      */
-    static class KeySet extends AbstractSet {
-        private final Flat3Map parent;
-        
-        KeySet(Flat3Map parent) {
+    static class KeySet<K> extends AbstractSet<K> {
+        private final Flat3Map<K, ?> parent;
+
+        KeySet(Flat3Map<K, ?> parent) {
             super();
             this.parent = parent;
         }
@@ -879,11 +889,11 @@ public class Flat3Map implements IterableMap, 
Serializable, Cloneable {
         public int size() {
             return parent.size();
         }
-        
+
         public void clear() {
             parent.clear();
         }
-        
+
         public boolean contains(Object key) {
             return parent.containsKey(key);
         }
@@ -894,53 +904,54 @@ public class Flat3Map implements IterableMap, 
Serializable, Cloneable {
             return result;
         }
 
-        public Iterator iterator() {
+        public Iterator<K> iterator() {
             if (parent.delegateMap != null) {
                 return parent.delegateMap.keySet().iterator();
             }
             if (parent.size() == 0) {
-                return EmptyIterator.INSTANCE;
+                return EmptyIterator.<K>getInstance();
             }
-            return new KeySetIterator(parent);
+            return new KeySetIterator<K>(parent);
         }
     }
 
     /**
      * KeySetIterator
      */
-    static class KeySetIterator extends EntrySetIterator {
-        
-        KeySetIterator(Flat3Map parent) {
-            super(parent);
+    static class KeySetIterator<K> extends EntryIterator<K, Object> implements 
Iterator<K>{
+
+        @SuppressWarnings("unchecked")
+        KeySetIterator(Flat3Map<K, ?> parent) {
+            super((Flat3Map<K, Object>) parent);
         }
 
-        public Object next() {
-            super.next();
+        public K next() {
+            nextEntry();
             return getKey();
         }
     }
-    
+
     /**
      * Gets the values view of the map.
      * Changes made to the view affect this map.
      * To simply iterate through the values, use {@link #mapIterator()}.
-     * 
+     *
      * @return the values view
      */
-    public Collection values() {
+    public Collection<V> values() {
         if (delegateMap != null) {
             return delegateMap.values();
         }
-        return new Values(this);
+        return new Values<V>(this);
     }
 
     /**
      * Values
      */
-    static class Values extends AbstractCollection {
-        private final Flat3Map parent;
-        
-        Values(Flat3Map parent) {
+    static class Values<V> extends AbstractCollection<V> {
+        private final Flat3Map<?, V> parent;
+
+        Values(Flat3Map<?, V> parent) {
             super();
             this.parent = parent;
         }
@@ -948,37 +959,38 @@ public class Flat3Map implements IterableMap, 
Serializable, Cloneable {
         public int size() {
             return parent.size();
         }
-        
+
         public void clear() {
             parent.clear();
         }
-        
+
         public boolean contains(Object value) {
             return parent.containsValue(value);
         }
 
-        public Iterator iterator() {
+        public Iterator<V> iterator() {
             if (parent.delegateMap != null) {
                 return parent.delegateMap.values().iterator();
             }
             if (parent.size() == 0) {
-                return EmptyIterator.INSTANCE;
+                return EmptyIterator.<V>getInstance();
             }
-            return new ValuesIterator(parent);
+            return new ValuesIterator<V>(parent);
         }
     }
 
     /**
      * ValuesIterator
      */
-    static class ValuesIterator extends EntrySetIterator {
-        
-        ValuesIterator(Flat3Map parent) {
-            super(parent);
+    static class ValuesIterator<V> extends EntryIterator<Object, V> implements 
Iterator<V> {
+
+        @SuppressWarnings("unchecked")
+        ValuesIterator(Flat3Map<?, V> parent) {
+            super((Flat3Map<Object, V>) parent);
         }
 
-        public Object next() {
-            super.next();
+        public V next() {
+            nextEntry();
             return getValue();
         }
     }
@@ -990,7 +1002,7 @@ public class Flat3Map implements IterableMap, 
Serializable, Cloneable {
     private void writeObject(ObjectOutputStream out) throws IOException {
         out.defaultWriteObject();
         out.writeInt(size());
-        for (MapIterator it = mapIterator(); it.hasNext();) {
+        for (MapIterator<?, ?> it = mapIterator(); it.hasNext();) {
             out.writeObject(it.next());  // key
             out.writeObject(it.getValue());  // value
         }
@@ -999,6 +1011,7 @@ public class Flat3Map implements IterableMap, 
Serializable, Cloneable {
     /**
      * Read the map in using a custom routine.
      */
+    @SuppressWarnings("unchecked")
     private void readObject(ObjectInputStream in) throws IOException, 
ClassNotFoundException {
         in.defaultReadObject();
         int count = in.readInt();
@@ -1006,7 +1019,7 @@ public class Flat3Map implements IterableMap, 
Serializable, Cloneable {
             delegateMap = createDelegateMap();
         }
         for (int i = count; i > 0; i--) {
-            put(in.readObject(), in.readObject());
+            put((K) in.readObject(), (V) in.readObject());
         }
     }
 
@@ -1017,11 +1030,12 @@ public class Flat3Map implements IterableMap, 
Serializable, Cloneable {
      * @return a shallow clone
      * @since Commons Collections 3.1
      */
-    public Object clone() {
+    @SuppressWarnings("unchecked")
+    public Flat3Map<K, V> clone() {
         try {
-            Flat3Map cloned = (Flat3Map) super.clone();
+            Flat3Map<K, V> cloned = (Flat3Map<K, V>) super.clone();
             if (cloned.delegateMap != null) {
-                cloned.delegateMap = (HashedMap) cloned.delegateMap.clone();
+                cloned.delegateMap = (HashedMap<K, V>) 
cloned.delegateMap.clone();
             }
             return cloned;
         } catch (CloneNotSupportedException ex) {
@@ -1031,7 +1045,7 @@ public class Flat3Map implements IterableMap, 
Serializable, Cloneable {
 
     /**
      * Compares this map with another.
-     * 
+     *
      * @param obj  the object to compare to
      * @return true if equal
      */
@@ -1045,7 +1059,7 @@ public class Flat3Map implements IterableMap, 
Serializable, Cloneable {
         if (obj instanceof Map == false) {
             return false;
         }
-        Map other = (Map) obj;
+        Map<?, ?> other = (Map<?, ?>) obj;
         if (size != other.size()) {
             return false;
         }
@@ -1083,7 +1097,7 @@ public class Flat3Map implements IterableMap, 
Serializable, Cloneable {
 
     /**
      * Gets the standard Map hashCode.
-     * 
+     *
      * @return the hash code defined in the Map interface
      */
     public int hashCode() {
@@ -1104,7 +1118,7 @@ public class Flat3Map implements IterableMap, 
Serializable, Cloneable {
 
     /**
      * Gets the map as a String.
-     * 
+     *
      * @return a string version of the map
      */
     public String toString() {

http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/java/org/apache/commons/collections/map/HashedMap.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/commons/collections/map/HashedMap.java 
b/src/java/org/apache/commons/collections/map/HashedMap.java
index dd491f0..c880ea7 100644
--- a/src/java/org/apache/commons/collections/map/HashedMap.java
+++ b/src/java/org/apache/commons/collections/map/HashedMap.java
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -26,14 +26,14 @@ import java.util.Map;
  * A <code>Map</code> implementation that is a general purpose alternative
  * to <code>HashMap</code>.
  * <p>
- * This implementation improves on the JDK1.4 HashMap by adding the 
+ * This implementation improves on the JDK1.4 HashMap by adding the
  * {@link org.apache.commons.collections.MapIterator MapIterator}
  * functionality and many methods for subclassing.
  * <p>
  * <strong>Note that HashedMap is not synchronized and is not 
thread-safe.</strong>
  * If you wish to use this map from multiple threads concurrently, you must use
  * appropriate synchronization. The simplest approach is to wrap this map
- * using {@link java.util.Collections#synchronizedMap(Map)}. This class may 
throw 
+ * using {@link java.util.Collections#synchronizedMap(Map)}. This class may 
throw
  * exceptions when accessed by concurrent threads without synchronization.
  *
  * @since Commons Collections 3.0
@@ -41,12 +41,12 @@ import java.util.Map;
  *
  * @author Stephen Colebourne
  */
-public class HashedMap
-        extends AbstractHashedMap implements Serializable, Cloneable {
+public class HashedMap<K, V>
+        extends AbstractHashedMap<K, V> implements Serializable, Cloneable {
 
     /** Serialisation version */
     private static final long serialVersionUID = -1788199231038721040L;
-    
+
     /**
      * Constructs a new empty map with default size and load factor.
      */
@@ -55,7 +55,7 @@ public class HashedMap
     }
 
     /**
-     * Constructs a new, empty map with the specified initial capacity. 
+     * Constructs a new, empty map with the specified initial capacity.
      *
      * @param initialCapacity  the initial capacity
      * @throws IllegalArgumentException if the initial capacity is less than 
one
@@ -66,7 +66,7 @@ public class HashedMap
 
     /**
      * Constructs a new, empty map with the specified initial capacity and
-     * load factor. 
+     * load factor.
      *
      * @param initialCapacity  the initial capacity
      * @param loadFactor  the load factor
@@ -83,7 +83,7 @@ public class HashedMap
      * @param map  the map to copy
      * @throws NullPointerException if the map is null
      */
-    public HashedMap(Map map) {
+    public HashedMap(Map<K, V> map) {
         super(map);
     }
 
@@ -93,10 +93,10 @@ public class HashedMap
      *
      * @return a shallow clone
      */
-    public Object clone() {
-        return super.clone();
+    public HashedMap<K, V> clone() {
+        return (HashedMap<K, V>) super.clone();
     }
-    
+
     /**
      * Write the map out using a custom routine.
      */
@@ -112,5 +112,5 @@ public class HashedMap
         in.defaultReadObject();
         doReadObject(in);
     }
-    
+
 }

http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/java/org/apache/commons/collections/map/IdentityMap.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/commons/collections/map/IdentityMap.java 
b/src/java/org/apache/commons/collections/map/IdentityMap.java
index afefdc1..abf563e 100644
--- a/src/java/org/apache/commons/collections/map/IdentityMap.java
+++ b/src/java/org/apache/commons/collections/map/IdentityMap.java
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -32,7 +32,7 @@ import java.util.Map;
  * <strong>Note that IdentityMap is not synchronized and is not 
thread-safe.</strong>
  * If you wish to use this map from multiple threads concurrently, you must use
  * appropriate synchronization. The simplest approach is to wrap this map
- * using {@link java.util.Collections#synchronizedMap(Map)}. This class may 
throw 
+ * using {@link java.util.Collections#synchronizedMap(Map)}. This class may 
throw
  * exceptions when accessed by concurrent threads without synchronization.
  *
  * @since Commons Collections 3.0
@@ -41,8 +41,8 @@ import java.util.Map;
  * @author java util HashMap
  * @author Stephen Colebourne
  */
-public class IdentityMap
-        extends AbstractHashedMap implements Serializable, Cloneable {
+public class IdentityMap<K, V>
+        extends AbstractHashedMap<K, V> implements Serializable, Cloneable {
 
     /** Serialisation version */
     private static final long serialVersionUID = 2028493495224302329L;
@@ -55,7 +55,7 @@ public class IdentityMap
     }
 
     /**
-     * Constructs a new, empty map with the specified initial capacity. 
+     * Constructs a new, empty map with the specified initial capacity.
      *
      * @param initialCapacity  the initial capacity
      * @throws IllegalArgumentException if the initial capacity is less than 
one
@@ -66,7 +66,7 @@ public class IdentityMap
 
     /**
      * Constructs a new, empty map with the specified initial capacity and
-     * load factor. 
+     * load factor.
      *
      * @param initialCapacity  the initial capacity
      * @param loadFactor  the load factor
@@ -83,7 +83,7 @@ public class IdentityMap
      * @param map  the map to copy
      * @throws NullPointerException if the map is null
      */
-    public IdentityMap(Map map) {
+    public IdentityMap(Map<K, V> map) {
         super(map);
     }
 
@@ -91,18 +91,18 @@ public class IdentityMap
     /**
      * Gets the hash code for the key specified.
      * This implementation uses the identity hash code.
-     * 
+     *
      * @param key  the key to get a hash code for
      * @return the hash code
      */
     protected int hash(Object key) {
         return System.identityHashCode(key);
     }
-    
+
     /**
      * Compares two keys for equals.
      * This implementation uses <code>==</code>.
-     * 
+     *
      * @param key1  the first key to compare
      * @param key2  the second key to compare
      * @return true if equal by identity
@@ -110,11 +110,11 @@ public class IdentityMap
     protected boolean isEqualKey(Object key1, Object key2) {
         return (key1 == key2);
     }
-    
+
     /**
      * Compares two values for equals.
      * This implementation uses <code>==</code>.
-     * 
+     *
      * @param value1  the first value to compare
      * @param value2  the second value to compare
      * @return true if equal by identity
@@ -122,31 +122,31 @@ public class IdentityMap
     protected boolean isEqualValue(Object value1, Object value2) {
         return (value1 == value2);
     }
-    
+
     /**
      * Creates an entry to store the data.
      * This implementation creates an IdentityEntry instance.
-     * 
+     *
      * @param next  the next entry in sequence
      * @param hashCode  the hash code to use
      * @param key  the key to store
      * @param value  the value to store
      * @return the newly created entry
      */
-    protected HashEntry createEntry(HashEntry next, int hashCode, Object key, 
Object value) {
-        return new IdentityEntry(next, hashCode, key, value);
+    protected IdentityEntry<K, V> createEntry(HashEntry<K, V> next, int 
hashCode, K key, V value) {
+        return new IdentityEntry<K, V>(next, hashCode, key, value);
     }
-    
+
     //-----------------------------------------------------------------------
     /**
      * HashEntry
      */
-    protected static class IdentityEntry extends HashEntry {
-        
-        protected IdentityEntry(HashEntry next, int hashCode, Object key, 
Object value) {
+    protected static class IdentityEntry<K, V> extends HashEntry<K, V> {
+
+        protected IdentityEntry(HashEntry<K, V> next, int hashCode, K key, V 
value) {
             super(next, hashCode, key, value);
         }
-        
+
         public boolean equals(Object obj) {
             if (obj == this) {
                 return true;
@@ -154,28 +154,28 @@ public class IdentityMap
             if (obj instanceof Map.Entry == false) {
                 return false;
             }
-            Map.Entry other = (Map.Entry) obj;
+            Map.Entry<?, ?> other = (Map.Entry<?, ?>) obj;
             return
                 (getKey() == other.getKey()) &&
                 (getValue() == other.getValue());
         }
-        
+
         public int hashCode() {
             return System.identityHashCode(getKey()) ^
                    System.identityHashCode(getValue());
         }
     }
-    
+
     //-----------------------------------------------------------------------
     /**
      * Clones the map without cloning the keys or values.
      *
      * @return a shallow clone
      */
-    public Object clone() {
-        return super.clone();
+    public IdentityMap<K, V> clone() {
+        return (IdentityMap<K, V>) super.clone();
     }
-    
+
     /**
      * Write the map out using a custom routine.
      */
@@ -191,5 +191,5 @@ public class IdentityMap
         in.defaultReadObject();
         doReadObject(in);
     }
-    
+
 }

http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/java/org/apache/commons/collections/map/LRUMap.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/commons/collections/map/LRUMap.java 
b/src/java/org/apache/commons/collections/map/LRUMap.java
index 9b121a9..f4a0255 100644
--- a/src/java/org/apache/commons/collections/map/LRUMap.java
+++ b/src/java/org/apache/commons/collections/map/LRUMap.java
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -35,7 +35,7 @@ import org.apache.commons.collections.BoundedMap;
  * <p>
  * The map implements <code>OrderedMap</code> and entries may be queried using
  * the bidirectional <code>OrderedMapIterator</code>. The order returned is
- * least recently used to most recently used. Iterators from map views can 
+ * least recently used to most recently used. Iterators from map views can
  * also be cast to <code>OrderedIterator</code> if required.
  * <p>
  * All the available iterators can be reset back to the start by casting to
@@ -44,7 +44,7 @@ import org.apache.commons.collections.BoundedMap;
  * <strong>Note that LRUMap is not synchronized and is not 
thread-safe.</strong>
  * If you wish to use this map from multiple threads concurrently, you must use
  * appropriate synchronization. The simplest approach is to wrap this map
- * using {@link java.util.Collections#synchronizedMap(Map)}. This class may 
throw 
+ * using {@link java.util.Collections#synchronizedMap(Map)}. This class may 
throw
  * <code>NullPointerException</code>'s when accessed by concurrent threads.
  *
  * @since Commons Collections 3.0 (previously in main package v1.0)
@@ -56,14 +56,14 @@ import org.apache.commons.collections.BoundedMap;
  * @author Mike Pettypiece
  * @author Mario Ivankovits
  */
-public class LRUMap
-        extends AbstractLinkedMap implements BoundedMap, Serializable, 
Cloneable {
-    
+public class LRUMap<K, V>
+        extends AbstractLinkedMap<K, V> implements BoundedMap<K, V>, 
Serializable, Cloneable {
+
     /** Serialisation version */
     private static final long serialVersionUID = -612114643488955218L;
     /** Default maximum size */
     protected static final int DEFAULT_MAX_SIZE = 100;
-    
+
     /** Maximum size */
     private transient int maxSize;
     /** Scan behaviour */
@@ -100,7 +100,7 @@ public class LRUMap
 
     /**
      * Constructs a new, empty map with the specified initial capacity and
-     * load factor. 
+     * load factor.
      *
      * @param maxSize  the maximum size of the map, -1 for no limit,
      * @param loadFactor  the load factor
@@ -140,7 +140,7 @@ public class LRUMap
      * @throws NullPointerException if the map is null
      * @throws IllegalArgumentException if the map is empty
      */
-    public LRUMap(Map map) {
+    public LRUMap(Map<K, V> map) {
         this(map, false);
     }
 
@@ -155,7 +155,7 @@ public class LRUMap
      * @throws IllegalArgumentException if the map is empty
      * @since Commons Collections 3.1
      */
-    public LRUMap(Map map, boolean scanUntilRemovable) {
+    public LRUMap(Map<K, V> map, boolean scanUntilRemovable) {
         this(map.size(), DEFAULT_LOAD_FACTOR, scanUntilRemovable);
         putAll(map);
     }
@@ -166,12 +166,12 @@ public class LRUMap
      * <p>
      * This operation changes the position of the key in the map to the
      * most recently used position (first).
-     * 
+     *
      * @param key  the key
      * @return the mapped value, null if no match
      */
-    public Object get(Object key) {
-        LinkEntry entry = (LinkEntry) getEntry(key);
+    public V get(Object key) {
+        LinkEntry<K, V> entry = getEntry(key);
         if (entry == null) {
             return null;
         }
@@ -184,10 +184,10 @@ public class LRUMap
      * Moves an entry to the MRU position at the end of the list.
      * <p>
      * This implementation moves the updated entry to the end of the list.
-     * 
+     *
      * @param entry  the entry to update
      */
-    protected void moveToMRU(LinkEntry entry) {
+    protected void moveToMRU(LinkEntry<K, V> entry) {
         if (entry.after != header) {
             modCount++;
             // remove
@@ -203,21 +203,21 @@ public class LRUMap
                 " (please report this to commons-...@jakarta.apache.org)");
         }
     }
-    
+
     /**
      * Updates an existing key-value mapping.
      * <p>
      * This implementation moves the updated entry to the top of the list
      * using {@link #moveToMRU(AbstractLinkedMap.LinkEntry)}.
-     * 
+     *
      * @param entry  the entry to update
      * @param newValue  the new value to store
      */
-    protected void updateEntry(HashEntry entry, Object newValue) {
-        moveToMRU((LinkEntry) entry);  // handles modCount
+    protected void updateEntry(HashEntry<K, V> entry, V newValue) {
+        moveToMRU((LinkEntry<K, V>) entry);  // handles modCount
         entry.setValue(newValue);
     }
-    
+
     /**
      * Adds a new key-value mapping into this map.
      * <p>
@@ -227,15 +227,15 @@ public class LRUMap
      * From Commons Collections 3.1 this method uses {@link #isFull()} rather
      * than accessing <code>size</code> and <code>maxSize</code> directly.
      * It also handles the scanUntilRemovable functionality.
-     * 
+     *
      * @param hashIndex  the index into the data array to store at
      * @param hashCode  the hash code of the key to add
      * @param key  the key to add
      * @param value  the value to add
      */
-    protected void addMapping(int hashIndex, int hashCode, Object key, Object 
value) {
+    protected void addMapping(int hashIndex, int hashCode, K key, V value) {
         if (isFull()) {
-            LinkEntry reuse = header.after;
+            LinkEntry<K, V> reuse = header.after;
             boolean removeLRUEntry = false;
             if (scanUntilRemovable) {
                 while (reuse != header && reuse != null) {
@@ -255,7 +255,7 @@ public class LRUMap
             } else {
                 removeLRUEntry = removeLRU(reuse);
             }
-            
+
             if (removeLRUEntry) {
                 if (reuse == null) {
                     throw new IllegalStateException(
@@ -272,27 +272,27 @@ public class LRUMap
             super.addMapping(hashIndex, hashCode, key, value);
         }
     }
-    
+
     /**
      * Reuses an entry by removing it and moving it to a new place in the map.
      * <p>
      * This method uses {@link #removeEntry}, {@link #reuseEntry} and {@link 
#addEntry}.
-     * 
+     *
      * @param entry  the entry to reuse
      * @param hashIndex  the index into the data array to store at
      * @param hashCode  the hash code of the key to add
      * @param key  the key to add
      * @param value  the value to add
      */
-    protected void reuseMapping(LinkEntry entry, int hashIndex, int hashCode, 
Object key, Object value) {
+    protected void reuseMapping(LinkEntry<K, V> entry, int hashIndex, int 
hashCode, K key, V value) {
         // find the entry before the entry specified in the hash table
         // remember that the parameters (except the first) refer to the new 
entry,
         // not the old one
         try {
             int removeIndex = hashIndex(entry.hashCode, data.length);
-            HashEntry[] tmp = data;  // may protect against some sync issues
-            HashEntry loop = tmp[removeIndex];
-            HashEntry previous = null;
+            HashEntry<K, V>[] tmp = data;  // may protect against some sync 
issues
+            HashEntry<K, V> loop = tmp[removeIndex];
+            HashEntry<K, V> previous = null;
             while (loop != entry && loop != null) {
                 previous = loop;
                 loop = loop.next;
@@ -304,7 +304,7 @@ public class LRUMap
                     " Please check that your keys are immutable, and that you 
have used synchronization properly." +
                     " If so, then please report this to 
commons-...@jakarta.apache.org as a bug.");
             }
-            
+
             // reuse the entry
             modCount++;
             removeEntry(entry, removeIndex, previous);
@@ -318,7 +318,7 @@ public class LRUMap
                     " If so, then please report this to 
commons-...@jakarta.apache.org as a bug.");
         }
     }
-    
+
     /**
      * Subclass method to control removal of the least recently used entry 
from the map.
      * <p>
@@ -349,10 +349,10 @@ public class LRUMap
      * <p>
      * NOTE: Commons Collections 3.0 passed the wrong entry to this method.
      * This is fixed in version 3.1 onwards.
-     * 
+     *
      * @param entry  the entry to be removed
      */
-    protected boolean removeLRU(LinkEntry entry) {
+    protected boolean removeLRU(LinkEntry<K, V> entry) {
         return true;
     }
 
@@ -392,10 +392,10 @@ public class LRUMap
      *
      * @return a shallow clone
      */
-    public Object clone() {
-        return super.clone();
+    public LRUMap<K, V> clone() {
+        return (LRUMap<K, V>) super.clone();
     }
-    
+
     /**
      * Write the map out using a custom routine.
      */
@@ -411,7 +411,7 @@ public class LRUMap
         in.defaultReadObject();
         doReadObject(in);
     }
-    
+
     /**
      * Writes the data necessary for <code>put()</code> to work in 
deserialization.
      */
@@ -427,5 +427,5 @@ public class LRUMap
         maxSize = in.readInt();
         super.doReadObject(in);
     }
-    
+
 }

http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/java/org/apache/commons/collections/map/LazyMap.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/commons/collections/map/LazyMap.java 
b/src/java/org/apache/commons/collections/map/LazyMap.java
index cccadfe..db0f565 100644
--- a/src/java/org/apache/commons/collections/map/LazyMap.java
+++ b/src/java/org/apache/commons/collections/map/LazyMap.java
@@ -62,9 +62,7 @@ import 
org.apache.commons.collections.functors.FactoryTransformer;
  * @author Stephen Colebourne
  * @author Paul Jack
  */
-public class LazyMap<K,V>
-        extends AbstractMapDecorator<K,V>
-        implements Map<K,V>, Serializable {
+public class LazyMap<K, V> extends AbstractMapDecorator<K, V> implements 
Map<K, V>, Serializable {
 
     /** Serialization version */
     private static final long serialVersionUID = 7990956402564206740L;

http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/java/org/apache/commons/collections/map/LinkedMap.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/commons/collections/map/LinkedMap.java 
b/src/java/org/apache/commons/collections/map/LinkedMap.java
index f9da823..d6479d5 100644
--- a/src/java/org/apache/commons/collections/map/LinkedMap.java
+++ b/src/java/org/apache/commons/collections/map/LinkedMap.java
@@ -62,8 +62,7 @@ import org.apache.commons.collections.list.UnmodifiableList;
  *
  * @author Stephen Colebourne
  */
-public class LinkedMap
-        extends AbstractLinkedMap implements Serializable, Cloneable {
+public class LinkedMap<K, V> extends AbstractLinkedMap<K, V> implements 
Serializable, Cloneable {
 
     /** Serialisation version */
     private static final long serialVersionUID = 9077234323521161066L;
@@ -104,7 +103,7 @@ public class LinkedMap
      * @param map  the map to copy
      * @throws NullPointerException if the map is null
      */
-    public LinkedMap(Map map) {
+    public LinkedMap(Map<K, V> map) {
         super(map);
     }
 
@@ -114,8 +113,8 @@ public class LinkedMap
      *
      * @return a shallow clone
      */
-    public Object clone() {
-        return super.clone();
+    public LinkedMap<K, V> clone() {
+        return (LinkedMap<K, V>) super.clone();
     }
     
     /**
@@ -142,7 +141,7 @@ public class LinkedMap
      * @return the key at the specified index
      * @throws IndexOutOfBoundsException if the index is invalid
      */
-    public Object get(int index) {
+    public K get(int index) {
         return getEntry(index).getKey();
     }
     
@@ -153,7 +152,7 @@ public class LinkedMap
      * @return the key at the specified index
      * @throws IndexOutOfBoundsException if the index is invalid
      */
-    public Object getValue(int index) {
+    public V getValue(int index) {
         return getEntry(index).getValue();
     }
     
@@ -166,7 +165,7 @@ public class LinkedMap
     public int indexOf(Object key) {
         key = convertKey(key);
         int i = 0;
-        for (LinkEntry entry = header.after; entry != header; entry = 
entry.after, i++) {
+        for (LinkEntry<K, V> entry = header.after; entry != header; entry = 
entry.after, i++) {
             if (isEqualKey(key, entry.key)) {
                 return i;
             }
@@ -182,7 +181,7 @@ public class LinkedMap
      *  or <code>null</code> if none existed
      * @throws IndexOutOfBoundsException if the index is invalid
      */
-    public Object remove(int index) {
+    public V remove(int index) {
         return remove(get(index));
     }
 
@@ -201,29 +200,29 @@ public class LinkedMap
      * @see #keySet()
      * @return The ordered list of keys.  
      */
-    public List asList() {
-        return new LinkedMapList(this);
+    public List<K> asList() {
+        return new LinkedMapList<K>(this);
     }
 
     /**
      * List view of map.
      */
-    static class LinkedMapList extends AbstractList {
-        
-        final LinkedMap parent;
-        
-        LinkedMapList(LinkedMap parent) {
+    static class LinkedMapList<K> extends AbstractList<K> {
+
+        final LinkedMap<K, ?> parent;
+
+        LinkedMapList(LinkedMap<K, ?> parent) {
             this.parent = parent;
         }
-        
+
         public int size() {
             return parent.size();
         }
-    
-        public Object get(int index) {
+
+        public K get(int index) {
             return parent.get(index);
         }
-        
+
         public boolean contains(Object obj) {
             return parent.containsKey(obj);
         }
@@ -231,58 +230,58 @@ public class LinkedMap
         public int indexOf(Object obj) {
             return parent.indexOf(obj);
         }
-        
+
         public int lastIndexOf(Object obj) {
             return parent.indexOf(obj);
         }
-        
-        public boolean containsAll(Collection coll) {
+
+        public boolean containsAll(Collection<?> coll) {
             return parent.keySet().containsAll(coll);
         }
-        
-        public Object remove(int index) {
+
+        public K remove(int index) {
             throw new UnsupportedOperationException();
         }
-        
+
         public boolean remove(Object obj) {
             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 void clear() {
             throw new UnsupportedOperationException();
         }
-        
+
         public Object[] toArray() {
             return parent.keySet().toArray();
         }
 
-        public Object[] toArray(Object[] array) {
+        public <T> T[] toArray(T[] array) {
             return parent.keySet().toArray(array);
         }
-        
-        public Iterator iterator() {
+
+        public Iterator<K> iterator() {
             return UnmodifiableIterator.decorate(parent.keySet().iterator());
         }
-        
-        public ListIterator listIterator() {
+
+        public ListIterator<K> listIterator() {
             return UnmodifiableListIterator.decorate(super.listIterator());
         }
-        
-        public ListIterator listIterator(int fromIndex) {
+
+        public ListIterator<K> listIterator(int fromIndex) {
             return 
UnmodifiableListIterator.decorate(super.listIterator(fromIndex));
         }
-        
-        public List subList(int fromIndexInclusive, int toIndexExclusive) {
+
+        public List<K> subList(int fromIndexInclusive, int toIndexExclusive) {
             return UnmodifiableList.decorate(super.subList(fromIndexInclusive, 
toIndexExclusive));
         }
     }
-    
+
 }

Reply via email to