ToEnumImpl implements ToEnum<T, E> { @Override public int compare(T first, T second) { return Integer.compare( apply(first).ordinal(), apply(second).ordinal() ); } ToEnumImpl(Class<E> enumClass, Function<T, E> inner); @Override Class<E> enumClass(); @Override E apply(T t); @Override ToInt<T> asOrdinal(); @Override ToString<T> asName(); @Override long hash(T object); @Override int compare(T first, T second);  }
@Test void compare() { Pair<String, String> pair1 = new Pair<>("FIRST", "FIRST"); Pair<String, String> pair2 = new Pair<>("FIRST", "SECOND"); Pair<String, String> pair3 = new Pair<>("SECOND", "FIRST"); Pair<String, String> pair4 = new Pair<>("SECOND", "SECOND"); assertEquals(0, instance.compare(pair1.getFirst(), pair1.getSecond())); assertEquals(-1, instance.compare(pair2.getFirst(), pair2.getSecond())); assertEquals(1, instance.compare(pair3.getFirst(), pair3.getSecond())); assertEquals(0, instance.compare(pair4.getFirst(), pair4.getSecond())); }