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
This commit is contained in:
Henri Yandell 2009-04-30 07:40:02 +00:00
parent 0904ecd4fa
commit c58bbaaa4b
14 changed files with 14 additions and 79 deletions

View File

@ -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<MutableBoolean> {
/**
* 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);
}

View File

@ -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<MutableByte>, 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);
}

View File

@ -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<MutableDouble>, 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);
}

View File

@ -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<MutableFloat>, 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);
}

View File

@ -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<MutableInt>, 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);
}

View File

@ -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<MutableLong>, 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);
}

View File

@ -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<MutableShort>, 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);
}

View File

@ -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) {
}
}
// ----------------------------------------------------------------

View File

@ -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() {

View File

@ -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() {

View File

@ -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() {

View File

@ -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() {

View File

@ -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() {

View File

@ -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() {