commons-commits mailing list archives

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

URL: http://svn.apache.org/viewvc?rev=815079&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:

    ------------------------------------------------------------------------
    r572176 | skestle | 2007-09-02 15:04:41 -0700 (Sun, 02 Sep 2007) | 1 line
    
    Generified LazySortedMap to fix build errors
    ------------------------------------------------------------------------
    r572156 | skestle | 2007-09-02 14:12:06 -0700 (Sun, 02 Sep 2007) | 1 line
    
    Added <Object, Object> generification for LazySortedMap to temporarily fix javac
compilation problems
    ------------------------------------------------------------------------

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

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/LazySortedMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/LazySortedMap.java?rev=815079&r1=815078&r2=815079&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/LazySortedMap.java
(original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/LazySortedMap.java
Tue Sep 15 05:56:08 2009
@@ -58,9 +58,9 @@
  * @author Stephen Colebourne
  * @author Paul Jack
  */
-public class LazySortedMap
-        extends LazyMap
-        implements SortedMap {
+public class LazySortedMap<K,V>
+        extends LazyMap<K,V>
+        implements SortedMap<K,V> {
 
     /** Serialization version */
     private static final long serialVersionUID = 2715322183617658933L;
@@ -71,9 +71,11 @@
      * @param map  the map to decorate, must not be null
      * @param factory  the factory to use, must not be null
      * @throws IllegalArgumentException if map or factory is null
+     * @deprecated
      */
-    public static SortedMap decorate(SortedMap map, Factory factory) {
-        return new LazySortedMap(map, factory);
+    @Deprecated
+    public static <K,V> SortedMap<K,V> decorate(SortedMap<K,V> map, Factory<?
extends V> factory) {
+        return getLazySortedMap(map, factory);
     }
 
     /**
@@ -83,8 +85,32 @@
      * @param factory  the factory to use, must not be null
      * @throws IllegalArgumentException if map or factory is null
      */
-    public static SortedMap decorate(SortedMap map, Transformer factory) {
-        return new LazySortedMap(map, factory);
+    public static <K, V> SortedMap<K, V> getLazySortedMap(SortedMap<K, V>
map, Factory<? extends V> factory) {
+        return new LazySortedMap<K,V>(map, factory);
+    }
+
+    /**
+     * Factory method to create a lazily instantiated sorted map.
+     * 
+     * @param map  the map to decorate, must not be null
+     * @param factory  the factory to use, must not be null
+     * @throws IllegalArgumentException if map or factory is null
+     * @deprecated
+     */
+    @Deprecated
+    public static <K,V> SortedMap<K,V> decorate(SortedMap<K,V> map, Transformer<?
super K, ? extends V> factory) {
+        return getLazySortedMap(map, factory);
+    }
+
+    /**
+     * Factory method to create a lazily instantiated sorted map.
+     * 
+     * @param map  the map to decorate, must not be null
+     * @param factory  the factory to use, must not be null
+     * @throws IllegalArgumentException if map or factory is null
+     */
+    public static <K, V> SortedMap<K, V> getLazySortedMap(SortedMap<K, V>
map, Transformer<? super K, ? extends V> factory) {
+        return new LazySortedMap<K,V>(map, factory);
     }
 
     //-----------------------------------------------------------------------
@@ -95,7 +121,7 @@
      * @param factory  the factory to use, must not be null
      * @throws IllegalArgumentException if map or factory is null
      */
-    protected LazySortedMap(SortedMap map, Factory factory) {
+    protected LazySortedMap(SortedMap<K,V> map, Factory<? extends V> factory)
{
         super(map, factory);
     }
 
@@ -106,7 +132,7 @@
      * @param factory  the factory to use, must not be null
      * @throws IllegalArgumentException if map or factory is null
      */
-    protected LazySortedMap(SortedMap map, Transformer factory) {
+    protected LazySortedMap(SortedMap<K,V> map, Transformer<? super K, ? extends
V> factory) {
         super(map, factory);
     }
 
@@ -116,36 +142,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 LazySortedMap(map, factory);
+    public SortedMap<K,V> subMap(K fromKey, K toKey) {
+        SortedMap<K,V> map = getSortedMap().subMap(fromKey, toKey);
+        return new LazySortedMap<K,V>(map, factory);
     }
 
-    public SortedMap headMap(Object toKey) {
-        SortedMap map = getSortedMap().headMap(toKey);
-        return new LazySortedMap(map, factory);
+    public SortedMap<K,V> headMap(K toKey) {
+        SortedMap<K,V> map = getSortedMap().headMap(toKey);
+        return new LazySortedMap<K,V>(map, factory);
     }
 
-    public SortedMap tailMap(Object fromKey) {
-        SortedMap map = getSortedMap().tailMap(fromKey);
-        return new LazySortedMap(map, factory);
+    public SortedMap<K,V> tailMap(K fromKey) {
+        SortedMap<K,V> map = getSortedMap().tailMap(fromKey);
+        return new LazySortedMap<K,V>(map, factory);
     }
 
 }



Mime
View raw message