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

OO-608: make the sorting methods bullet proof

parent d8090e7f
No related branches found
No related tags found
No related merge requests found
......@@ -166,16 +166,27 @@ public class DefaultColumnDescriptor implements ColumnDescriptor {
}
protected int compareString(final String a, final String b) {
return collator.compare(a, b);
if (a == null || b == null) {
return compareNullObjects(a, b);
}
return collator == null ? a.compareTo(b) : collator.compare(a, b);
}
protected int compareBooleans(final Boolean a, final Boolean b) {
if (a == null || b == null) {
return compareNullObjects(a, b);
}
boolean ba = a.booleanValue();
boolean bb = b.booleanValue();
return ba? (bb? 0: -1):(bb? 1: 0);
}
protected int compareDateAndTimestamps(Date a, Date b) {
if (a == null || b == null) {
return compareNullObjects(a, b);
}
if (a instanceof Timestamp) { // a timestamp (a) cannot compare a date (b), but vice versa is ok.
if(b instanceof Timestamp) {
return ((Timestamp)a).compareTo((Timestamp)b);
......
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