This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-vfs.git


The following commit(s) were added to refs/heads/master by this push:
     new d6d1a4a  Use generics.
d6d1a4a is described below

commit d6d1a4a00cf7da771b8c20190aff8a6658163170
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Thu Feb 4 15:10:14 2021 -0500

    Use generics.
---
 .../commons/vfs2/FileSystemConfigBuilder.java      | 23 +++++++++++-----------
 .../org/apache/commons/vfs2/FileSystemOptions.java |  4 ++--
 .../vfs2/impl/DefaultFileSystemConfigBuilder.java  |  2 +-
 .../provider/ftps/FtpsFileSystemConfigBuilder.java |  4 ++--
 .../provider/hdfs/HdfsFileSystemConfigBuilder.java |  4 ++--
 .../provider/http/HttpFileSystemConfigBuilder.java |  6 +++---
 .../http4/Http4FileSystemConfigBuilder.java        | 10 +++++-----
 .../http5/Http5FileSystemConfigBuilder.java        | 12 +++++------
 .../res/ResourceFileSystemConfigBuilder.java       |  2 +-
 .../provider/sftp/SftpFileSystemConfigBuilder.java | 14 ++++++-------
 .../provider/zip/ZipFileSystemConfigBuilder.java   |  2 +-
 11 files changed, 42 insertions(+), 41 deletions(-)

diff --git 
a/commons-vfs2/src/main/java/org/apache/commons/vfs2/FileSystemConfigBuilder.java
 
