@Test public void testDisplayOrderNullAndInteger() { when(o1.getDisplayOrder()).thenReturn(null); when(o2.getDisplayOrder()).thenReturn("5"); int result = comparator.compare(o1, o2); Assert.assertEquals("Null values should come before integer values.", -1, result); }
@Override public int compare(ViewFieldTag o1, ViewFieldTag o2) { Integer displayOrder1 = getIntegerValue(o1.getDisplayOrder()); Integer displayOrder2 = getIntegerValue(o2.getDisplayOrder()); int displayOrderResult = Ordering.natural().compare(displayOrder1, displayOrder2); if (displayOrderResult != 0) { return displayOrderResult; } int pageOrderResult = Ordering.natural().nullsFirst().compare(o1.getPageOrder(), o2.getPageOrder()); if (pageOrderResult != 0) { return pageOrderResult; } return o1.getCode().compareTo(o2.getCode()); }
ViewFieldDisplayOrderComparator implements Comparator<ViewFieldTag> { @Override public int compare(ViewFieldTag o1, ViewFieldTag o2) { Integer displayOrder1 = getIntegerValue(o1.getDisplayOrder()); Integer displayOrder2 = getIntegerValue(o2.getDisplayOrder()); int displayOrderResult = Ordering.natural().compare(displayOrder1, displayOrder2); if (displayOrderResult != 0) { return displayOrderResult; } int pageOrderResult = Ordering.natural().nullsFirst().compare(o1.getPageOrder(), o2.getPageOrder()); if (pageOrderResult != 0) { return pageOrderResult; } return o1.getCode().compareTo(o2.getCode()); } }
ViewFieldDisplayOrderComparator implements Comparator<ViewFieldTag> { @Override public int compare(ViewFieldTag o1, ViewFieldTag o2) { Integer displayOrder1 = getIntegerValue(o1.getDisplayOrder()); Integer displayOrder2 = getIntegerValue(o2.getDisplayOrder()); int displayOrderResult = Ordering.natural().compare(displayOrder1, displayOrder2); if (displayOrderResult != 0) { return displayOrderResult; } int pageOrderResult = Ordering.natural().nullsFirst().compare(o1.getPageOrder(), o2.getPageOrder()); if (pageOrderResult != 0) { return pageOrderResult; } return o1.getCode().compareTo(o2.getCode()); }  }
ViewFieldDisplayOrderComparator implements Comparator<ViewFieldTag> { @Override public int compare(ViewFieldTag o1, ViewFieldTag o2) { Integer displayOrder1 = getIntegerValue(o1.getDisplayOrder()); Integer displayOrder2 = getIntegerValue(o2.getDisplayOrder()); int displayOrderResult = Ordering.natural().compare(displayOrder1, displayOrder2); if (displayOrderResult != 0) { return displayOrderResult; } int pageOrderResult = Ordering.natural().nullsFirst().compare(o1.getPageOrder(), o2.getPageOrder()); if (pageOrderResult != 0) { return pageOrderResult; } return o1.getCode().compareTo(o2.getCode()); }  @Override int compare(ViewFieldTag o1, ViewFieldTag o2); int compare(String o1, String o2); }
ViewFieldDisplayOrderComparator implements Comparator<ViewFieldTag> { @Override public int compare(ViewFieldTag o1, ViewFieldTag o2) { Integer displayOrder1 = getIntegerValue(o1.getDisplayOrder()); Integer displayOrder2 = getIntegerValue(o2.getDisplayOrder()); int displayOrderResult = Ordering.natural().compare(displayOrder1, displayOrder2); if (displayOrderResult != 0) { return displayOrderResult; } int pageOrderResult = Ordering.natural().nullsFirst().compare(o1.getPageOrder(), o2.getPageOrder()); if (pageOrderResult != 0) { return pageOrderResult; } return o1.getCode().compareTo(o2.getCode()); }  @Override int compare(ViewFieldTag o1, ViewFieldTag o2); int compare(String o1, String o2);  }