Author: scolebourne
Date: Sat Aug 27 07:02:07 2005
New Revision: 240419

URL: http://svn.apache.org/viewcvs?rev=240419&view=rev
Log:
Add toType methods to return the primitive wrapper object

Modified:
    
jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableByte.java
    
jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableDouble.java
    
jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableFloat.java
    
jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableInt.java
    
jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableLong.java
    
jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableShort.java
    
jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableByteTest.java
    
jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableDoubleTest.java
    
jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableFloatTest.java
    
jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableIntTest.java
    
jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableLongTest.java
    
jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableShortTest.java

Modified: 
jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableByte.java
URL: 
http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableByte.java?rev=240419&r1=240418&r2=240419&view=diff
==============================================================================
--- 
jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableByte.java
 (original)
+++ 
jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableByte.java
 Sat Aug 27 07:02:07 2005
@@ -145,6 +145,16 @@
 
     //-----------------------------------------------------------------------
     /**
+     * Gets this mutable as an instance of Byte.
+     *
+     * @return a Byte instance containing the value from this mutable
+     */
+    public Byte toByte() {
+        return new Byte(byteValue());
+    }
+
+    //-----------------------------------------------------------------------
+    /**
      * Compares this object against the specified object. The result is 
<code>true</code> if and only if the argument
      * is not <code>null</code> and is a <code>MutableByte</code> object that 
contains the same <code>byte</code>
      * value as this object.

Modified: 
jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableDouble.java
URL: 
http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableDouble.java?rev=240419&r1=240418&r2=240419&view=diff
==============================================================================
--- 
jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableDouble.java
 (original)
+++ 
jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableDouble.java
 Sat Aug 27 07:02:07 2005
@@ -156,6 +156,16 @@
 
     //-----------------------------------------------------------------------
     /**
+     * Gets this mutable as an instance of Double.
+     *
+     * @return a Double instance containing the value from this mutable
+     */
+    public Double toDouble() {
+        return new Double(doubleValue());
+    }
+
+    //-----------------------------------------------------------------------
+    /**
      * Compares this object against the specified object. The result is 
<code>true</code> if and only if the argument
      * is not <code>null</code> and is a <code>Double</code> object that 
represents a double that has the identical
      * bit pattern to the bit pattern of the double represented by this 
object. For this purpose, two

Modified: 
jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableFloat.java
URL: 
http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableFloat.java?rev=240419&r1=240418&r2=240419&view=diff
==============================================================================
--- 
jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableFloat.java
 (original)
+++ 
jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableFloat.java
 Sat Aug 27 07:02:07 2005
@@ -154,6 +154,17 @@
         return Float.isInfinite(value);
     }
 
+    //-----------------------------------------------------------------------
+    /**
+     * Gets this mutable as an instance of Float.
+     *
+     * @return a Float instance containing the value from this mutable
+     */
+    public Float toFloat() {
+        return new Float(floatValue());
+    }
+
+    //-----------------------------------------------------------------------
     /**
      * Compares this object against some other object. The result is 
<code>true</code> if and only if the argument is
      * not <code>null</code> and is a <code>Float</code> object that 
represents a <code>float</code> that has the

Modified: 
jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableInt.java
URL: 
http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableInt.java?rev=240419&r1=240418&r2=240419&view=diff
==============================================================================
--- 
jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableInt.java
 (original)
+++ 
jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableInt.java
 Sat Aug 27 07:02:07 2005
@@ -136,6 +136,16 @@
 
     //-----------------------------------------------------------------------
     /**
+     * Gets this mutable as an instance of Integer.
+     *
+     * @return a Integer instance containing the value from this mutable
+     */
+    public Integer toInteger() {
+        return new Integer(intValue());
+    }
+
+    //-----------------------------------------------------------------------
+    /**
      * Compares this object to the specified object. The result is 
<code>true</code> if and only if the argument is
      * not <code>null</code> and is an <code>MutableInt</code> object that 
contains the same <code>int</code> value
      * as this object.

Modified: 
jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableLong.java
URL: 
http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableLong.java?rev=240419&r1=240418&r2=240419&view=diff
==============================================================================
--- 
jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableLong.java
 (original)
+++ 
jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableLong.java
 Sat Aug 27 07:02:07 2005
@@ -136,6 +136,16 @@
 
     //-----------------------------------------------------------------------
     /**
+     * Gets this mutable as an instance of Long.
+     *
+     * @return a Long instance containing the value from this mutable
+     */
+    public Long toLong() {
+        return new Long(longValue());
+    }
+
+    //-----------------------------------------------------------------------
+    /**
      * Compares this object against the specified object. The result is 
<code>true</code> if and only if the argument
      * is not <code>null</code> and is a <code>MutableLong</code> object that 
contains the same <code>long</code>
      * value as this object.

Modified: 
jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableShort.java
URL: 
http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableShort.java?rev=240419&r1=240418&r2=240419&view=diff
==============================================================================
--- 
jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableShort.java
 (original)
+++ 
jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableShort.java
 Sat Aug 27 07:02:07 2005
@@ -145,6 +145,16 @@
 
     //-----------------------------------------------------------------------
     /**
+     * Gets this mutable as an instance of Short.
+     *
+     * @return a Short instance containing the value from this mutable
+     */
+    public Short toShort() {
+        return new Short(shortValue());
+    }
+
+    //-----------------------------------------------------------------------
+    /**
      * Compares this object against the specified object. The result is 
<code>true</code> if and only if the argument
      * is not <code>null</code> and is a <code>MutableShort</code> object that 
contains the same <code>short</code>
      * value as this object.

Modified: 
jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableByteTest.java
URL: 
http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableByteTest.java?rev=240419&r1=240418&r2=240419&view=diff
==============================================================================
--- 
jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableByteTest.java
 (original)
+++ 
jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableByteTest.java
 Sat Aug 27 07:02:07 2005
@@ -139,6 +139,11 @@
         assertEquals( 1L, mutNum.longValue() );
     }
 
+    public void testToByte() {
+        assertEquals(new Byte((byte) 0), new MutableByte((byte) 0).toByte());
+        assertEquals(new Byte((byte) 123), new MutableByte((byte) 
123).toByte());
+    }
+
     public void testToString() {
         assertEquals("0", new MutableByte((byte) 0).toString());
         assertEquals("10", new MutableByte((byte) 10).toString());

Modified: 
jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableDoubleTest.java
URL: 
http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableDoubleTest.java?rev=240419&r1=240418&r2=240419&view=diff
==============================================================================
--- 
jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableDoubleTest.java
 (original)
+++ 
jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableDoubleTest.java
 Sat Aug 27 07:02:07 2005
@@ -150,6 +150,11 @@
         assertEquals( 1L, mutNum.longValue() );
     }
 
+    public void testToDouble() {
+        assertEquals(new Double(0d), new MutableDouble(0d).toDouble());
+        assertEquals(new Double(12.3d), new MutableDouble(12.3d).toDouble());
+    }
+
     public void testToString() {
         assertEquals("0.0", new MutableDouble(0d).toString());
         assertEquals("10.0", new MutableDouble(10d).toString());

Modified: 
jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableFloatTest.java
URL: 
http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableFloatTest.java?rev=240419&r1=240418&r2=240419&view=diff
==============================================================================
--- 
jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableFloatTest.java
 (original)
+++ 
jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableFloatTest.java
 Sat Aug 27 07:02:07 2005
@@ -150,6 +150,11 @@
         assertEquals( 1L, mutNum.longValue() );
     }
 
+    public void testToFloat() {
+        assertEquals(new Float(0f), new MutableFloat(0f).toFloat());
+        assertEquals(new Float(12.3f), new MutableFloat(12.3f).toFloat());
+    }
+
     public void testToString() {
         assertEquals("0.0", new MutableFloat(0f).toString());
         assertEquals("10.0", new MutableFloat(10f).toString());

Modified: 
jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableIntTest.java
URL: 
http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableIntTest.java?rev=240419&r1=240418&r2=240419&view=diff
==============================================================================
--- 
jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableIntTest.java
 (original)
+++ 
jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableIntTest.java
 Sat Aug 27 07:02:07 2005
@@ -145,6 +145,11 @@
         assertEquals( 1L, mutNum.longValue() );
     }
 
+    public void testToInteger() {
+        assertEquals(new Integer(0), new MutableInt(0).toInteger());
+        assertEquals(new Integer(123), new MutableInt(123).toInteger());
+    }
+
     public void testToString() {
         assertEquals("0", new MutableInt(0).toString());
         assertEquals("10", new MutableInt(10).toString());

Modified: 
jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableLongTest.java
URL: 
http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableLongTest.java?rev=240419&r1=240418&r2=240419&view=diff
==============================================================================
--- 
jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableLongTest.java
 (original)
+++ 
jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableLongTest.java
 Sat Aug 27 07:02:07 2005
@@ -139,6 +139,11 @@
         assertEquals( 1L, mutNum.longValue() );
     }
 
+    public void testToLong() {
+        assertEquals(new Long(0L), new MutableLong(0L).toLong());
+        assertEquals(new Long(123L), new MutableLong(123L).toLong());
+    }
+
     public void testToString() {
         assertEquals("0", new MutableLong(0).toString());
         assertEquals("10", new MutableLong(10).toString());

Modified: 
jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableShortTest.java
URL: 
http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableShortTest.java?rev=240419&r1=240418&r2=240419&view=diff
==============================================================================
--- 
jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableShortTest.java
 (original)
+++ 
jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableShortTest.java
 Sat Aug 27 07:02:07 2005
@@ -139,6 +139,11 @@
         assertEquals( 1L, mutNum.longValue() );
     }
 
+    public void testToShort() {
+        assertEquals(new Short((short) 0), new MutableShort((short) 
0).toShort());
+        assertEquals(new Short((short) 123), new MutableShort((short) 
123).toShort());
+    }
+
     public void testToString() {
         assertEquals("0", new MutableShort((short) 0).toString());
         assertEquals("10", new MutableShort((short) 10).toString());



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to