@Test public void compareTest() { Action actionLess = mock(Action.class); Action actionMore = mock(Action.class); Action actionNull = mock(Action.class); when(actionLess.getOrder()).thenReturn(Integer.valueOf(3)); when(actionMore.getOrder()).thenReturn(Integer.valueOf(5)); when(actionNull.getOrder()).thenReturn(null); Assert.assertEquals(1, ActionComparator.INSTANCE.compare(actionMore, actionLess)); Assert.assertEquals(1, ActionComparator.INSTANCE.compare(actionNull, actionLess)); Assert.assertEquals(-1, ActionComparator.INSTANCE.compare(actionLess, actionMore)); Assert.assertEquals(-1, ActionComparator.INSTANCE.compare(actionLess, actionNull)); }
@Override public int compare(Action arg0, Action arg1) { return ComparisonChain.start() .compare(arg0.getOrder(), arg1.getOrder(), Ordering.natural().nullsLast()) .result(); }
ActionComparator implements Comparator<Action> { @Override public int compare(Action arg0, Action arg1) { return ComparisonChain.start() .compare(arg0.getOrder(), arg1.getOrder(), Ordering.natural().nullsLast()) .result(); } }
ActionComparator implements Comparator<Action> { @Override public int compare(Action arg0, Action arg1) { return ComparisonChain.start() .compare(arg0.getOrder(), arg1.getOrder(), Ordering.natural().nullsLast()) .result(); }  }
ActionComparator implements Comparator<Action> { @Override public int compare(Action arg0, Action arg1) { return ComparisonChain.start() .compare(arg0.getOrder(), arg1.getOrder(), Ordering.natural().nullsLast()) .result(); }  @Override int compare(Action arg0, Action arg1); }
ActionComparator implements Comparator<Action> { @Override public int compare(Action arg0, Action arg1) { return ComparisonChain.start() .compare(arg0.getOrder(), arg1.getOrder(), Ordering.natural().nullsLast()) .result(); }  @Override int compare(Action arg0, Action arg1); static final ActionComparator INSTANCE; }