commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sebb (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (DBUTILS-85) In BeanProcessor#isCompatibleType, can Integer.class.isInstance(value) be replaced by value instanceof Integer (etc)?
Date Tue, 14 May 2013 17:49:16 GMT

     [ https://issues.apache.org/jira/browse/DBUTILS-85?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Sebb resolved DBUTILS-85.
-------------------------

       Resolution: Fixed
    Fix Version/s: 1.6
                   2.0

URL: http://svn.apache.org/r1482485
Log:
DBUTILS-85 In BeanProcessor#isCompatibleType, can Integer.class.isInstance(value) be replaced
by value instanceof Integer (etc)?
Simplified code by using instanceof.

Modified:
    commons/proper/dbutils/trunk/src/changes/changes.xml
    commons/proper/dbutils/trunk/src/main/java/org/apache/commons/dbutils/BeanProcessor.java


URL: http://svn.apache.org/r1482487
Log:
DBUTILS-85 In BeanProcessor#isCompatibleType, can Integer.class.isInstance(value) be replaced
by value instanceof Integer (etc)?
Simplified code by using instanceof.

Modified:
    commons/proper/dbutils/branches/2_0/src/changes/changes.xml
    commons/proper/dbutils/branches/2_0/src/main/java/org/apache/commons/dbutils2/BeanProcessor.java

                
> In BeanProcessor#isCompatibleType, can Integer.class.isInstance(value) be replaced by
value instanceof Integer (etc)?
> ---------------------------------------------------------------------------------------------------------------------
>
>                 Key: DBUTILS-85
>                 URL: https://issues.apache.org/jira/browse/DBUTILS-85
>             Project: Commons DbUtils
>          Issue Type: Improvement
>            Reporter: Sebb
>            Priority: Minor
>             Fix For: 2.0, 1.6
>
>
> In BeanProcessor#isCompatibleType, there is one valid use of the dynamic Class#isInstance()
method, followed by several that could surely use the static instanceof keyword:
> {noformat}
> if (value == null || type.isInstance(value)) { // <== this needs to be dynamic
>     return true;
> } else if (type.equals(Integer.TYPE) && Integer.class.isInstance(value)) { //
<== this doesn't
>     return true;
> } else if (type.equals(Long.TYPE) && Long.class.isInstance(value)) { // <==
nore here
>     return true;
> ...
> {noformat}
> Seems unnecessary (and more verbose) to use the dynamic method where the target class
is known at compile time.
> Or am I missing something here? 
> If so, let's document why the dynamic method is needed.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message