diff --git a/src/java/org/apache/commons/lang/mutable/MutableBoolean.java b/src/java/org/apache/commons/lang/mutable/MutableBoolean.java index a1c5103d2..fdf396a6d 100644 --- a/src/java/org/apache/commons/lang/mutable/MutableBoolean.java +++ b/src/java/org/apache/commons/lang/mutable/MutableBoolean.java @@ -27,7 +27,7 @@ import java.io.Serializable; * @author Apache Software Foundation * @version $Id$ */ -public class MutableBoolean implements Mutable, Serializable, Comparable { +public class MutableBoolean implements Mutable, Serializable, Comparable { /** * Required for serialization support. @@ -88,8 +88,6 @@ public class MutableBoolean implements Mutable, Serializable, Comparable, Mutable { +public class MutableByte extends Number implements Comparable, Mutable { /** * Required for serialization support. @@ -72,7 +72,7 @@ public class MutableByte extends Number implements Comparable, Muta * * @return the value as a Byte */ - public Object getValue() { + public Byte getValue() { return Byte.valueOf(this.value); } @@ -93,11 +93,9 @@ public class MutableByte extends Number implements Comparable, Muta * the value to set * @throws NullPointerException * if the object is null - * @throws ClassCastException - * if the type is not a {@link Number} */ - public void setValue(Object value) { - setValue(((Number) value).byteValue()); + public void setValue(Number value) { + this.value = value.byteValue(); } //----------------------------------------------------------------------- diff --git a/src/java/org/apache/commons/lang/mutable/MutableDouble.java b/src/java/org/apache/commons/lang/mutable/MutableDouble.java index 2b0f7d87f..cabd5610a 100644 --- a/src/java/org/apache/commons/lang/mutable/MutableDouble.java +++ b/src/java/org/apache/commons/lang/mutable/MutableDouble.java @@ -23,7 +23,7 @@ package org.apache.commons.lang.mutable; * @since 2.1 * @version $Id$ */ -public class MutableDouble extends Number implements Comparable, Mutable { +public class MutableDouble extends Number implements Comparable, Mutable { /** * Required for serialization support. @@ -72,7 +72,7 @@ public class MutableDouble extends Number implements Comparable, * * @return the value as a Double */ - public Object getValue() { + public Double getValue() { return new Double(this.value); } @@ -93,11 +93,9 @@ public class MutableDouble extends Number implements Comparable, * the value to set * @throws NullPointerException * if the object is null - * @throws ClassCastException - * if the type is not a {@link Number} */ - public void setValue(Object value) { - setValue(((Number) value).doubleValue()); + public void setValue(Number value) { + this.value = value.doubleValue(); } //----------------------------------------------------------------------- @@ -296,7 +294,6 @@ public class MutableDouble extends Number implements Comparable, * @param other * the mutable to compare to * @return negative if this is less, zero if equal, positive if greater - * @throws ClassCastException if the argument is not a MutableDouble */ public int compareTo(MutableDouble other) { double anotherVal = other.value; diff --git a/src/java/org/apache/commons/lang/mutable/MutableFloat.java b/src/java/org/apache/commons/lang/mutable/MutableFloat.java index 50419a2cd..04e03fbe0 100644 --- a/src/java/org/apache/commons/lang/mutable/MutableFloat.java +++ b/src/java/org/apache/commons/lang/mutable/MutableFloat.java @@ -23,7 +23,7 @@ package org.apache.commons.lang.mutable; * @since 2.1 * @version $Id$ */ -public class MutableFloat extends Number implements Comparable, Mutable { +public class MutableFloat extends Number implements Comparable, Mutable { /** * Required for serialization support. @@ -72,7 +72,7 @@ public class MutableFloat extends Number implements Comparable, Mu * * @return the value as a Float */ - public Object getValue() { + public Float getValue() { return new Float(this.value); } @@ -93,11 +93,9 @@ public class MutableFloat extends Number implements Comparable, Mu * the value to set * @throws NullPointerException * if the object is null - * @throws ClassCastException - * if the type is not a {@link Number} */ - public void setValue(Object value) { - setValue(((Number) value).floatValue()); + public void setValue(Number value) { + this.value = value.floatValue(); } //----------------------------------------------------------------------- diff --git a/src/java/org/apache/commons/lang/mutable/MutableInt.java b/src/java/org/apache/commons/lang/mutable/MutableInt.java index 20600e61e..668b717e5 100644 --- a/src/java/org/apache/commons/lang/mutable/MutableInt.java +++ b/src/java/org/apache/commons/lang/mutable/MutableInt.java @@ -23,7 +23,7 @@ package org.apache.commons.lang.mutable; * @since 2.1 * @version $Id$ */ -public class MutableInt extends Number implements Comparable, Mutable { +public class MutableInt extends Number implements Comparable, Mutable { /** * Required for serialization support. @@ -72,7 +72,7 @@ public class MutableInt extends Number implements Comparable, Mutabl * * @return the value as a Integer */ - public Object getValue() { + public Integer getValue() { return new Integer(this.value); } @@ -96,8 +96,8 @@ public class MutableInt extends Number implements Comparable, Mutabl * @throws ClassCastException * if the type is not a {@link Number} */ - public void setValue(Object value) { - setValue(((Number) value).intValue()); + public void setValue(Number value) { + this.value = value.intValue(); } //----------------------------------------------------------------------- @@ -258,7 +258,6 @@ public class MutableInt extends Number implements Comparable, Mutabl * @param other * the mutable to compare to * @return negative if this is less, zero if equal, positive if greater - * @throws ClassCastException if the argument is not a MutableInt */ public int compareTo(MutableInt other) { int anotherVal = other.value; diff --git a/src/java/org/apache/commons/lang/mutable/MutableLong.java b/src/java/org/apache/commons/lang/mutable/MutableLong.java index 9e4717486..f2282fab2 100644 --- a/src/java/org/apache/commons/lang/mutable/MutableLong.java +++ b/src/java/org/apache/commons/lang/mutable/MutableLong.java @@ -23,7 +23,7 @@ package org.apache.commons.lang.mutable; * @since 2.1 * @version $Id$ */ -public class MutableLong extends Number implements Comparable, Mutable { +public class MutableLong extends Number implements Comparable, Mutable { /** * Required for serialization support. @@ -72,7 +72,7 @@ public class MutableLong extends Number implements Comparable, Muta * * @return the value as a Long */ - public Object getValue() { + public Long getValue() { return new Long(this.value); } @@ -93,11 +93,9 @@ public class MutableLong extends Number implements Comparable, Muta * the value to set * @throws NullPointerException * if the object is null - * @throws ClassCastException - * if the type is not a {@link Number} */ - public void setValue(Object value) { - setValue(((Number) value).longValue()); + public void setValue(Number value) { + this.value = value.longValue(); } //----------------------------------------------------------------------- @@ -258,7 +256,6 @@ public class MutableLong extends Number implements Comparable, Muta * @param other * the mutable to compare to * @return negative if this is less, zero if equal, positive if greater - * @throws ClassCastException if the argument is not a MutableLong */ public int compareTo(MutableLong other) { long anotherVal = other.value; diff --git a/src/java/org/apache/commons/lang/mutable/MutableShort.java b/src/java/org/apache/commons/lang/mutable/MutableShort.java index 9e0a78919..35d222fbe 100644 --- a/src/java/org/apache/commons/lang/mutable/MutableShort.java +++ b/src/java/org/apache/commons/lang/mutable/MutableShort.java @@ -23,7 +23,7 @@ package org.apache.commons.lang.mutable; * @since 2.1 * @version $Id$ */ -public class MutableShort extends Number implements Comparable, Mutable { +public class MutableShort extends Number implements Comparable, Mutable { /** * Required for serialization support. @@ -72,7 +72,7 @@ public class MutableShort extends Number implements Comparable, Mu * * @return the value as a Short */ - public Object getValue() { + public Short getValue() { return new Short(this.value); } @@ -93,11 +93,9 @@ public class MutableShort extends Number implements Comparable, Mu * the value to set * @throws NullPointerException * if the object is null - * @throws ClassCastException - * if the type is not a {@link Number} */ - public void setValue(Object value) { - setValue(((Number) value).shortValue()); + public void setValue(Number value) { + this.value = value.shortValue(); } //----------------------------------------------------------------------- @@ -268,7 +266,6 @@ public class MutableShort extends Number implements Comparable, Mu * @param other * the mutable to compare to * @return negative if this is less, zero if equal, positive if greater - * @throws ClassCastException if the argument is not a MutableShort */ public int compareTo(MutableShort other) { short anotherVal = other.value; diff --git a/src/test/org/apache/commons/lang/mutable/MutableBooleanTest.java b/src/test/org/apache/commons/lang/mutable/MutableBooleanTest.java index 0a25dc3c2..852e52d51 100644 --- a/src/test/org/apache/commons/lang/mutable/MutableBooleanTest.java +++ b/src/test/org/apache/commons/lang/mutable/MutableBooleanTest.java @@ -113,11 +113,6 @@ public class MutableBooleanTest extends TestCase { fail(); } catch (NullPointerException ex) { } - try { - mutBool.setValue("false"); - fail(); - } catch (ClassCastException ex) { - } } public void testHashCode() { diff --git a/src/test/org/apache/commons/lang/mutable/MutableByteTest.java b/src/test/org/apache/commons/lang/mutable/MutableByteTest.java index bc046ce5b..5e67070c6 100644 --- a/src/test/org/apache/commons/lang/mutable/MutableByteTest.java +++ b/src/test/org/apache/commons/lang/mutable/MutableByteTest.java @@ -75,10 +75,6 @@ public class MutableByteTest extends TestCase { mutNum.setValue(null); fail(); } catch (NullPointerException ex) {} - try { - mutNum.setValue("0"); - fail(); - } catch (ClassCastException ex) {} } public void testEquals() { diff --git a/src/test/org/apache/commons/lang/mutable/MutableDoubleTest.java b/src/test/org/apache/commons/lang/mutable/MutableDoubleTest.java index 2c37ed7cd..3f0392302 100644 --- a/src/test/org/apache/commons/lang/mutable/MutableDoubleTest.java +++ b/src/test/org/apache/commons/lang/mutable/MutableDoubleTest.java @@ -75,10 +75,6 @@ public class MutableDoubleTest extends TestCase { mutNum.setValue(null); fail(); } catch (NullPointerException ex) {} - try { - mutNum.setValue("0"); - fail(); - } catch (ClassCastException ex) {} } public void testNanInfinite() { diff --git a/src/test/org/apache/commons/lang/mutable/MutableFloatTest.java b/src/test/org/apache/commons/lang/mutable/MutableFloatTest.java index 51d33ce9a..a0e7052f1 100644 --- a/src/test/org/apache/commons/lang/mutable/MutableFloatTest.java +++ b/src/test/org/apache/commons/lang/mutable/MutableFloatTest.java @@ -75,10 +75,6 @@ public class MutableFloatTest extends TestCase { mutNum.setValue(null); fail(); } catch (NullPointerException ex) {} - try { - mutNum.setValue("0"); - fail(); - } catch (ClassCastException ex) {} } public void testNanInfinite() { diff --git a/src/test/org/apache/commons/lang/mutable/MutableIntTest.java b/src/test/org/apache/commons/lang/mutable/MutableIntTest.java index 4a2d03cf4..10dcb0446 100644 --- a/src/test/org/apache/commons/lang/mutable/MutableIntTest.java +++ b/src/test/org/apache/commons/lang/mutable/MutableIntTest.java @@ -75,10 +75,6 @@ public class MutableIntTest extends TestCase { mutNum.setValue(null); fail(); } catch (NullPointerException ex) {} - try { - mutNum.setValue("0"); - fail(); - } catch (ClassCastException ex) {} } public void testEquals() { diff --git a/src/test/org/apache/commons/lang/mutable/MutableLongTest.java b/src/test/org/apache/commons/lang/mutable/MutableLongTest.java index 9058af829..f23413db1 100644 --- a/src/test/org/apache/commons/lang/mutable/MutableLongTest.java +++ b/src/test/org/apache/commons/lang/mutable/MutableLongTest.java @@ -75,10 +75,6 @@ public class MutableLongTest extends TestCase { mutNum.setValue(null); fail(); } catch (NullPointerException ex) {} - try { - mutNum.setValue("0"); - fail(); - } catch (ClassCastException ex) {} } public void testEquals() { diff --git a/src/test/org/apache/commons/lang/mutable/MutableObjectTest.java b/src/test/org/apache/commons/lang/mutable/MutableObjectTest.java index 5b5704d62..d746d4f71 100644 --- a/src/test/org/apache/commons/lang/mutable/MutableObjectTest.java +++ b/src/test/org/apache/commons/lang/mutable/MutableObjectTest.java @@ -43,17 +43,17 @@ public class MutableObjectTest extends TestCase { // ---------------------------------------------------------------- public void testConstructors() { - assertEquals(null, new MutableObject().getValue()); + assertEquals(null, new MutableObject().getValue()); Integer i = new Integer(6); - assertSame(i, new MutableObject(i).getValue()); - assertSame("HI", new MutableObject("HI").getValue()); - assertSame(null, new MutableObject(null).getValue()); + assertSame(i, new MutableObject(i).getValue()); + assertSame("HI", new MutableObject("HI").getValue()); + assertSame(null, new MutableObject(null).getValue()); } public void testGetSet() { - final MutableObject mutNum = new MutableObject(); - assertEquals(null, new MutableObject().getValue()); + final MutableObject mutNum = new MutableObject(); + assertEquals(null, new MutableObject().getValue()); mutNum.setValue("HELLO"); assertSame("HELLO", mutNum.getValue()); @@ -63,10 +63,10 @@ public class MutableObjectTest extends TestCase { } public void testEquals() { - final MutableObject mutNumA = new MutableObject("ALPHA"); - final MutableObject mutNumB = new MutableObject("ALPHA"); - final MutableObject mutNumC = new MutableObject("BETA"); - final MutableObject mutNumD = new MutableObject(null); + final MutableObject mutNumA = new MutableObject("ALPHA"); + final MutableObject mutNumB = new MutableObject("ALPHA"); + final MutableObject mutNumC = new MutableObject("BETA"); + final MutableObject mutNumD = new MutableObject(null); assertEquals(true, mutNumA.equals(mutNumA)); assertEquals(true, mutNumA.equals(mutNumB)); @@ -84,10 +84,10 @@ public class MutableObjectTest extends TestCase { } public void testHashCode() { - final MutableObject mutNumA = new MutableObject("ALPHA"); - final MutableObject mutNumB = new MutableObject("ALPHA"); - final MutableObject mutNumC = new MutableObject("BETA"); - final MutableObject mutNumD = new MutableObject(null); + final MutableObject mutNumA = new MutableObject("ALPHA"); + final MutableObject mutNumB = new MutableObject("ALPHA"); + final MutableObject mutNumC = new MutableObject("BETA"); + final MutableObject mutNumD = new MutableObject(null); assertEquals(true, mutNumA.hashCode() == mutNumA.hashCode()); assertEquals(true, mutNumA.hashCode() == mutNumB.hashCode()); @@ -98,9 +98,9 @@ public class MutableObjectTest extends TestCase { } public void testToString() { - assertEquals("HI", new MutableObject("HI").toString()); - assertEquals("10.0", new MutableObject(new Double(10)).toString()); - assertEquals("null", new MutableObject(null).toString()); + assertEquals("HI", new MutableObject("HI").toString()); + assertEquals("10.0", new MutableObject(new Double(10)).toString()); + assertEquals("null", new MutableObject(null).toString()); } } diff --git a/src/test/org/apache/commons/lang/mutable/MutableShortTest.java b/src/test/org/apache/commons/lang/mutable/MutableShortTest.java index 7f66f6f78..497d4acc1 100644 --- a/src/test/org/apache/commons/lang/mutable/MutableShortTest.java +++ b/src/test/org/apache/commons/lang/mutable/MutableShortTest.java @@ -75,10 +75,6 @@ public class MutableShortTest extends TestCase { mutNum.setValue(null); fail(); } catch (NullPointerException ex) {} - try { - mutNum.setValue("0"); - fail(); - } catch (ClassCastException ex) {} } public void testEquals() {