commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1228597 - /commons/proper/dbutils/trunk/src/main/java/org/apache/commons/dbutils/BeanProcessor.java
Date Sat, 07 Jan 2012 11:42:21 GMT
Author: sebb
Date: Sat Jan  7 11:42:21 2012
New Revision: 1228597

URL: http://svn.apache.org/viewvc?rev=1228597&view=rev
Log:
No need to check for non-null before using instanceof (null is never an instanceof);
Only extract the target type once

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

Modified: commons/proper/dbutils/trunk/src/main/java/org/apache/commons/dbutils/BeanProcessor.java
URL: http://svn.apache.org/viewvc/commons/proper/dbutils/trunk/src/main/java/org/apache/commons/dbutils/BeanProcessor.java?rev=1228597&r1=1228596&r2=1228597&view=diff
==============================================================================
--- commons/proper/dbutils/trunk/src/main/java/org/apache/commons/dbutils/BeanProcessor.java
(original)
+++ commons/proper/dbutils/trunk/src/main/java/org/apache/commons/dbutils/BeanProcessor.java
Sat Jan  7 11:42:21 2012
@@ -234,14 +234,15 @@ public class BeanProcessor {
         Class<?>[] params = setter.getParameterTypes();
         try {
             // convert types for some popular ones
-            if (value != null && value instanceof java.util.Date) {
-                if ("java.sql.Date".equals(params[0].getName())) {
+            if (value instanceof java.util.Date) {
+                final String targetType = params[0].getName();
+                if ("java.sql.Date".equals(targetType)) {
                     value = new java.sql.Date(((java.util.Date) value).getTime());
                 } else
-                if ("java.sql.Time".equals(params[0].getName())) {
+                if ("java.sql.Time".equals(targetType)) {
                     value = new java.sql.Time(((java.util.Date) value).getTime());
                 } else
-                if ("java.sql.Timestamp".equals(params[0].getName())) {
+                if ("java.sql.Timestamp".equals(targetType)) {
                     value = new java.sql.Timestamp(((java.util.Date) value).getTime());
                 }
             }



Mime
View raw message