From c58bbaaa4b638934494bfe02802890a28e178e7d Mon Sep 17 00:00:00 2001 From: Henri Yandell Date: Thu, 30 Apr 2009 07:40:02 +0000 Subject: [PATCH] Applying Hendrik Maryns' generics changes for Mutable classes from LANG-336 git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@770100 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/commons/lang/mutable/MutableBoolean.java | 5 ++--- .../org/apache/commons/lang/mutable/MutableByte.java | 5 ++--- .../org/apache/commons/lang/mutable/MutableDouble.java | 5 ++--- .../org/apache/commons/lang/mutable/MutableFloat.java | 5 ++--- .../org/apache/commons/lang/mutable/MutableInt.java | 5 ++--- .../org/apache/commons/lang/mutable/MutableLong.java | 5 ++--- .../org/apache/commons/lang/mutable/MutableShort.java | 5 ++--- .../commons/lang/mutable/MutableBooleanTest.java | 10 ---------- .../apache/commons/lang/mutable/MutableByteTest.java | 8 -------- .../apache/commons/lang/mutable/MutableDoubleTest.java | 8 -------- .../apache/commons/lang/mutable/MutableFloatTest.java | 8 -------- .../apache/commons/lang/mutable/MutableIntTest.java | 8 -------- .../apache/commons/lang/mutable/MutableLongTest.java | 8 -------- .../apache/commons/lang/mutable/MutableShortTest.java | 8 -------- 14 files changed, 14 insertions(+), 79 deletions(-) diff --git a/src/java/org/apache/commons/lang/mutable/MutableBoolean.java b/src/java/org/apache/commons/lang/mutable/MutableBoolean.java index a3d295183..dc9d0de55 100644 --- a/src/java/org/apache/commons/lang/mutable/MutableBoolean.java +++ b/src/java/org/apache/commons/lang/mutable/MutableBoolean.java @@ -29,7 +29,7 @@ import org.apache.commons.lang.BooleanUtils; * @author Apache Software Foundation * @version $Id$ */ -public class MutableBoolean implements Mutable, Serializable, Comparable { +public class MutableBoolean implements Mutable, Serializable, Comparable { /** * Required for serialization support. @@ -93,8 +93,7 @@ public class MutableBoolean implements Mutable, Serializable, Comparable { * @throws ClassCastException * if the argument is not a MutableInt */ - public int compareTo(Object obj) { - MutableBoolean other = (MutableBoolean) obj; + public int compareTo(MutableBoolean other) { boolean anotherVal = other.value; return value == anotherVal ? 0 : (value ? 1 : -1); } diff --git a/src/java/org/apache/commons/lang/mutable/MutableByte.java b/src/java/org/apache/commons/lang/mutable/MutableByte.java index 1de81e3fa..63bc9967c 100644 --- a/src/java/org/apache/commons/lang/mutable/MutableByte.java +++ b/src/java/org/apache/commons/lang/mutable/MutableByte.java @@ -23,7 +23,7 @@ package org.apache.commons.lang.mutable; * @since 2.1 * @version $Id$ */ -public class MutableByte extends Number implements Comparable, Mutable { +public class MutableByte extends Number implements Comparable, Mutable { /** * Required for serialization support. @@ -270,8 +270,7 @@ public class MutableByte extends Number implements Comparable, Mutable { * @return negative if this is less, zero if equal, positive if greater * @throws ClassCastException if the argument is not a MutableByte */ - public int compareTo(Object obj) { - MutableByte other = (MutableByte) obj; + public int compareTo(MutableByte other) { byte anotherVal = other.value; return value < anotherVal ? -1 : (value == anotherVal ? 0 : 1); } diff --git a/src/java/org/apache/commons/lang/mutable/MutableDouble.java b/src/java/org/apache/commons/lang/mutable/MutableDouble.java index cf41f63d8..e4e5c1d6a 100644 --- a/src/java/org/apache/commons/lang/mutable/MutableDouble.java +++ b/src/java/org/apache/commons/lang/mutable/MutableDouble.java @@ -25,7 +25,7 @@ import org.apache.commons.lang.math.NumberUtils; * @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. @@ -300,8 +300,7 @@ public class MutableDouble extends Number implements Comparable, Mutable { * @return negative if this is less, zero if equal, positive if greater * @throws ClassCastException if the argument is not a MutableDouble */ - public int compareTo(Object obj) { - MutableDouble other = (MutableDouble) obj; + public int compareTo(MutableDouble other) { double anotherVal = other.value; return Double.compare(value, anotherVal); } diff --git a/src/java/org/apache/commons/lang/mutable/MutableFloat.java b/src/java/org/apache/commons/lang/mutable/MutableFloat.java index 584de6f59..a2d1fcc07 100644 --- a/src/java/org/apache/commons/lang/mutable/MutableFloat.java +++ b/src/java/org/apache/commons/lang/mutable/MutableFloat.java @@ -25,7 +25,7 @@ import org.apache.commons.lang.math.NumberUtils; * @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. @@ -301,8 +301,7 @@ public class MutableFloat extends Number implements Comparable, Mutable { * the mutable to compare to * @return negative if this is less, zero if equal, positive if greater */ - public int compareTo(Object obj) { - MutableFloat other = (MutableFloat) obj; + public int compareTo(MutableFloat other) { float anotherVal = other.value; return Float.compare(value, anotherVal); } diff --git a/src/java/org/apache/commons/lang/mutable/MutableInt.java b/src/java/org/apache/commons/lang/mutable/MutableInt.java index 3a638603a..88a0dcb62 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. @@ -260,8 +260,7 @@ public class MutableInt extends Number implements Comparable, Mutable { * @return negative if this is less, zero if equal, positive if greater * @throws ClassCastException if the argument is not a MutableInt */ - public int compareTo(Object obj) { - MutableInt other = (MutableInt) obj; + public int compareTo(MutableInt other) { int anotherVal = other.value; return value < anotherVal ? -1 : (value == anotherVal ? 0 : 1); } diff --git a/src/java/org/apache/commons/lang/mutable/MutableLong.java b/src/java/org/apache/commons/lang/mutable/MutableLong.java index 460370bb7..6a06cce62 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. @@ -260,8 +260,7 @@ public class MutableLong extends Number implements Comparable, Mutable { * @return negative if this is less, zero if equal, positive if greater * @throws ClassCastException if the argument is not a MutableLong */ - public int compareTo(Object obj) { - MutableLong other = (MutableLong) obj; + public int compareTo(MutableLong other) { long anotherVal = other.value; return value < anotherVal ? -1 : (value == anotherVal ? 0 : 1); } diff --git a/src/java/org/apache/commons/lang/mutable/MutableShort.java b/src/java/org/apache/commons/lang/mutable/MutableShort.java index 8427b3803..ab7f5dea5 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. @@ -270,8 +270,7 @@ public class MutableShort extends Number implements Comparable, Mutable { * @return negative if this is less, zero if equal, positive if greater * @throws ClassCastException if the argument is not a MutableShort */ - public int compareTo(Object obj) { - MutableShort other = (MutableShort) obj; + public int compareTo(MutableShort other) { short anotherVal = other.value; return value < anotherVal ? -1 : (value == anotherVal ? 0 : 1); } diff --git a/src/test/org/apache/commons/lang/mutable/MutableBooleanTest.java b/src/test/org/apache/commons/lang/mutable/MutableBooleanTest.java index c11736a15..0a25dc3c2 100644 --- a/src/test/org/apache/commons/lang/mutable/MutableBooleanTest.java +++ b/src/test/org/apache/commons/lang/mutable/MutableBooleanTest.java @@ -58,16 +58,6 @@ public class MutableBooleanTest extends TestCase { fail(); } catch (NullPointerException ex) { } - try { - mutBool.compareTo(Boolean.FALSE); - fail(); - } catch (ClassCastException ex) { - } - try { - mutBool.compareTo("false"); - fail(); - } catch (ClassCastException ex) { - } } // ---------------------------------------------------------------- diff --git a/src/test/org/apache/commons/lang/mutable/MutableByteTest.java b/src/test/org/apache/commons/lang/mutable/MutableByteTest.java index 176e4e862..bc046ce5b 100644 --- a/src/test/org/apache/commons/lang/mutable/MutableByteTest.java +++ b/src/test/org/apache/commons/lang/mutable/MutableByteTest.java @@ -119,14 +119,6 @@ public class MutableByteTest extends TestCase { mutNum.compareTo(null); fail(); } catch (NullPointerException ex) {} - try { - mutNum.compareTo(Byte.valueOf((byte) 0)); - fail(); - } catch (ClassCastException ex) {} - try { - mutNum.compareTo("0"); - fail(); - } catch (ClassCastException ex) {} } public void testPrimitiveValues() { diff --git a/src/test/org/apache/commons/lang/mutable/MutableDoubleTest.java b/src/test/org/apache/commons/lang/mutable/MutableDoubleTest.java index 6677a7a64..2c37ed7cd 100644 --- a/src/test/org/apache/commons/lang/mutable/MutableDoubleTest.java +++ b/src/test/org/apache/commons/lang/mutable/MutableDoubleTest.java @@ -130,14 +130,6 @@ public class MutableDoubleTest extends TestCase { mutNum.compareTo(null); fail(); } catch (NullPointerException ex) {} - try { - mutNum.compareTo(new Double(0d)); - fail(); - } catch (ClassCastException ex) {} - try { - mutNum.compareTo("0"); - fail(); - } catch (ClassCastException ex) {} } public void testPrimitiveValues() { diff --git a/src/test/org/apache/commons/lang/mutable/MutableFloatTest.java b/src/test/org/apache/commons/lang/mutable/MutableFloatTest.java index eb7866f85..51d33ce9a 100644 --- a/src/test/org/apache/commons/lang/mutable/MutableFloatTest.java +++ b/src/test/org/apache/commons/lang/mutable/MutableFloatTest.java @@ -130,14 +130,6 @@ public class MutableFloatTest extends TestCase { mutNum.compareTo(null); fail(); } catch (NullPointerException ex) {} - try { - mutNum.compareTo(new Float(0f)); - fail(); - } catch (ClassCastException ex) {} - try { - mutNum.compareTo("0"); - fail(); - } catch (ClassCastException ex) {} } public void testPrimitiveValues() { diff --git a/src/test/org/apache/commons/lang/mutable/MutableIntTest.java b/src/test/org/apache/commons/lang/mutable/MutableIntTest.java index 45d6f2575..4a2d03cf4 100644 --- a/src/test/org/apache/commons/lang/mutable/MutableIntTest.java +++ b/src/test/org/apache/commons/lang/mutable/MutableIntTest.java @@ -126,14 +126,6 @@ public class MutableIntTest extends TestCase { mutNum.compareTo(null); fail(); } catch (NullPointerException ex) {} - try { - mutNum.compareTo(new Integer(0)); - fail(); - } catch (ClassCastException ex) {} - try { - mutNum.compareTo("0"); - fail(); - } catch (ClassCastException ex) {} } public void testPrimitiveValues() { diff --git a/src/test/org/apache/commons/lang/mutable/MutableLongTest.java b/src/test/org/apache/commons/lang/mutable/MutableLongTest.java index 7861fafa1..9058af829 100644 --- a/src/test/org/apache/commons/lang/mutable/MutableLongTest.java +++ b/src/test/org/apache/commons/lang/mutable/MutableLongTest.java @@ -119,14 +119,6 @@ public class MutableLongTest extends TestCase { mutNum.compareTo(null); fail(); } catch (NullPointerException ex) {} - try { - mutNum.compareTo(new Long(0)); - fail(); - } catch (ClassCastException ex) {} - try { - mutNum.compareTo("0"); - fail(); - } catch (ClassCastException ex) {} } public void testPrimitiveValues() { diff --git a/src/test/org/apache/commons/lang/mutable/MutableShortTest.java b/src/test/org/apache/commons/lang/mutable/MutableShortTest.java index 613d1ddd2..7f66f6f78 100644 --- a/src/test/org/apache/commons/lang/mutable/MutableShortTest.java +++ b/src/test/org/apache/commons/lang/mutable/MutableShortTest.java @@ -119,14 +119,6 @@ public class MutableShortTest extends TestCase { mutNum.compareTo(null); fail(); } catch (NullPointerException ex) {} - try { - mutNum.compareTo(new Short((short) 0)); - fail(); - } catch (ClassCastException ex) {} - try { - mutNum.compareTo("0"); - fail(); - } catch (ClassCastException ex) {} } public void testPrimitiveValues() {