diff --git a/src/java/org/apache/commons/lang/mutable/MutableBoolean.java b/src/java/org/apache/commons/lang/mutable/MutableBoolean.java index fdf396a6d..3710582ff 100644 --- a/src/java/org/apache/commons/lang/mutable/MutableBoolean.java +++ b/src/java/org/apache/commons/lang/mutable/MutableBoolean.java @@ -80,6 +80,17 @@ public class MutableBoolean implements Mutable, Serializable, Comparabl 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. * diff --git a/src/java/org/apache/commons/lang/mutable/MutableDouble.java b/src/java/org/apache/commons/lang/mutable/MutableDouble.java index c6b9d373e..5d73336ca 100644 --- a/src/java/org/apache/commons/lang/mutable/MutableDouble.java +++ b/src/java/org/apache/commons/lang/mutable/MutableDouble.java @@ -175,10 +175,10 @@ public class MutableDouble extends Number implements Comparable, /** * 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()); } //----------------------------------------------------------------------- diff --git a/src/java/org/apache/commons/lang/mutable/MutableFloat.java b/src/java/org/apache/commons/lang/mutable/MutableFloat.java index c528301ea..26a953328 100644 --- a/src/java/org/apache/commons/lang/mutable/MutableFloat.java +++ b/src/java/org/apache/commons/lang/mutable/MutableFloat.java @@ -247,10 +247,10 @@ public class MutableFloat extends Number implements Comparable, Mu /** * 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()); } //----------------------------------------------------------------------- diff --git a/src/java/org/apache/commons/lang/mutable/MutableInt.java b/src/java/org/apache/commons/lang/mutable/MutableInt.java index 0599dc2ea..456821f18 100644 --- a/src/java/org/apache/commons/lang/mutable/MutableInt.java +++ b/src/java/org/apache/commons/lang/mutable/MutableInt.java @@ -231,10 +231,10 @@ public class MutableInt extends Number implements Comparable, Mutabl /** * 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()); } //----------------------------------------------------------------------- diff --git a/src/java/org/apache/commons/lang/mutable/MutableLong.java b/src/java/org/apache/commons/lang/mutable/MutableLong.java index f89f1e14b..e945718d1 100644 --- a/src/java/org/apache/commons/lang/mutable/MutableLong.java +++ b/src/java/org/apache/commons/lang/mutable/MutableLong.java @@ -229,10 +229,10 @@ public class MutableLong extends Number implements Comparable, Muta /** * 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()); } //----------------------------------------------------------------------- diff --git a/src/java/org/apache/commons/lang/mutable/MutableShort.java b/src/java/org/apache/commons/lang/mutable/MutableShort.java index b653a3ed6..82e14dbb7 100644 --- a/src/java/org/apache/commons/lang/mutable/MutableShort.java +++ b/src/java/org/apache/commons/lang/mutable/MutableShort.java @@ -239,10 +239,10 @@ public class MutableShort extends Number implements Comparable, Mu /** * 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()); } //----------------------------------------------------------------------- diff --git a/src/test/org/apache/commons/lang/mutable/MutableBooleanTest.java b/src/test/org/apache/commons/lang/mutable/MutableBooleanTest.java index 852e52d51..9bb8cff71 100644 --- a/src/test/org/apache/commons/lang/mutable/MutableBooleanTest.java +++ b/src/test/org/apache/commons/lang/mutable/MutableBooleanTest.java @@ -95,11 +95,15 @@ public class MutableBooleanTest extends TestCase { } 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);