b/commons-vfs2/src/main/java/org/apache/commons/vfs2/FileSystemConfigBuilder.java
index 43408da..f67b78b 100644
--- 
a/commons-vfs2/src/main/java/org/apache/commons/vfs2/FileSystemConfigBuilder.java
+++ 
b/commons-vfs2/src/main/java/org/apache/commons/vfs2/FileSystemConfigBuilder.java
@@ -95,7 +95,7 @@ public abstract class FileSystemConfigBuilder {
      */
     protected Boolean getBoolean(final FileSystemOptions fileSystemOptions, 
final String name,
         final Boolean defaultValue) {
-        Boolean value = (Boolean) getParam(fileSystemOptions, name);
+        Boolean value = getParam(fileSystemOptions, name);
         if (value == null) {
             final String str = getProperty(name);
             if (str == null) {
@@ -146,7 +146,7 @@ public abstract class FileSystemConfigBuilder {
      * @since 2.0
      */
     protected Byte getByte(final FileSystemOptions fileSystemOptions, final 
String name, final Byte defaultValue) {
-        Byte value = (Byte) getParam(fileSystemOptions, name);
+        Byte value = getParam(fileSystemOptions, name);
         if (value == null) {
             final String str = getProperty(name);
             if (str == null) {
@@ -198,7 +198,7 @@ public abstract class FileSystemConfigBuilder {
      */
     protected Character getCharacter(final FileSystemOptions 
fileSystemOptions, final String name,
         final Character defaultValue) {
-        Character value = (Character) getParam(fileSystemOptions, name);
+        Character value = getParam(fileSystemOptions, name);
         if (value == null) {
             final String str = getProperty(name);
             if (str == null || str.isEmpty()) {
@@ -260,7 +260,7 @@ public abstract class FileSystemConfigBuilder {
      */
     protected Double getDouble(final FileSystemOptions fileSystemOptions, 
final String name,
         final Double defaultValue) {
-        Double value = (Double) getParam(fileSystemOptions, name);
+        Double value = getParam(fileSystemOptions, name);
         if (value == null) {
             final String str = getProperty(name);
             if (str == null || str.isEmpty()) {
@@ -306,7 +306,7 @@ public abstract class FileSystemConfigBuilder {
     protected <E extends Enum<E>> E getEnum(final Class<E> enumClass, final 
FileSystemOptions fileSystemOptions,
         final String name, final E defaultValue) {
         @SuppressWarnings("unchecked")
-        E value = (E) getParam(fileSystemOptions, name);
+        E value = getParam(fileSystemOptions, name);
         if (value == null) {
             final String str = getProperty(name);
             if (str == null) {
@@ -360,7 +360,7 @@ public abstract class FileSystemConfigBuilder {
      * @since 2.0
      */
     protected Float getFloat(final FileSystemOptions fileSystemOptions, final 
String name, final Float defaultValue) {
-        Float value = (Float) getParam(fileSystemOptions, name);
+        Float value = getParam(fileSystemOptions, name);
         if (value == null) {
             final String str = getProperty(name);
             if (str == null || str.isEmpty()) {
@@ -415,7 +415,7 @@ public abstract class FileSystemConfigBuilder {
      */
     protected Integer getInteger(final FileSystemOptions fileSystemOptions, 
final String name,
         final Integer defaultValue) {
-        Integer value = (Integer) getParam(fileSystemOptions, name);
+        Integer value = getParam(fileSystemOptions, name);
         if (value == null) {
             final String str = getProperty(name);
             if (str == null) {
@@ -469,7 +469,7 @@ public abstract class FileSystemConfigBuilder {
      * @since 2.0
      */
     protected Long getLong(final FileSystemOptions fileSystemOptions, final 
String name, final Long defaultValue) {
-        Long value = (Long) getParam(fileSystemOptions, name);
+        Long value = getParam(fileSystemOptions, name);
         if (value == null) {
             final String str = getProperty(name);
             if (str == null) {
@@ -483,13 +483,14 @@ public abstract class FileSystemConfigBuilder {
     /**
      * Gets named parameter.
      *
+     * @param <T> The expected return type.
      * @param fileSystemOptions file system options to query, may be null.
      * @param name get option with this name
      * @return the named option or null
      *
      * @since 1.0
      */
-    protected Object getParam(final FileSystemOptions fileSystemOptions, final 
String name) {
+    protected <T> T getParam(final FileSystemOptions fileSystemOptions, final 
String name) {
         return fileSystemOptions == null ? null : 
fileSystemOptions.getOption(getConfigClass(), name);
     }
 
@@ -560,7 +561,7 @@ public abstract class FileSystemConfigBuilder {
      * @since 2.0
      */
     protected Short getShort(final FileSystemOptions fileSystemOptions, final 
String name, final Short defaultValue) {
-        Short value = (Short) getParam(fileSystemOptions, name);
+        Short value = getParam(fileSystemOptions, name);
         if (value == null) {
             final String str = getProperty(name);
             if (str == null) {
@@ -597,7 +598,7 @@ public abstract class FileSystemConfigBuilder {
      */
     protected String getString(final FileSystemOptions fileSystemOptions, 
final String name,
         final String defaultValue) {
-        String value = (String) getParam(fileSystemOptions, name);
+        String value = getParam(fileSystemOptions, name);
         if (value == null) {
             value = getProperty(name);
             if (value == null) {
diff --git 
a/commons-vfs2/src/main/java/org/apache/commons/vfs2/FileSystemOptions.java 
b/commons-vfs2/src/main/java/org/apache/commons/vfs2/FileSystemOptions.java
index 91e8cec..c8d3ef4 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/FileSystemOptions.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/FileSystemOptions.java
@@ -124,9 +124,9 @@ public final class FileSystemOptions implements Cloneable {
         options.put(new FileSystemOptionKey(fileSystemClass, name), value);
     }
 
-    Object getOption(final Class<? extends FileSystem> fileSystemClass, final 
String name) {
+    <T> T getOption(final Class<? extends FileSystem> fileSystemClass, final 
String name) {
         final FileSystemOptionKey key = new 
FileSystemOptionKey(fileSystemClass, name);
-        return options.get(key);
+        return (T) options.get(key);
     }
 
     boolean hasOption(final Class<? extends FileSystem> fileSystemClass, final 
String name) {
diff --git 
a/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultFileSystemConfigBuilder.java
 
b/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultFileSystemConfigBuilder.java
index f6db28e..e2a687e 100644
--- 
a/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultFileSystemConfigBuilder.java
+++ 
b/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultFileSystemConfigBuilder.java
@@ -56,7 +56,7 @@ public class DefaultFileSystemConfigBuilder extends 
FileSystemConfigBuilder {
      * @return The UserAuthenticator.
      */
     public UserAuthenticator getUserAuthenticator(final FileSystemOptions 
opts) {
-        return (UserAuthenticator) getParam(opts, "userAuthenticator");
+        return getParam(opts, "userAuthenticator");
     }
 
     /**
diff --git 
a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftps/FtpsFileSystemConfigBuilder.java
 
b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftps/FtpsFileSystemConfigBuilder.java
index efe942d..1426d67 100644
--- 
a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftps/FtpsFileSystemConfigBuilder.java
+++ 
b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftps/FtpsFileSystemConfigBuilder.java
@@ -153,7 +153,7 @@ public final class FtpsFileSystemConfigBuilder extends 
FtpFileSystemConfigBuilde
      * @since 2.1
      */
     public KeyManager getKeyManager(final FileSystemOptions opts) {
-        return (KeyManager) getParam(opts, KEY_MANAGER);
+        return getParam(opts, KEY_MANAGER);
     }
 
     /**
@@ -183,7 +183,7 @@ public final class FtpsFileSystemConfigBuilder extends 
FtpFileSystemConfigBuilde
     public TrustManager getTrustManager(final FileSystemOptions opts) {
         final TrustManager trustManager;
         if (hasParam(opts, TRUST_MANAGER)) {
-            trustManager = (TrustManager) getParam(opts, TRUST_MANAGER);
+            trustManager = getParam(opts, TRUST_MANAGER);
         } else {
             trustManager = 
TrustManagerUtils.getValidateServerCertificateTrustManager();
         }
diff --git 
a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/hdfs/HdfsFileSystemConfigBuilder.java
 
b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/hdfs/HdfsFileSystemConfigBuilder.java
index fb8630c..af5738c 100644
--- 
a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/hdfs/HdfsFileSystemConfigBuilder.java
+++ 
b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/hdfs/HdfsFileSystemConfigBuilder.java
@@ -68,7 +68,7 @@ public final class HdfsFileSystemConfigBuilder extends 
FileSystemConfigBuilder {
      * @see #setConfigConfiguration(FileSystemOptions, Configuration)
      */
     public Configuration getConfigConfiguration(final FileSystemOptions opts) {
-        return (Configuration) this.getParam(opts, KEY_CONFIG_CONF);
+        return getParam(opts, KEY_CONFIG_CONF);
     }
 
     /**
@@ -79,7 +79,7 @@ public final class HdfsFileSystemConfigBuilder extends 
FileSystemConfigBuilder {
      * @see #setConfigInputStream(FileSystemOptions, InputStream)
      */
     public InputStream getConfigInputStream(final FileSystemOptions opts) {
-        return (InputStream) this.getParam(opts, KEY_CONFIG_STREAM);
+        return getParam(opts, KEY_CONFIG_STREAM);
     }
 
     /**
diff --git 
a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http/HttpFileSystemConfigBuilder.java
 
b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http/HttpFileSystemConfigBuilder.java
index b7044f8..3179fe3 100644
--- 
a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http/HttpFileSystemConfigBuilder.java
+++ 
b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http/HttpFileSystemConfigBuilder.java
@@ -159,7 +159,7 @@ public class HttpFileSystemConfigBuilder extends 
FileSystemConfigBuilder {
      * @return The UserAuthenticator.
      */
     public UserAuthenticator getProxyAuthenticator(final FileSystemOptions 
opts) {
-        return (UserAuthenticator) getParam(opts, "proxyAuthenticator");
+        return getParam(opts, "proxyAuthenticator");
     }
 
     /**
@@ -191,7 +191,7 @@ public class HttpFileSystemConfigBuilder extends 
FileSystemConfigBuilder {
      * @return the Cookie array.
      */
     public Cookie[] getCookies(final FileSystemOptions opts) {
-        return (Cookie[]) getParam(opts, "cookies");
+        return getParam(opts, "cookies");
     }
 
     /**
@@ -334,7 +334,7 @@ public class HttpFileSystemConfigBuilder extends 
FileSystemConfigBuilder {
      * @return User provided User-Agent string, otherwise default of: 
Commons-VFS
      */
     public String getUserAgent(final FileSystemOptions opts) {
-        final String userAgent = (String) getParam(opts, KEY_USER_AGENT);
+        final String userAgent = getParam(opts, KEY_USER_AGENT);
         return userAgent != null ? userAgent : DEFAULT_USER_AGENT;
     }
 
diff --git 
a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http4/Http4FileSystemConfigBuilder.java
 
b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http4/Http4FileSystemConfigBuilder.java
index 26d97c1..7e35a19 100644
--- 
a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http4/Http4FileSystemConfigBuilder.java
+++ 
b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http4/Http4FileSystemConfigBuilder.java
@@ -308,7 +308,7 @@ public class Http4FileSystemConfigBuilder extends 
FileSystemConfigBuilder {
      * @return The UserAuthenticator.
      */
     public UserAuthenticator getProxyAuthenticator(final FileSystemOptions 
opts) {
-        return (UserAuthenticator) getParam(opts, "proxyAuthenticator");
+        return getParam(opts, "proxyAuthenticator");
     }
 
     /**
@@ -339,7 +339,7 @@ public class Http4FileSystemConfigBuilder extends 
FileSystemConfigBuilder {
      * @return the Cookie array.
      */
     public Cookie[] getCookies(final FileSystemOptions opts) {
-        return (Cookie[]) getParam(opts, "cookies");
+        return getParam(opts, "cookies");
     }
 
     /**
@@ -492,7 +492,7 @@ public class Http4FileSystemConfigBuilder extends 
FileSystemConfigBuilder {
      * @return User provided User-Agent string, otherwise default of: 
Commons-VFS
      */
     public String getUserAgent(final FileSystemOptions opts) {
-        final String userAgent = (String) getParam(opts, KEY_USER_AGENT);
+        final String userAgent = getParam(opts, KEY_USER_AGENT);
         return userAgent != null ? userAgent : DEFAULT_USER_AGENT;
     }
 
@@ -511,7 +511,7 @@ public class Http4FileSystemConfigBuilder extends 
FileSystemConfigBuilder {
      * @return keystore file path to be used in SSL connections
      */
     public String getKeyStoreFile(final FileSystemOptions opts) {
-        return (String) getParam(opts, KEYSTORE_FILE);
+        return getParam(opts, KEYSTORE_FILE);
     }
 
     /**
@@ -529,7 +529,7 @@ public class Http4FileSystemConfigBuilder extends 
FileSystemConfigBuilder {
      * @return keystore pass phrase for SSL connections
      */
     String getKeyStorePass(final FileSystemOptions opts) {
-        return (String) getParam(opts, KEYSTORE_PASS);
+        return getParam(opts, KEYSTORE_PASS);
     }
 
     /**
diff --git 
a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http5/Http5FileSystemConfigBuilder.java
 
b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http5/Http5FileSystemConfigBuilder.java
index 9f5a41a..53b327b 100644
--- 
a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http5/Http5FileSystemConfigBuilder.java
+++ 
b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http5/Http5FileSystemConfigBuilder.java
@@ -325,7 +325,7 @@ public class Http5FileSystemConfigBuilder extends 
FileSystemConfigBuilder {
      * @return The UserAuthenticator.
      */
     public UserAuthenticator getProxyAuthenticator(final FileSystemOptions 
opts) {
-        return (UserAuthenticator) getParam(opts, "proxyAuthenticator");
+        return getParam(opts, "proxyAuthenticator");
     }
 
     /**
@@ -356,7 +356,7 @@ public class Http5FileSystemConfigBuilder extends 
FileSystemConfigBuilder {
      * @return the Cookie array.
      */
     public Cookie[] getCookies(final FileSystemOptions opts) {
-        return (Cookie[]) getParam(opts, "cookies");
+        return getParam(opts, "cookies");
     }
 
     /**
@@ -509,7 +509,7 @@ public class Http5FileSystemConfigBuilder extends 
FileSystemConfigBuilder {
      * @return User provided User-Agent string, otherwise default of: 
Commons-VFS
      */
     public String getUserAgent(final FileSystemOptions opts) {
-        final String userAgent = (String) getParam(opts, KEY_USER_AGENT);
+        final String userAgent = getParam(opts, KEY_USER_AGENT);
         return userAgent != null ? userAgent : DEFAULT_USER_AGENT;
     }
 
@@ -528,7 +528,7 @@ public class Http5FileSystemConfigBuilder extends 
FileSystemConfigBuilder {
      * @return keystore file path to be used in SSL connections
      */
     public String getKeyStoreFile(final FileSystemOptions opts) {
-        return (String) getParam(opts, KEYSTORE_FILE);
+        return getParam(opts, KEYSTORE_FILE);
     }
 
     /**
@@ -546,7 +546,7 @@ public class Http5FileSystemConfigBuilder extends 
FileSystemConfigBuilder {
      * @return keystore pass phrase for SSL connections
      */
     String getKeyStorePass(final FileSystemOptions opts) {
-        return (String) getParam(opts, KEYSTORE_PASS);
+        return getParam(opts, KEYSTORE_PASS);
     }
 
     /**
@@ -607,7 +607,7 @@ public class Http5FileSystemConfigBuilder extends 
FileSystemConfigBuilder {
      * @return enabled TLS versions
      */
     public String getTlsVersions(final FileSystemOptions opts) {
-        final String tlsVersions = (String) getParam(opts, KEY_TLS_VERSIONS);
+        final String tlsVersions = getParam(opts, KEY_TLS_VERSIONS);
         return tlsVersions != null ? tlsVersions : DEFAULT_TLS_VERSIONS;
     }
 
diff --git 
a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/res/ResourceFileSystemConfigBuilder.java
 
b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/res/ResourceFileSystemConfigBuilder.java
index fed3ea9..92da202 100644
--- 
a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/res/ResourceFileSystemConfigBuilder.java
+++ 
b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/res/ResourceFileSystemConfigBuilder.java
@@ -46,7 +46,7 @@ public final class ResourceFileSystemConfigBuilder extends 
FileSystemConfigBuild
     }
 
     public ClassLoader getClassLoader(final FileSystemOptions opts) {
-        return (ClassLoader) getParam(opts, ClassLoader.class.getName());
+        return getParam(opts, ClassLoader.class.getName());
     }
 
     @Override
diff --git 
a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileSystemConfigBuilder.java
 
b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileSystemConfigBuilder.java
index afdde3f..dd7be37 100644
--- 
a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileSystemConfigBuilder.java
+++ 
b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileSystemConfigBuilder.java
@@ -161,7 +161,7 @@ public final class SftpFileSystemConfigBuilder extends 
FileSystemConfigBuilder {
      * @return the ConfigRepository
      */
     public ConfigRepository getConfigRepository(final FileSystemOptions opts) {
-        return (ConfigRepository) this.getParam(opts, CONFIG_REPOSITORY);
+        return getParam(opts, CONFIG_REPOSITORY);
     }
 
     /**
@@ -229,7 +229,7 @@ public final class SftpFileSystemConfigBuilder extends 
FileSystemConfigBuilder {
      * @since 2.4
      */
     public IdentityProvider[] getIdentityProvider(final FileSystemOptions 
opts) {
-        return (IdentityProvider[]) this.getParam(opts, IDENTITIES);
+        return getParam(opts, IDENTITIES);
     }
 
     /**
@@ -239,7 +239,7 @@ public final class SftpFileSystemConfigBuilder extends 
FileSystemConfigBuilder {
      * @return the IdentityRepositoryFactory
      */
     public IdentityRepositoryFactory getIdentityRepositoryFactory(final 
FileSystemOptions opts) {
-        return (IdentityRepositoryFactory) this.getParam(opts, 
IDENTITY_REPOSITORY_FACTORY);
+        return getParam(opts, IDENTITY_REPOSITORY_FACTORY);
     }
 
     /**
@@ -259,7 +259,7 @@ public final class SftpFileSystemConfigBuilder extends 
FileSystemConfigBuilder {
      * @see #setKnownHosts
      */
     public File getKnownHosts(final FileSystemOptions opts) {
-        return (File) this.getParam(opts, KNOWN_HOSTS);
+        return getParam(opts, KNOWN_HOSTS);
     }
 
     /**
@@ -309,7 +309,7 @@ public final class SftpFileSystemConfigBuilder extends 
FileSystemConfigBuilder {
      * @since 2.1
      */
     public FileSystemOptions getProxyOptions(final FileSystemOptions opts) {
-        return (FileSystemOptions) this.getParam(opts, PROXY_OPTIONS);
+        return getParam(opts, PROXY_OPTIONS);
     }
 
     /**
@@ -344,7 +344,7 @@ public final class SftpFileSystemConfigBuilder extends 
FileSystemConfigBuilder {
      * @return The ProxyType.
      */
     public ProxyType getProxyType(final FileSystemOptions opts) {
-        return (ProxyType) this.getParam(opts, PROXY_TYPE);
+        return getParam(opts, PROXY_TYPE);
     }
 
     /**
@@ -408,7 +408,7 @@ public final class SftpFileSystemConfigBuilder extends 
FileSystemConfigBuilder {
      * @see #setUserInfo
      */
     public UserInfo getUserInfo(final FileSystemOptions opts) {
-        return (UserInfo) this.getParam(opts, UserInfo.class.getName());
+        return getParam(opts, UserInfo.class.getName());
     }
 
     /**
diff --git 
a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/zip/ZipFileSystemConfigBuilder.java
 
b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/zip/ZipFileSystemConfigBuilder.java
index 143cc8a..acb5a68 100644
--- 
a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/zip/ZipFileSystemConfigBuilder.java
+++ 
b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/zip/ZipFileSystemConfigBuilder.java
@@ -38,7 +38,7 @@ public class ZipFileSystemConfigBuilder extends 
FileSystemConfigBuilder {
     }
 
     public Charset getCharset(final FileSystemOptions opts) {
-        return (Charset) getParam(opts, KEY_CHARSET);
+        return getParam(opts, KEY_CHARSET);
     }
 
     @Override

Reply via email to