commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1153490 - in /commons/proper/lang/trunk/src: main/java/org/apache/commons/lang3/ main/java/org/apache/commons/lang3/math/ main/java/org/apache/commons/lang3/mutable/ test/java/org/apache/commons/lang3/ test/java/org/apache/commons/lang3/ma...
Date Wed, 03 Aug 2011 13:53:37 GMT
Author: ggregory
Date: Wed Aug  3 13:53:35 2011
New Revision: 1153490

URL: http://svn.apache.org/viewvc?rev=1153490&view=rev
Log:
Use internal Java's Number caches instead creating new objects:

- Use more efficient Integer cache: Use "Integer.valueOf(int)" instead of "new Integer(int)".
- Use more efficient Long cache: Use "Long.valueOf(int)" instead of "new Long(long)".
- Use more efficient Short cache: Use "Short.valueOf(int)" instead of "new Short(short)".

In Java version 1.6.0_24 (vendor: Sun Microsystems Inc.), Float and Double do not implement
caches, but I've made the same changes for consistency and future proofing.

- Use "Double.valueOf(int)" instead of "new Double(double)".
- Use "Float.valueOf(int)" instead of "new Float(float)".

Modified:
    commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/ArrayUtils.java
    commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/Validate.java
    commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/math/NumberUtils.java
    commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableDouble.java
    commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableFloat.java
    commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java
    commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java
    commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
    commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java
    commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java
    commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableObjectTest.java
    commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java
    commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java

Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/ArrayUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/ArrayUtils.java?rev=1153490&r1=1153489&r2=1153490&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/ArrayUtils.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/ArrayUtils.java Wed Aug
 3 13:53:35 2011
