Comparables { static <T extends Comparable<T>> int compareLists(List<T> lefts, List<T> rights) { if (lefts.size() != rights.size()) { return lefts.size() - rights.size(); } for (int i = 0; i < lefts.size(); i++) { final int comparison = lefts.get(i).compareTo(rights.get(i)); if (comparison != 0) { return comparison; } } return 0; }    }
@Test public void an_empty_list_is_smaller_than_others() { final int lefty = compareLists(Arrays.<Integer>asList(1), Collections.<Integer>emptyList()); assertEquals(OutCome.LEFT, OutCome.from(lefty)); final int righty = compareLists(Collections.<Integer>emptyList(), Arrays.<Integer>asList(1)); assertEquals(OutCome.RIGHT, OutCome.from(righty)); }