KV implements Serializable { public static <K extends @Nullable Object, V extends @Nullable Object> KV<K, V> of( K key, V value) { return new KV<>(key, value); } private  KV(K key, V value); static KV<K, V> of(
      K key, V value); K getKey(); V getValue(); @Override boolean equals(@Nullable Object other); @Override int hashCode(); @Override String toString();  }
@Test public void testOrderByKey() { Comparator<KV<Integer, Integer>> orderByKey = new KV.OrderByKey<>(); for (Integer key1 : TEST_VALUES) { for (Integer val1 : TEST_VALUES) { for (Integer key2 : TEST_VALUES) { for (Integer val2 : TEST_VALUES) { assertEquals( compareInt(key1, key2), orderByKey.compare(KV.of(key1, val1), KV.of(key2, val2))); } } } } }
@Test public void testOrderByValue() { Comparator<KV<Integer, Integer>> orderByValue = new KV.OrderByValue<>(); for (Integer key1 : TEST_VALUES) { for (Integer val1 : TEST_VALUES) { for (Integer key2 : TEST_VALUES) { for (Integer val2 : TEST_VALUES) { assertEquals( compareInt(val1, val2), orderByValue.compare(KV.of(key1, val1), KV.of(key2, val2))); } } } } }