ObjectComparator implements Comparator<Object>, Serializable { @Override public int compare(Object first, Object second) { return MultiKeyComparator.compareValues(first, second, sortCondition.getSortEnum()); } ObjectComparator(SortCondition sortCondition); @Override int compare(Object first, Object second);  }
@Test public void testCompare() { String attr = "attr"; int i1 = 1; int i2 = SupportConst.I_TWO; Integer i3 = null; String s1 = "aaaa"; String s2 = "ab"; String s3 = null; condition = new SortCondition(attr, SortEnum.ASC); oc = new ObjectComparator(condition); Assert.assertEquals(-1, oc.compare(i1, i2)); Assert.assertEquals(1, oc.compare(i1, i3)); Assert.assertEquals(0, oc.compare(i1, i1)); Assert.assertEquals(0, oc.compare(i3, i3)); Assert.assertEquals(-1, oc.compare(s1, s2)); Assert.assertEquals(1, oc.compare(s1, s3)); Assert.assertEquals(0, oc.compare(s1, s1)); Assert.assertEquals(0, oc.compare(s3, s3)); condition = new SortCondition(attr, SortEnum.DESC); oc = new ObjectComparator(condition); Assert.assertEquals(1, oc.compare(i1, i2)); Assert.assertEquals(-1, oc.compare(i1, i3)); Assert.assertEquals(0, oc.compare(i1, i1)); Assert.assertEquals(0, oc.compare(i3, i3)); Assert.assertEquals(1, oc.compare(s1, s2)); Assert.assertEquals(-1, oc.compare(s1, s3)); Assert.assertEquals(0, oc.compare(s1, s1)); Assert.assertEquals(0, oc.compare(s3, s3)); }