commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scolebou...@apache.org
Subject svn commit: r830016 - in /commons/proper/lang/trunk/src: java/org/apache/commons/lang/mutable/ test/org/apache/commons/lang/mutable/
Date Mon, 26 Oct 2009 23:12:06 GMT
Author: scolebourne
Date: Mon Oct 26 23:12:05 2009
New Revision: 830016

URL: http://svn.apache.org/viewvc?rev=830016&view=rev
Log:
Use valueOf() to convert primitive to wrapper class

Modified:
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableBoolean.java
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableDouble.java
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableFloat.java
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableInt.java
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableLong.java
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableShort.java
    commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableBooleanTest.java

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableBoolean.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableBoolean.java?rev=830016&r1=830015&r2=830016&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableBoolean.java
(original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableBoolean.java
Mon Oct 26 23:12:05 2009
@@ -80,6 +80,17 @@
         return value;
     }
 
+    //-----------------------------------------------------------------------
+    /**
+     * Gets this mutable as an instance of Boolean.
+     *
+     * @return a Boolean instance containing the value from this mutable, never null
+     */
+    public Boolean toBoolean() {
+        return Boolean.valueOf(booleanValue());
+    }
+
+    //-----------------------------------------------------------------------
     /**
      * Compares this mutable to another in ascending order.
      * 

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableDouble.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableDouble.java?rev=830016&r1=830015&r2=830016&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableDouble.java
(original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableDouble.java
Mon Oct 26 23:12:05 2009
@@ -175,10 +175,10 @@
     /**
      * Gets this mutable as an instance of Double.
      *
-     * @return a Double instance containing the value from this mutable
+     * @return a Double instance containing the value from this mutable, never null
      */
     public Double toDouble() {
-        return new Double(doubleValue());
+        return Double.valueOf(doubleValue());
     }
 
     //-----------------------------------------------------------------------

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableFloat.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableFloat.java?rev=830016&r1=830015&r2=830016&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableFloat.java (original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableFloat.java Mon
Oct 26 23:12:05 2009
@@ -247,10 +247,10 @@
     /**
      * Gets this mutable as an instance of Float.
      *
-     * @return a Float instance containing the value from this mutable
+     * @return a Float instance containing the value from this mutable, never null
      */
     public Float toFloat() {
-        return new Float(floatValue());
+        return Float.valueOf(floatValue());
     }
 
     //-----------------------------------------------------------------------

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableInt.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableInt.java?rev=830016&r1=830015&r2=830016&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableInt.java (original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableInt.java Mon
Oct 26 23:12:05 2009
@@ -231,10 +231,10 @@
     /**
      * Gets this mutable as an instance of Integer.
      *
-     * @return a Integer instance containing the value from this mutable
+     * @return a Integer instance containing the value from this mutable, never null
      */
     public Integer toInteger() {
-        return new Integer(intValue());
+        return Integer.valueOf(intValue());
     }
 
     //-----------------------------------------------------------------------

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableLong.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableLong.java?rev=830016&r1=830015&r2=830016&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableLong.java (original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableLong.java Mon
Oct 26 23:12:05 2009
@@ -229,10 +229,10 @@
     /**
      * Gets this mutable as an instance of Long.
      *
-     * @return a Long instance containing the value from this mutable
+     * @return a Long instance containing the value from this mutable, never null
      */
     public Long toLong() {
-        return new Long(longValue());
+        return Long.valueOf(longValue());
     }
 
     //-----------------------------------------------------------------------

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableShort.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableShort.java?rev=830016&r1=830015&r2=830016&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableShort.java (original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableShort.java Mon
Oct 26 23:12:05 2009
@@ -239,10 +239,10 @@
     /**
      * Gets this mutable as an instance of Short.
      *
-     * @return a Short instance containing the value from this mutable
+     * @return a Short instance containing the value from this mutable, never null
      */
     public Short toShort() {
-        return new Short(shortValue());
+        return Short.valueOf(shortValue());
     }
 
     //-----------------------------------------------------------------------

Modified: commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableBooleanTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableBooleanTest.java?rev=830016&r1=830015&r2=830016&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableBooleanTest.java
(original)
+++ commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableBooleanTest.java
Mon Oct 26 23:12:05 2009
@@ -95,11 +95,15 @@
     }
 
     public void testGetSet() {
-        final MutableBoolean mutBool = new MutableBoolean(false);
         assertEquals(false, new MutableBoolean().booleanValue());
         assertEquals(Boolean.FALSE, new MutableBoolean().getValue());
+        
+        final MutableBoolean mutBool = new MutableBoolean(false);
+        assertEquals(Boolean.FALSE, mutBool.toBoolean());
+        assertEquals(false, mutBool.booleanValue());
 
         mutBool.setValue(Boolean.TRUE);
+        assertEquals(Boolean.TRUE, mutBool.toBoolean());
         assertEquals(true, mutBool.booleanValue());
 
         mutBool.setValue(false);



Mime
View raw message