commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1716212 - in /commons/proper/validator/trunk/src/main/java/org/apache/commons/validator: GenericTypeValidator.java routines/ByteValidator.java routines/LongValidator.java routines/ShortValidator.java
Date Tue, 24 Nov 2015 17:02:00 GMT
Author: sebb
Date: Tue Nov 24 17:01:58 2015
New Revision: 1716212

URL: http://svn.apache.org/viewvc?rev=1716212&view=rev
Log:
Findbugs - more efficient conversions

Modified:
    commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/GenericTypeValidator.java
    commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/ByteValidator.java
    commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/LongValidator.java
    commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/ShortValidator.java

Modified: commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/GenericTypeValidator.java
URL: http://svn.apache.org/viewvc/commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/GenericTypeValidator.java?rev=1716212&r1=1716211&r2=1716212&view=diff
==============================================================================
--- commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/GenericTypeValidator.java
(original)
+++ commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/GenericTypeValidator.java
Tue Nov 24 17:01:58 2015
@@ -52,7 +52,7 @@ public class GenericTypeValidator implem
         }
 
         try {
-            return new Byte(value);
+            return Byte.valueOf(value);
         } catch (NumberFormatException e) {
             return null;
         }
@@ -85,7 +85,7 @@ public class GenericTypeValidator implem
             if (pos.getErrorIndex() == -1 && pos.getIndex() == value.length() &&
                     num.doubleValue() >= Byte.MIN_VALUE &&
                     num.doubleValue() <= Byte.MAX_VALUE) {
-                result = new Byte(num.byteValue());
+                result = Byte.valueOf(num.byteValue());
             }
         }
 
@@ -104,7 +104,7 @@ public class GenericTypeValidator implem
         }
 
         try {
-            return new Short(value);
+            return Short.valueOf(value);
         } catch (NumberFormatException e) {
             return null;
         }
@@ -137,7 +137,7 @@ public class GenericTypeValidator implem
             if (pos.getErrorIndex() == -1 && pos.getIndex() == value.length() &&
                     num.doubleValue() >= Short.MIN_VALUE &&
                     num.doubleValue() <= Short.MAX_VALUE) {
-                result = new Short(num.shortValue());
+                result = Short.valueOf(num.shortValue());
             }
         }
 
@@ -156,7 +156,7 @@ public class GenericTypeValidator implem
         }
 
         try {
-            return new Integer(value);
+            return Integer.valueOf(value);
         } catch (NumberFormatException e) {
             return null;
         }
@@ -189,7 +189,7 @@ public class GenericTypeValidator implem
             if (pos.getErrorIndex() == -1 && pos.getIndex() == value.length() &&
                     num.doubleValue() >= Integer.MIN_VALUE &&
                     num.doubleValue() <= Integer.MAX_VALUE) {
-                result = new Integer(num.intValue());
+                result = Integer.valueOf(num.intValue());
             }
         }
 
@@ -208,7 +208,7 @@ public class GenericTypeValidator implem
         }
 
         try {
-            return new Long(value);
+            return Long.valueOf(value);
         } catch (NumberFormatException e) {
             return null;
         }
@@ -241,7 +241,7 @@ public class GenericTypeValidator implem
             if (pos.getErrorIndex() == -1 && pos.getIndex() == value.length() &&
                     num.doubleValue() >= Long.MIN_VALUE &&
                     num.doubleValue() <= Long.MAX_VALUE) {
-                result = new Long(num.longValue());
+                result = Long.valueOf(num.longValue());
             }
         }
 
@@ -466,7 +466,7 @@ public class GenericTypeValidator implem
      * @return the converted Credit Card number.
      */
     public static Long formatCreditCard(String value) {
-        return GenericValidator.isCreditCard(value) ? new Long(value) : null;
+        return GenericValidator.isCreditCard(value) ? Long.valueOf(value) : null;
     }
 
 }

Modified: commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/ByteValidator.java
URL: http://svn.apache.org/viewvc/commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/ByteValidator.java?rev=1716212&r1=1716211&r2=1716212&view=diff
==============================================================================
--- commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/ByteValidator.java
(original)
+++ commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/ByteValidator.java
Tue Nov 24 17:01:58 2015
@@ -249,7 +249,7 @@ public class ByteValidator extends Abstr
             longValue > Byte.MAX_VALUE) {
             return null;
         }
-        return new Byte((byte)longValue);
+        return Byte.valueOf((byte)longValue);
     }
 
 }

Modified: commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/LongValidator.java
URL: http://svn.apache.org/viewvc/commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/LongValidator.java?rev=1716212&r1=1716211&r2=1716212&view=diff
==============================================================================
--- commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/LongValidator.java
(original)
+++ commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/LongValidator.java
Tue Nov 24 17:01:58 2015
@@ -244,7 +244,7 @@ public class LongValidator extends Abstr
         if (value instanceof Long) {
             return value;
         }
-        return new Long(((Number)value).longValue());
+        return Long.valueOf(((Number)value).longValue());
 
     }
 }

Modified: commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/ShortValidator.java
URL: http://svn.apache.org/viewvc/commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/ShortValidator.java?rev=1716212&r1=1716211&r2=1716212&view=diff
==============================================================================
--- commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/ShortValidator.java
(original)
+++ commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/ShortValidator.java
Tue Nov 24 17:01:58 2015
@@ -249,6 +249,6 @@ public class ShortValidator extends Abst
             longValue > Short.MAX_VALUE) {
             return null;
         }
-        return new Short((short)longValue);
+        return Short.valueOf((short)longValue);
     }
 }



Mime
View raw message