commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r815086 - /commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/UnmodifiableOrderedMap.java
Date Tue, 15 Sep 2009 05:56:20 GMT
Author: bayard
Date: Tue Sep 15 05:56:20 2009
New Revision: 815086

URL: http://svn.apache.org/viewvc?rev=815086&view=rev
Log:
Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified;
mostly in r738956.

Also see the following revisions:

    ------------------------------------------------------------------------
    r471189 | scolebourne | 2006-11-04 05:57:57 -0800 (Sat, 04 Nov 2006) | 1 line
    
    Remove getMap(), getOrderedMap() and getSortedMap() - use decorated()
    ------------------------------------------------------------------------

Modified:
    commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/UnmodifiableOrderedMap.java

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/UnmodifiableOrderedMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/UnmodifiableOrderedMap.java?rev=815086&r1=815085&r2=815086&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/UnmodifiableOrderedMap.java
(original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/UnmodifiableOrderedMap.java
Tue Sep 15 05:56:20 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;
 
@@ -45,9 +43,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;
@@ -58,11 +55,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);
     }
 
     //-----------------------------------------------------------------------
@@ -72,7 +69,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);
     }
 
@@ -97,19 +94,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 = getOrderedMap().mapIterator();
-        return UnmodifiableMapIterator.decorate(it);
-    }
-
-    public OrderedMapIterator orderedMapIterator() {
-        OrderedMapIterator it = getOrderedMap().orderedMapIterator();
+    public OrderedMapIterator<K, V> mapIterator() {
+        OrderedMapIterator<K, V> it = decorated().mapIterator();
         return UnmodifiableOrderedMapIterator.decorate(it);
     }
 
@@ -117,30 +110,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);
     }
 



Mime
View raw message