make Boolean, Byte, Short, etc. implement Comparable

This commit is contained in:
Joel Dice
2007-10-28 18:51:08 -06:00
parent 7f1837fecd
commit 09cedfd7cb
5 changed files with 25 additions and 5 deletions

View File

@ -1,6 +1,6 @@
package java.lang;
public final class Boolean {
public final class Boolean implements Comparable<Boolean> {
public static final Class TYPE = Class.forCanonicalName("Z");
public static final Boolean FALSE = new Boolean(false);
@ -24,6 +24,10 @@ public final class Boolean {
return ("true".equals(s) ? Boolean.TRUE : Boolean.FALSE);
}
public int compareTo(Boolean o) {
return (value ? (o.value ? 0 : 1) : (o.value ? -1 : 0));
}
public boolean equals(Object o) {
return o instanceof Boolean && ((Boolean) o).value == value;
}