@Test public void testCompareNull() throws Exception { TestObjectComparator objectComparator = new TestObjectComparator(); Assert.assertEquals("objectComparator.compareNull(null, null, false)", 0, objectComparator.compareNull(null, null, false)); Assert.assertEquals("objectComparator.compareNull(new Object(), null, false)", -1, objectComparator.compareNull(new Object(), null, false)); Assert.assertEquals("objectComparator.compareNull(null, new Object(), false)", 1, objectComparator.compareNull(null, new Object(), false)); Assert.assertEquals("objectComparator.compareNull(new Object(), new Object(), false)", 2, objectComparator.compareNull(new Object(), new Object(), false)); Assert.assertEquals("objectComparator.compareNull(null, null, true)", 0, objectComparator.compareNull(null, null, true)); Assert.assertEquals("objectComparator.compareNull(new Object(), null, true)", 1, objectComparator.compareNull(new Object(), null, true)); Assert.assertEquals("objectComparator.compareNull(null, new Object(), true)", -1, objectComparator.compareNull(null, new Object(), true)); Assert.assertEquals("objectComparator.compareNull(new Object(), new Object(), true)", 2, objectComparator.compareNull(new Object(), new Object(), true)); }
int compareNull(Object left, Object right, boolean descending) { if (left != null && right != null) { return 2; } if (left != null) { return descending ? 1 : -1; } if (right != null) { return descending ? -1 : 1; } return 0; }
PaginationComparator implements Comparator<T> { int compareNull(Object left, Object right, boolean descending) { if (left != null && right != null) { return 2; } if (left != null) { return descending ? 1 : -1; } if (right != null) { return descending ? -1 : 1; } return 0; } }
PaginationComparator implements Comparator<T> { int compareNull(Object left, Object right, boolean descending) { if (left != null && right != null) { return 2; } if (left != null) { return descending ? 1 : -1; } if (right != null) { return descending ? -1 : 1; } return 0; } PaginationComparator(); protected  PaginationComparator(String defaultSortOrder); }
PaginationComparator implements Comparator<T> { int compareNull(Object left, Object right, boolean descending) { if (left != null && right != null) { return 2; } if (left != null) { return descending ? 1 : -1; } if (right != null) { return descending ? -1 : 1; } return 0; } PaginationComparator(); protected  PaginationComparator(String defaultSortOrder); PaginationComparator<T> replaceSortorder(String sortOrder); }
PaginationComparator implements Comparator<T> { int compareNull(Object left, Object right, boolean descending) { if (left != null && right != null) { return 2; } if (left != null) { return descending ? 1 : -1; } if (right != null) { return descending ? -1 : 1; } return 0; } PaginationComparator(); protected  PaginationComparator(String defaultSortOrder); PaginationComparator<T> replaceSortorder(String sortOrder);  }