Skip to content
Snippets Groups Projects
Commit c3452d64 authored by srosse's avatar srosse
Browse files

OO-1083: check if the 2 objects are of the same class before compare them with...

OO-1083: check if the 2 objects are of the same class before compare them with the generic compareTo method
parent f2adc1eb
No related branches found
No related tags found
No related merge requests found
......@@ -179,12 +179,14 @@ public class DefaultColumnDescriptor implements ColumnDescriptor {
if(a instanceof Date && b instanceof Date) {
return compareDateAndTimestamps((Date)a, (Date)b);
}
if (a instanceof Comparable && b instanceof Comparable) {
if (a instanceof Boolean && b instanceof Boolean) {
// faster than string compare, boolean are comparable
return compareBooleans((Boolean)a, (Boolean)b);
}
if (a instanceof Comparable && a.getClass().equals(b.getClass())) {
//compare the same things
return ((Comparable)a).compareTo((Comparable)b);
}
/*if (a instanceof Boolean && b instanceof Boolean) { // faster than string compare, boolean are comparable
return compareBooleans((Boolean)a, (Boolean)b);
}*/
return a.toString().compareTo(b.toString());
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment