commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1033559 - in /commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider: AbstractFileProvider.java FileSystemKey.java
Date Wed, 10 Nov 2010 16:13:02 GMT
Author: sebb
Date: Wed Nov 10 16:13:02 2010
New Revision: 1033559

URL: http://svn.apache.org/viewvc?rev=1033559&view=rev
Log:
Generics

Modified:
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractFileProvider.java
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/FileSystemKey.java

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractFileProvider.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractFileProvider.java?rev=1033559&r1=1033558&r2=1033559&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractFileProvider.java
(original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractFileProvider.java
Wed Nov 10 16:13:02 2010
@@ -95,7 +95,7 @@ public abstract class AbstractFileProvid
      * Adds a file system to those cached by this provider.  The file system
      * may implement {@link VfsComponent}, in which case it is initialised.
      */
-    protected void addFileSystem(final Comparable key, final FileSystem fs)
+    protected void addFileSystem(final Comparable<?> key, final FileSystem fs)
         throws FileSystemException
     {
         // Add to the cache
@@ -115,7 +115,7 @@ public abstract class AbstractFileProvid
      *
      * @return The provider, or null if it is not cached.
      */
-    protected FileSystem findFileSystem(final Comparable key, final FileSystemOptions fileSystemProps)
+    protected FileSystem findFileSystem(final Comparable<?> key, final FileSystemOptions
fileSystemProps)
     {
         FileSystemKey treeKey = new FileSystemKey(key, fileSystemProps);
 

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/FileSystemKey.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/FileSystemKey.java?rev=1033559&r1=1033558&r2=1033559&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/FileSystemKey.java
(original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/FileSystemKey.java
Wed Nov 10 16:13:02 2010
@@ -24,14 +24,20 @@ import org.apache.commons.vfs.FileSystem
  * @author <a href="mailto:imario@apache.org">Mario Ivankovits</a>
  * @version $Revision$ $Date$
  */
-class FileSystemKey implements Comparable
+class FileSystemKey implements Comparable<FileSystemKey>
 {
     private static final FileSystemOptions EMPTY_OPTIONS = new FileSystemOptions();
 
-    private final Comparable key;
+    private final Comparable<?> key;
     private final FileSystemOptions fileSystemOptions;
 
-    FileSystemKey(final Comparable key, final FileSystemOptions fileSystemOptions)
+    /**
+     * Create the FS key.
+     * 
+     * @param key must implement Comparable, and must be self-comparable
+     * @param fileSystemOptions the required options
+     */
+    FileSystemKey(final Comparable<?> key, final FileSystemOptions fileSystemOptions)
     {
         this.key = key;
         if (fileSystemOptions != null)
@@ -44,17 +50,17 @@ class FileSystemKey implements Comparabl
         }
     }
 
-    public int compareTo(Object o)
+    public int compareTo(FileSystemKey o)
     {
-        FileSystemKey fk = (FileSystemKey) o;
-
-        int ret = key.compareTo(fk.key);
+        @SuppressWarnings("unchecked") // Keys must implement comparable, and be comparable
to themselves
+        Comparable<Comparable<?>> comparable = (Comparable<Comparable<?>>)key;
+        int ret = comparable.compareTo(o.key);
         if (ret != 0)
         {
             // other filesystem
             return ret;
         }
 
-        return fileSystemOptions.compareTo(fk.fileSystemOptions);
+        return fileSystemOptions.compareTo(o.fileSystemOptions);
     }
 }



Mime
View raw message