@@ -288,9 +288,9 @@ public class ArrayUtils {
      * <p>Note, this method makes only sense to provide arguments of the same type
so that the
      * compiler can deduce the type of the array itself. While it is possible to select the
      * type explicitly like in
-     * <code>Number[] array = ArrayUtils.&lt;Number&gt;toArray(Integer.valueOf(42),
new Double(Math.PI))</code>,
+     * <code>Number[] array = ArrayUtils.&lt;Number&gt;toArray(Integer.valueOf(42),
Double.valueOf(Math.PI))</code>,
      * there is no real advantage when compared to
-     * <code>new Number[] {Integer.valueOf(42), new Double(Math.PI)}</code>.</p>
+     * <code>new Number[] {Integer.valueOf(42), Double.valueOf(Math.PI)}</code>.</p>
      *
      * @param  <T>   the array's element type
      * @param  items  the varargs array items, null allowed

Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/Validate.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/Validate.java?rev=1153490&r1=1153489&r2=1153490&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/Validate.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/Validate.java Wed Aug
 3 13:53:35 2011
@@ -129,7 +129,7 @@ public class Validate {
      */
     public static void isTrue(boolean expression, String message, double value) {
         if (expression == false) {
-            throw new IllegalArgumentException(String.format(message, new Double(value)));
+            throw new IllegalArgumentException(String.format(message, Double.valueOf(value)));
         }
     }
 

Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/math/NumberUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/math/NumberUtils.java?rev=1153490&r1=1153489&r2=1153490&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/math/NumberUtils.java
(original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/math/NumberUtils.java
Wed Aug  3 13:53:35 2011
@@ -54,17 +54,17 @@ public class NumberUtils {
     /** Reusable Byte constant for minus one. */
     public static final Byte BYTE_MINUS_ONE = Byte.valueOf((byte) -1);
     /** Reusable Double constant for zero. */
-    public static final Double DOUBLE_ZERO = new Double(0.0d);
+    public static final Double DOUBLE_ZERO = Double.valueOf(0.0d);
     /** Reusable Double constant for one. */
-    public static final Double DOUBLE_ONE = new Double(1.0d);
+    public static final Double DOUBLE_ONE = Double.valueOf(1.0d);
     /** Reusable Double constant for minus one. */
-    public static final Double DOUBLE_MINUS_ONE = new Double(-1.0d);
+    public static final Double DOUBLE_MINUS_ONE = Double.valueOf(-1.0d);
     /** Reusable Float constant for zero. */
-    public static final Float FLOAT_ZERO = new Float(0.0f);
+    public static final Float FLOAT_ZERO = Float.valueOf(0.0f);
     /** Reusable Float constant for one. */
-    public static final Float FLOAT_ONE = new Float(1.0f);
+    public static final Float FLOAT_ONE = Float.valueOf(1.0f);
     /** Reusable Float constant for minus one. */
-    public static final Float FLOAT_MINUS_ONE = new Float(-1.0f);
+    public static final Float FLOAT_MINUS_ONE = Float.valueOf(-1.0f);
 
     /**
      * <p><code>NumberUtils</code> instances should NOT be constructed
in standard programming.
@@ -388,7 +388,7 @@ public class NumberUtils {
     // Byte.valueOf(String)
     // Double.valueOf(String)
     // Float.valueOf(String)
-    // new Float(String)
+    // Float.valueOf(String)
     // Integer.valueOf(String,int radix)
     // Integer.valueOf(String)
     // Integer.decode(String)
@@ -396,7 +396,7 @@ public class NumberUtils {
     // Integer.getInteger(String,int val)
     // Integer.getInteger(String,Integer val)
     // Integer.valueOf(String)
-    // new Double(String)
+    // Double.valueOf(String)
     // new Byte(String)
     // Long.valueOf(String)
     // Long.getLong(String)

Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableDouble.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableDouble.java?rev=1153490&r1=1153489&r2=1153490&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableDouble.java
(original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableDouble.java
Wed Aug  3 13:53:35 2011
@@ -82,7 +82,7 @@ public class MutableDouble extends Numbe
      * @return the value as a Double, never null
      */
     public Double getValue() {
-        return new Double(this.value);
+        return Double.valueOf(this.value);
     }
 
     /**

Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableFloat.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableFloat.java?rev=1153490&r1=1153489&r2=1153490&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableFloat.java
(original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableFloat.java
Wed Aug  3 13:53:35 2011
@@ -82,7 +82,7 @@ public class MutableFloat extends Number
      * @return the value as a Float, never null
      */
     public Float getValue() {
-        return new Float(this.value);
+        return Float.valueOf(this.value);
     }
 
     /**

Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java?rev=1153490&r1=1153489&r2=1153490&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java
(original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java
Wed Aug  3 13:53:35 2011
@@ -199,14 +199,14 @@ public class ArrayUtilsAddTest extends T
         assertTrue(Arrays.equals((new String[]{"a", "b", "c", "d"}), newArray));
         assertEquals(String.class, newArray.getClass().getComponentType());
 
-        Number[] numberArray1 = new Number[]{Integer.valueOf(1), new Double(2)};
-        newArray = ArrayUtils.add(numberArray1, new Float(3));
-        assertTrue(Arrays.equals((new Number[]{Integer.valueOf(1), new Double(2), new Float(3)}),
newArray));
+        Number[] numberArray1 = new Number[]{Integer.valueOf(1), Double.valueOf(2)};
+        newArray = ArrayUtils.add(numberArray1, Float.valueOf(3));
+        assertTrue(Arrays.equals((new Number[]{Integer.valueOf(1), Double.valueOf(2), Float.valueOf(3)}),
newArray));
         assertEquals(Number.class, newArray.getClass().getComponentType());
 
         numberArray1 = null;
-        newArray = ArrayUtils.add(numberArray1, new Float(3));
-        assertTrue(Arrays.equals((new Float[]{new Float(3)}), newArray));
+        newArray = ArrayUtils.add(numberArray1, Float.valueOf(3));
+        assertTrue(Arrays.equals((new Float[]{Float.valueOf(3)}), newArray));
         assertEquals(Float.class, newArray.getClass().getComponentType());
     }
     

Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java?rev=1153490&r1=1153489&r2=1153490&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java (original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java Wed
Aug  3 13:53:35 2011
@@ -2609,12 +2609,12 @@ public class ArrayUtilsTest extends Test
          
          assertTrue(Arrays.equals(
              new float[] {Float.MIN_VALUE, Float.MAX_VALUE, 9999999},
-             ArrayUtils.toPrimitive(new Float[] {new Float(Float.MIN_VALUE), 
-                 new Float(Float.MAX_VALUE), new Float(9999999)}))
+             ArrayUtils.toPrimitive(new Float[] {Float.valueOf(Float.MIN_VALUE), 
+                 Float.valueOf(Float.MAX_VALUE), Float.valueOf(9999999)}))
          );
 
          try {
-             ArrayUtils.toPrimitive(new Float[] {new Float(Float.MIN_VALUE), null});
+             ArrayUtils.toPrimitive(new Float[] {Float.valueOf(Float.MIN_VALUE), null});
              fail();
          } catch (NullPointerException ex) {}
      }
@@ -2628,13 +2628,13 @@ public class ArrayUtilsTest extends Test
          
          assertTrue(Arrays.equals(
              new float[] {Float.MIN_VALUE, Float.MAX_VALUE, 9999999},
-             ArrayUtils.toPrimitive(new Float[] {new Float(Float.MIN_VALUE), 
-                 new Float(Float.MAX_VALUE), new Float(9999999)},1)));
+             ArrayUtils.toPrimitive(new Float[] {Float.valueOf(Float.MIN_VALUE), 
+                 Float.valueOf(Float.MAX_VALUE), Float.valueOf(9999999)},1)));
          
          assertTrue(Arrays.equals(
              new float[] {Float.MIN_VALUE, Float.MAX_VALUE, 9999999},
-             ArrayUtils.toPrimitive(new Float[] {new Float(Float.MIN_VALUE), 
-                 null, new Float(9999999)}, Float.MAX_VALUE))
+             ArrayUtils.toPrimitive(new Float[] {Float.valueOf(Float.MIN_VALUE), 
+                 null, Float.valueOf(9999999)}, Float.MAX_VALUE))
          );
      }
      
@@ -2649,9 +2649,9 @@ public class ArrayUtilsTest extends Test
         assertTrue(
             Arrays.equals(
                 new Float[] {
-                    new Float(Float.MIN_VALUE),
-                    new Float(Float.MAX_VALUE),
-                    new Float(9999999)},
+                    Float.valueOf(Float.MIN_VALUE),
+                    Float.valueOf(Float.MAX_VALUE),
+                    Float.valueOf(9999999)},
             ArrayUtils.toObject(
                 new float[] { Float.MIN_VALUE, Float.MAX_VALUE, 9999999 })));
     }
@@ -2667,12 +2667,12 @@ public class ArrayUtilsTest extends Test
          
          assertTrue(Arrays.equals(
              new double[] {Double.MIN_VALUE, Double.MAX_VALUE, 9999999},
-             ArrayUtils.toPrimitive(new Double[] {new Double(Double.MIN_VALUE), 
-                 new Double(Double.MAX_VALUE), new Double(9999999)}))
+             ArrayUtils.toPrimitive(new Double[] {Double.valueOf(Double.MIN_VALUE), 
+                 Double.valueOf(Double.MAX_VALUE), Double.valueOf(9999999)}))
          );
 
          try {
-             ArrayUtils.toPrimitive(new Float[] {new Float(Float.MIN_VALUE), null});
+             ArrayUtils.toPrimitive(new Float[] {Float.valueOf(Float.MIN_VALUE), null});
              fail();
          } catch (NullPointerException ex) {}
      }
@@ -2686,13 +2686,13 @@ public class ArrayUtilsTest extends Test
          
          assertTrue(Arrays.equals(
              new double[] {Double.MIN_VALUE, Double.MAX_VALUE, 9999999},
-             ArrayUtils.toPrimitive(new Double[] {new Double(Double.MIN_VALUE), 
-                 new Double(Double.MAX_VALUE), new Double(9999999)},1)));
+             ArrayUtils.toPrimitive(new Double[] {Double.valueOf(Double.MIN_VALUE), 
+                 Double.valueOf(Double.MAX_VALUE), Double.valueOf(9999999)},1)));
          
          assertTrue(Arrays.equals(
              new double[] {Double.MIN_VALUE, Double.MAX_VALUE, 9999999},
-             ArrayUtils.toPrimitive(new Double[] {new Double(Double.MIN_VALUE), 
-                 null, new Double(9999999)}, Double.MAX_VALUE))
+             ArrayUtils.toPrimitive(new Double[] {Double.valueOf(Double.MIN_VALUE), 
+                 null, Double.valueOf(9999999)}, Double.MAX_VALUE))
          );
      }
      
@@ -2707,9 +2707,9 @@ public class ArrayUtilsTest extends Test
         assertTrue(
             Arrays.equals(
                 new Double[] {
-                    new Double(Double.MIN_VALUE),
-                    new Double(Double.MAX_VALUE),
-                    new Double(9999999)},
+                    Double.valueOf(Double.MIN_VALUE),
+                    Double.valueOf(Double.MAX_VALUE),
+                    Double.valueOf(9999999)},
             ArrayUtils.toObject(
                 new double[] { Double.MIN_VALUE, Double.MAX_VALUE, 9999999 })));
     }

Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java?rev=1153490&r1=1153489&r2=1153490&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
(original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
Wed Aug  3 13:53:35 2011
@@ -181,24 +181,24 @@ public class NumberUtilsTest {
     @Test
     public void testCreateNumber() {
         // a lot of things can go wrong
-        assertEquals("createNumber(String) 1 failed", new Float("1234.5"), NumberUtils.createNumber("1234.5"));
+        assertEquals("createNumber(String) 1 failed", Float.valueOf("1234.5"), NumberUtils.createNumber("1234.5"));
         assertEquals("createNumber(String) 2 failed", Integer.valueOf("12345"), NumberUtils.createNumber("12345"));
-        assertEquals("createNumber(String) 3 failed", new Double("1234.5"), NumberUtils.createNumber("1234.5D"));
-        assertEquals("createNumber(String) 3 failed", new Double("1234.5"), NumberUtils.createNumber("1234.5d"));
-        assertEquals("createNumber(String) 4 failed", new Float("1234.5"), NumberUtils.createNumber("1234.5F"));
-        assertEquals("createNumber(String) 4 failed", new Float("1234.5"), NumberUtils.createNumber("1234.5f"));
+        assertEquals("createNumber(String) 3 failed", Double.valueOf("1234.5"), NumberUtils.createNumber("1234.5D"));
+        assertEquals("createNumber(String) 3 failed", Double.valueOf("1234.5"), NumberUtils.createNumber("1234.5d"));
+        assertEquals("createNumber(String) 4 failed", Float.valueOf("1234.5"), NumberUtils.createNumber("1234.5F"));
+        assertEquals("createNumber(String) 4 failed", Float.valueOf("1234.5"), NumberUtils.createNumber("1234.5f"));
         assertEquals("createNumber(String) 5 failed", Long.valueOf(Integer.MAX_VALUE + 1L),
NumberUtils.createNumber(""
             + (Integer.MAX_VALUE + 1L)));
         assertEquals("createNumber(String) 6 failed", Long.valueOf(12345), NumberUtils.createNumber("12345L"));
         assertEquals("createNumber(String) 6 failed", Long.valueOf(12345), NumberUtils.createNumber("12345l"));
-        assertEquals("createNumber(String) 7 failed", new Float("-1234.5"), NumberUtils.createNumber("-1234.5"));
+        assertEquals("createNumber(String) 7 failed", Float.valueOf("-1234.5"), NumberUtils.createNumber("-1234.5"));
         assertEquals("createNumber(String) 8 failed", Integer.valueOf("-12345"), NumberUtils.createNumber("-12345"));
         assertTrue("createNumber(String) 9 failed", 0xFADE == NumberUtils.createNumber("0xFADE").intValue());
         assertTrue("createNumber(String) 10 failed", -0xFADE == NumberUtils.createNumber("-0xFADE").intValue());
-        assertEquals("createNumber(String) 11 failed", new Double("1.1E200"), NumberUtils.createNumber("1.1E200"));
-        assertEquals("createNumber(String) 12 failed", new Float("1.1E20"), NumberUtils.createNumber("1.1E20"));
-        assertEquals("createNumber(String) 13 failed", new Double("-1.1E200"), NumberUtils.createNumber("-1.1E200"));
-        assertEquals("createNumber(String) 14 failed", new Double("1.1E-200"), NumberUtils.createNumber("1.1E-200"));
+        assertEquals("createNumber(String) 11 failed", Double.valueOf("1.1E200"), NumberUtils.createNumber("1.1E200"));
+        assertEquals("createNumber(String) 12 failed", Float.valueOf("1.1E20"), NumberUtils.createNumber("1.1E20"));
+        assertEquals("createNumber(String) 13 failed", Double.valueOf("-1.1E200"), NumberUtils.createNumber("-1.1E200"));
+        assertEquals("createNumber(String) 14 failed", Double.valueOf("1.1E-200"), NumberUtils.createNumber("1.1E-200"));
         assertEquals("createNumber(null) failed", null, NumberUtils.createNumber(null));
         assertEquals("createNumber(String) failed", new BigInteger("12345678901234567890"),
NumberUtils
                 .createNumber("12345678901234567890L"));
@@ -216,7 +216,7 @@ public class NumberUtilsTest {
                 .createNumber("10" + Long.MAX_VALUE));
 
         // LANG-521
-        assertEquals("createNumber(String) LANG-521 failed", new Float("2."), NumberUtils.createNumber("2."));
+        assertEquals("createNumber(String) LANG-521 failed", Float.valueOf("2."), NumberUtils.createNumber("2."));
 
         // LANG-638
         assertFalse("createNumber(String) succeeded", checkCreateNumber("1eE"));
@@ -228,7 +228,7 @@ public class NumberUtilsTest {
 
     @Test
     public void testCreateFloat() {
-        assertEquals("createFloat(String) failed", new Float("1234.5"), NumberUtils.createFloat("1234.5"));
+        assertEquals("createFloat(String) failed", Float.valueOf("1234.5"), NumberUtils.createFloat("1234.5"));
         assertEquals("createFloat(null) failed", null, NumberUtils.createFloat(null));
         this.testCreateFloatFailure("");
         this.testCreateFloatFailure(" ");
@@ -248,7 +248,7 @@ public class NumberUtilsTest {
 
     @Test
     public void testCreateDouble() {
-        assertEquals("createDouble(String) failed", new Double("1234.5"), NumberUtils.createDouble("1234.5"));
+        assertEquals("createDouble(String) failed", Double.valueOf("1234.5"), NumberUtils.createDouble("1234.5"));
         assertEquals("createDouble(null) failed", null, NumberUtils.createDouble(null));
         this.testCreateDoubleFailure("");
         this.testCreateDoubleFailure(" ");

Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java?rev=1153490&r1=1153489&r2=1153490&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java
(original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java
Wed Aug  3 13:53:35 2011
@@ -36,7 +36,7 @@ public class MutableDoubleTest extends T
         
         assertEquals(1d, new MutableDouble(1d).doubleValue(), 0.0001d);
         
-        assertEquals(2d, new MutableDouble(new Double(2d)).doubleValue(), 0.0001d);
+        assertEquals(2d, new MutableDouble(Double.valueOf(2d)).doubleValue(), 0.0001d);
         assertEquals(3d, new MutableDouble(new MutableDouble(3d)).doubleValue(), 0.0001d);
         
         assertEquals(2d, new MutableDouble("2.0").doubleValue(), 0.0001d);
@@ -50,19 +50,19 @@ public class MutableDoubleTest extends T
     public void testGetSet() {
         final MutableDouble mutNum = new MutableDouble(0d);
         assertEquals(0d, new MutableDouble().doubleValue(), 0.0001d);
-        assertEquals(new Double(0), new MutableDouble().getValue());
+        assertEquals(Double.valueOf(0), new MutableDouble().getValue());
         
         mutNum.setValue(1);
         assertEquals(1d, mutNum.doubleValue(), 0.0001d);
-        assertEquals(new Double(1d), mutNum.getValue());
+        assertEquals(Double.valueOf(1d), mutNum.getValue());
         
-        mutNum.setValue(new Double(2d));
+        mutNum.setValue(Double.valueOf(2d));
         assertEquals(2d, mutNum.doubleValue(), 0.0001d);
-        assertEquals(new Double(2d), mutNum.getValue());
+        assertEquals(Double.valueOf(2d), mutNum.getValue());
         
         mutNum.setValue(new MutableDouble(3d));
         assertEquals(3d, mutNum.doubleValue(), 0.0001d);
-        assertEquals(new Double(3d), mutNum.getValue());
+        assertEquals(Double.valueOf(3d), mutNum.getValue());
         try {
             mutNum.setValue(null);
             fail();
@@ -93,7 +93,7 @@ public class MutableDoubleTest extends T
         assertEquals(false, mutNumB.equals(mutNumC));
         assertEquals(true, mutNumC.equals(mutNumC));
         assertEquals(false, mutNumA.equals(null));
-        assertEquals(false, mutNumA.equals(new Double(0d)));
+        assertEquals(false, mutNumA.equals(Double.valueOf(0d)));
         assertEquals(false, mutNumA.equals("0"));
     }
 
@@ -105,7 +105,7 @@ public class MutableDoubleTest extends T
         assertEquals(true, mutNumA.hashCode() == mutNumA.hashCode());
         assertEquals(true, mutNumA.hashCode() == mutNumB.hashCode());
         assertEquals(false, mutNumA.hashCode() == mutNumC.hashCode());
-        assertEquals(true, mutNumA.hashCode() == new Double(0d).hashCode());
+        assertEquals(true, mutNumA.hashCode() == Double.valueOf(0d).hashCode());
     }
 
     public void testCompareTo() {
@@ -132,8 +132,8 @@ public class MutableDoubleTest extends T
     }
 
     public void testToDouble() {
-        assertEquals(new Double(0d), new MutableDouble(0d).toDouble());
-        assertEquals(new Double(12.3d), new MutableDouble(12.3d).toDouble());
+        assertEquals(Double.valueOf(0d), new MutableDouble(0d).toDouble());
+        assertEquals(Double.valueOf(12.3d), new MutableDouble(12.3d).toDouble());
     }
 
     public void testIncrement() {
@@ -161,7 +161,7 @@ public class MutableDoubleTest extends T
 
     public void testAddValueObject() {
         MutableDouble mutNum = new MutableDouble(1);
-        mutNum.add(new Double(1.1d));
+        mutNum.add(Double.valueOf(1.1d));
         
         assertEquals(2.1d, mutNum.doubleValue(), 0.01d);
     }
@@ -175,7 +175,7 @@ public class MutableDoubleTest extends T
 
     public void testSubtractValueObject() {
         MutableDouble mutNum = new MutableDouble(1);
-        mutNum.subtract(new Double(0.9d));
+        mutNum.subtract(Double.valueOf(0.9d));
         
         assertEquals(0.1d, mutNum.doubleValue(), 0.01d);
     }

Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java?rev=1153490&r1=1153489&r2=1153490&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java
(original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java
Wed Aug  3 13:53:35 2011
@@ -36,7 +36,7 @@ public class MutableFloatTest extends Te
         
         assertEquals(1f, new MutableFloat(1f).floatValue(), 0.0001f);
         
-        assertEquals(2f, new MutableFloat(new Float(2f)).floatValue(), 0.0001f);
+        assertEquals(2f, new MutableFloat(Float.valueOf(2f)).floatValue(), 0.0001f);
         assertEquals(3f, new MutableFloat(new MutableFloat(3f)).floatValue(), 0.0001f);
 
         assertEquals(2f, new MutableFloat("2.0").floatValue(), 0.0001f);
@@ -50,19 +50,19 @@ public class MutableFloatTest extends Te
     public void testGetSet() {
         final MutableFloat mutNum = new MutableFloat(0f);
         assertEquals(0f, new MutableFloat().floatValue(), 0.0001f);
-        assertEquals(new Float(0), new MutableFloat().getValue());
+        assertEquals(Float.valueOf(0), new MutableFloat().getValue());
         
         mutNum.setValue(1);
         assertEquals(1f, mutNum.floatValue(), 0.0001f);
-        assertEquals(new Float(1f), mutNum.getValue());
+        assertEquals(Float.valueOf(1f), mutNum.getValue());
         
-        mutNum.setValue(new Float(2f));
+        mutNum.setValue(Float.valueOf(2f));
         assertEquals(2f, mutNum.floatValue(), 0.0001f);
-        assertEquals(new Float(2f), mutNum.getValue());
+        assertEquals(Float.valueOf(2f), mutNum.getValue());
         
         mutNum.setValue(new MutableFloat(3f));
         assertEquals(3f, mutNum.floatValue(), 0.0001f);
-        assertEquals(new Float(3f), mutNum.getValue());
+        assertEquals(Float.valueOf(3f), mutNum.getValue());
         try {
             mutNum.setValue(null);
             fail();
@@ -93,7 +93,7 @@ public class MutableFloatTest extends Te
         assertEquals(false, mutNumB.equals(mutNumC));
         assertEquals(true, mutNumC.equals(mutNumC));
         assertEquals(false, mutNumA.equals(null));
-        assertEquals(false, mutNumA.equals(new Float(0f)));
+        assertEquals(false, mutNumA.equals(Float.valueOf(0f)));
         assertEquals(false, mutNumA.equals("0"));
     }
 
@@ -105,7 +105,7 @@ public class MutableFloatTest extends Te
         assertEquals(true, mutNumA.hashCode() == mutNumA.hashCode());
         assertEquals(true, mutNumA.hashCode() == mutNumB.hashCode());
         assertEquals(false, mutNumA.hashCode() == mutNumC.hashCode());
-        assertEquals(true, mutNumA.hashCode() == new Float(0f).hashCode());
+        assertEquals(true, mutNumA.hashCode() == Float.valueOf(0f).hashCode());
     }
 
     public void testCompareTo() {
@@ -132,8 +132,8 @@ public class MutableFloatTest extends Te
     }
 
     public void testToFloat() {
-        assertEquals(new Float(0f), new MutableFloat(0f).toFloat());
-        assertEquals(new Float(12.3f), new MutableFloat(12.3f).toFloat());
+        assertEquals(Float.valueOf(0f), new MutableFloat(0f).toFloat());
+        assertEquals(Float.valueOf(12.3f), new MutableFloat(12.3f).toFloat());
     }
 
     public void testIncrement() {
@@ -161,7 +161,7 @@ public class MutableFloatTest extends Te
 
     public void testAddValueObject() {
         MutableFloat mutNum = new MutableFloat(1);
-        mutNum.add(new Float(1.1f));
+        mutNum.add(Float.valueOf(1.1f));
         
         assertEquals(2.1f, mutNum.floatValue(), 0.01f);
     }
@@ -175,7 +175,7 @@ public class MutableFloatTest extends Te
 
     public void testSubtractValueObject() {
         MutableFloat mutNum = new MutableFloat(1);
-        mutNum.subtract(new Float(0.9f));
+        mutNum.subtract(Float.valueOf(0.9f));
         
         assertEquals(0.1f, mutNum.floatValue(), 0.01f);
     }

Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableObjectTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableObjectTest.java?rev=1153490&r1=1153489&r2=1153490&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableObjectTest.java
(original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableObjectTest.java
Wed Aug  3 13:53:35 2011
@@ -88,7 +88,7 @@ public class MutableObjectTest extends T
 
     public void testToString() {
         assertEquals("HI", new MutableObject<String>("HI").toString());
-        assertEquals("10.0", new MutableObject<Double>(new Double(10)).toString());
+        assertEquals("10.0", new MutableObject<Double>(Double.valueOf(10)).toString());
         assertEquals("null", new MutableObject<Object>(null).toString());
     }
 

Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java?rev=1153490&r1=1153489&r2=1153490&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java
(original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java
Wed Aug  3 13:53:35 2011
@@ -46,8 +46,8 @@ public class FieldUtilsTest {
     static final String SS = "ss";
     static final Integer I0 = Integer.valueOf(0);
     static final Integer I1 = Integer.valueOf(1);
-    static final Double D0 = new Double(0.0);
-    static final Double D1 = new Double(1.0);
+    static final Double D0 = Double.valueOf(0.0);
+    static final Double D1 = Double.valueOf(1.0);
 
     private PublicChild publicChild;
     private PubliclyShadowedChild publiclyShadowedChild;
@@ -919,7 +919,7 @@ public class FieldUtilsTest {
         }
         field = parentClass.getDeclaredField("d");
         try {
-            FieldUtils.writeField(field, publicChild, new Double(Double.MAX_VALUE));
+            FieldUtils.writeField(field, publicChild, Double.valueOf(Double.MAX_VALUE));
         } catch (IllegalAccessException e) {
             // pass
         }
@@ -937,8 +937,8 @@ public class FieldUtilsTest {
         FieldUtils.writeField(field, publicChild, Integer.valueOf(Integer.MAX_VALUE), true);
         assertEquals(Integer.valueOf(Integer.MAX_VALUE), field.get(publicChild));
         field = parentClass.getDeclaredField("d");
-        FieldUtils.writeField(field, publicChild, new Double(Double.MAX_VALUE), true);
-        assertEquals(new Double(Double.MAX_VALUE), field.get(publicChild));
+        FieldUtils.writeField(field, publicChild, Double.valueOf(Double.MAX_VALUE), true);
+        assertEquals(Double.valueOf(Double.MAX_VALUE), field.get(publicChild));
     }
 
     @Test
@@ -958,7 +958,7 @@ public class FieldUtilsTest {
             // pass
         }
         try {
-            FieldUtils.writeField(publicChild, "d", new Double(1.0));
+            FieldUtils.writeField(publicChild, "d", Double.valueOf(1.0));
             fail("Expected IllegalArgumentException");
         } catch (IllegalArgumentException e) {
             // pass
@@ -970,8 +970,8 @@ public class FieldUtilsTest {
         assertEquals(Boolean.FALSE, FieldUtils.readField(publiclyShadowedChild, "b"));
         FieldUtils.writeField(publiclyShadowedChild, "i", Integer.valueOf(0));
         assertEquals(Integer.valueOf(0), FieldUtils.readField(publiclyShadowedChild, "i"));
-        FieldUtils.writeField(publiclyShadowedChild, "d", new Double(0.0));
-        assertEquals(new Double(0.0), FieldUtils.readField(publiclyShadowedChild, "d"));
+        FieldUtils.writeField(publiclyShadowedChild, "d", Double.valueOf(0.0));
+        assertEquals(Double.valueOf(0.0), FieldUtils.readField(publiclyShadowedChild, "d"));
 
         FieldUtils.writeField(privatelyShadowedChild, "s", "S");
         assertEquals("S", FieldUtils.readField(privatelyShadowedChild, "s"));
@@ -988,7 +988,7 @@ public class FieldUtilsTest {
             // pass
         }
         try {
-            FieldUtils.writeField(privatelyShadowedChild, "d", new Double(1.0));
+            FieldUtils.writeField(privatelyShadowedChild, "d", Double.valueOf(1.0));
             fail("Expected IllegalArgumentException");
         } catch (IllegalArgumentException e) {
             // pass
@@ -1003,8 +1003,8 @@ public class FieldUtilsTest {
         assertEquals(Boolean.TRUE, FieldUtils.readField(publicChild, "b", true));
         FieldUtils.writeField(publicChild, "i", Integer.valueOf(1), true);
         assertEquals(Integer.valueOf(1), FieldUtils.readField(publicChild, "i", true));
-        FieldUtils.writeField(publicChild, "d", new Double(1.0), true);
-        assertEquals(new Double(1.0), FieldUtils.readField(publicChild, "d", true));
+        FieldUtils.writeField(publicChild, "d", Double.valueOf(1.0), true);
+        assertEquals(Double.valueOf(1.0), FieldUtils.readField(publicChild, "d", true));
 
         FieldUtils.writeField(publiclyShadowedChild, "s", "S", true);
         assertEquals("S", FieldUtils.readField(publiclyShadowedChild, "s", true));
@@ -1012,8 +1012,8 @@ public class FieldUtilsTest {
         assertEquals(Boolean.FALSE, FieldUtils.readField(publiclyShadowedChild, "b", true));
         FieldUtils.writeField(publiclyShadowedChild, "i", Integer.valueOf(0), true);
         assertEquals(Integer.valueOf(0), FieldUtils.readField(publiclyShadowedChild, "i",
true));
-        FieldUtils.writeField(publiclyShadowedChild, "d", new Double(0.0), true);
-        assertEquals(new Double(0.0), FieldUtils.readField(publiclyShadowedChild, "d", true));
+        FieldUtils.writeField(publiclyShadowedChild, "d", Double.valueOf(0.0), true);
+        assertEquals(Double.valueOf(0.0), FieldUtils.readField(publiclyShadowedChild, "d",
true));
 
         FieldUtils.writeField(privatelyShadowedChild, "s", "S", true);
         assertEquals("S", FieldUtils.readField(privatelyShadowedChild, "s", true));
@@ -1021,8 +1021,8 @@ public class FieldUtilsTest {
         assertEquals(Boolean.FALSE, FieldUtils.readField(privatelyShadowedChild, "b", true));
         FieldUtils.writeField(privatelyShadowedChild, "i", Integer.valueOf(0), true);
         assertEquals(Integer.valueOf(0), FieldUtils.readField(privatelyShadowedChild, "i",
true));
-        FieldUtils.writeField(privatelyShadowedChild, "d", new Double(0.0), true);
-        assertEquals(new Double(0.0), FieldUtils.readField(privatelyShadowedChild, "d", true));
+        FieldUtils.writeField(privatelyShadowedChild, "d", Double.valueOf(0.0), true);
+        assertEquals(Double.valueOf(0.0), FieldUtils.readField(privatelyShadowedChild, "d",
true));
     }
 
     @Test
@@ -1046,7 +1046,7 @@ public class FieldUtilsTest {
             // pass
         }
         try {
-            FieldUtils.writeDeclaredField(publicChild, "d", new Double(1.0));
+            FieldUtils.writeDeclaredField(publicChild, "d", Double.valueOf(1.0));
             fail("Expected IllegalArgumentException");
         } catch (IllegalArgumentException e) {
             // pass
@@ -1058,8 +1058,8 @@ public class FieldUtilsTest {
         assertEquals(Boolean.FALSE, FieldUtils.readDeclaredField(publiclyShadowedChild, "b"));
         FieldUtils.writeDeclaredField(publiclyShadowedChild, "i", Integer.valueOf(0));
         assertEquals(Integer.valueOf(0), FieldUtils.readDeclaredField(publiclyShadowedChild,
"i"));
-        FieldUtils.writeDeclaredField(publiclyShadowedChild, "d", new Double(0.0));
-        assertEquals(new Double(0.0), FieldUtils.readDeclaredField(publiclyShadowedChild,
"d"));
+        FieldUtils.writeDeclaredField(publiclyShadowedChild, "d", Double.valueOf(0.0));
+        assertEquals(Double.valueOf(0.0), FieldUtils.readDeclaredField(publiclyShadowedChild,
"d"));
 
         try {
             FieldUtils.writeDeclaredField(privatelyShadowedChild, "s", "S");
@@ -1080,7 +1080,7 @@ public class FieldUtilsTest {
             // pass
         }
         try {
-            FieldUtils.writeDeclaredField(privatelyShadowedChild, "d", new Double(1.0));
+            FieldUtils.writeDeclaredField(privatelyShadowedChild, "d", Double.valueOf(1.0));
             fail("Expected IllegalArgumentException");
         } catch (IllegalArgumentException e) {
             // pass
@@ -1108,7 +1108,7 @@ public class FieldUtilsTest {
             // pass
         }
         try {
-            FieldUtils.writeDeclaredField(publicChild, "d", new Double(1.0), true);
+            FieldUtils.writeDeclaredField(publicChild, "d", Double.valueOf(1.0), true);
             fail("Expected IllegalArgumentException");
         } catch (IllegalArgumentException e) {
             // pass
@@ -1120,8 +1120,8 @@ public class FieldUtilsTest {
         assertEquals(Boolean.FALSE, FieldUtils.readDeclaredField(publiclyShadowedChild, "b",
true));
         FieldUtils.writeDeclaredField(publiclyShadowedChild, "i", Integer.valueOf(0), true);
         assertEquals(Integer.valueOf(0), FieldUtils.readDeclaredField(publiclyShadowedChild,
"i", true));
-        FieldUtils.writeDeclaredField(publiclyShadowedChild, "d", new Double(0.0), true);
-        assertEquals(new Double(0.0), FieldUtils.readDeclaredField(publiclyShadowedChild,
"d", true));
+        FieldUtils.writeDeclaredField(publiclyShadowedChild, "d", Double.valueOf(0.0), true);
+        assertEquals(Double.valueOf(0.0), FieldUtils.readDeclaredField(publiclyShadowedChild,
"d", true));
 
         FieldUtils.writeDeclaredField(privatelyShadowedChild, "s", "S", true);
         assertEquals("S", FieldUtils.readDeclaredField(privatelyShadowedChild, "s", true));
@@ -1129,8 +1129,8 @@ public class FieldUtilsTest {
         assertEquals(Boolean.FALSE, FieldUtils.readDeclaredField(privatelyShadowedChild,
"b", true));
         FieldUtils.writeDeclaredField(privatelyShadowedChild, "i", Integer.valueOf(0), true);
         assertEquals(Integer.valueOf(0), FieldUtils.readDeclaredField(privatelyShadowedChild,
"i", true));
-        FieldUtils.writeDeclaredField(privatelyShadowedChild, "d", new Double(0.0), true);
-        assertEquals(new Double(0.0), FieldUtils.readDeclaredField(privatelyShadowedChild,
"d", true));
+        FieldUtils.writeDeclaredField(privatelyShadowedChild, "d", Double.valueOf(0.0), true);
+        assertEquals(Double.valueOf(0.0), FieldUtils.readDeclaredField(privatelyShadowedChild,
"d", true));
     }
 
     @Test(expected=IllegalArgumentException.class)

Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java?rev=1153490&r1=1153489&r2=1153490&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java
(original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java
Wed Aug  3 13:53:35 2011
@@ -92,7 +92,7 @@ public class ExtendedMessageFormatTest e
     public void testExtendedAndBuiltInFormats() {
         Calendar cal = Calendar.getInstance();
         cal.set(2007, Calendar.JANUARY, 23, 18, 33, 05);
-        Object[] args = new Object[] {"John Doe", cal.getTime(), new Double("12345.67")};
+        Object[] args = new Object[] {"John Doe", cal.getTime(), Double.valueOf("12345.67")};
         String builtinsPattern = "DOB: {1,date,short} Salary: {2,number,currency}";
         String extendedPattern = "Name: {0,upper} ";
         String pattern = extendedPattern + builtinsPattern;
@@ -153,8 +153,8 @@ public class ExtendedMessageFormatTest e
 //     */
 //    public void testExtendedAndBuiltInWithChoiceFormat() {
 //        String pattern = "Choice: {0,choice,1.0#{0} {1,lower} {2,number}|2.0#{0} {1,upper}
{2,number,currency}}";
-//        Object[] lowArgs  = new Object[] {Integer.valueOf(1), "Low",  new Double("1234.56")};
-//        Object[] highArgs = new Object[] {Integer.valueOf(2), "High", new Double("9876.54")};
+//        Object[] lowArgs  = new Object[] {Integer.valueOf(1), "Low",  Double.valueOf("1234.56")};
+//        Object[] highArgs = new Object[] {Integer.valueOf(2), "High", Double.valueOf("9876.54")};
 //        Locale[] availableLocales = ChoiceFormat.getAvailableLocales();
 //        Locale[] testLocales = new Locale[availableLocales.length + 1];
 //        testLocales[0] = null;
@@ -188,7 +188,7 @@ public class ExtendedMessageFormatTest e
      * Test the built in choice format.
      */
     public void testBuiltInChoiceFormat() {
-        Object[] values = new Number[] {Integer.valueOf(1), new Double("2.2"), new Double("1234.5")};
+        Object[] values = new Number[] {Integer.valueOf(1), Double.valueOf("2.2"), Double.valueOf("1234.5")};
         String choicePattern = null;
         Locale[] availableLocales = ChoiceFormat.getAvailableLocales();
 
@@ -255,7 +255,7 @@ public class ExtendedMessageFormatTest e
      * Test the built in number formats.
      */
     public void testBuiltInNumberFormat() {
-        Object[] args = new Object[] {new Double("6543.21")};
+        Object[] args = new Object[] {Double.valueOf("6543.21")};
         Locale[] availableLocales = NumberFormat.getAvailableLocales();
         checkBuiltInFormat("1: {0,number}",            args, availableLocales);
         checkBuiltInFormat("2: {0,number,integer}",    args, availableLocales);



Mime
View raw message