Name: rmT116609 Date: 03/19/2002
FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)
FULL OPERATING SYSTEM VERSION :
Microsoft Windows 2000 [Version 5.00.2195]
A DESCRIPTION OF THE PROBLEM :
For consistency of wrapping primitive types (int,float,...) to their object-counterparts (java.lang.Integer,java.lang.Float,...) java.lang.Boolean
should implement the java.lang.Comparable interface.
I'm working on a object-database completly stored in memory, backed by a JDBC-connected database. For easy and fast queries, i use java.util.TreeMap to provide field- based sorted lists of the stored records in memory, using
the key's natural order. Works fine with most (important) JDBC-Types (all numbers, strings, dates) but not with booleans.
// suggestion, analogous to java.lang.Integer
public int compareTo(Boolean anotherBoolean) {
boolean thisValue=this.value;
boolean thatValue=anotherBoolean.value;
return (int) thisValue ? (thatValue ? (int)0 : (int)-1) :
(thatValue ? (int)1 : (int)0);
}
public int compareTo(Object anotherObject) {
return compareTo((Boolean)anotherObject);
}
(Review ID: 144362)
======================================================================