- Added some null checks to TableSorter.

This commit is contained in:
Sloth
2012-07-11 20:16:28 +00:00
parent cfcf592ad8
commit 7b18561d40

View File

@@ -76,6 +76,12 @@ public class TableSorter<T> implements Comparator<Entry<T, Integer>> {
public final int compare(final Entry<T, Integer> arg0, final Entry<T, Integer> arg1) {
final Comparable obj1 = this.field.apply(arg0);
final Comparable obj2 = this.field.apply(arg1);
if (obj1 == null) {
return -1;
}
if (obj2 == null) {
return 1;
}
//System.out.println(String.format("%s vs %s _______ %s vs %s", arg0, arg1, obj1, obj2));
return this.ascending ? obj1.compareTo(obj2) : obj2.compareTo(obj1);
}