Pair { public static <F, S> Pair<F, S> create(F f, S s) { return new Pair<>(f, s); } Pair(F first, S second); static Pair<F, S> create(F f, S s); @Override boolean equals(java.lang.Object o); @Override String toString(); @Override int hashCode(); final F first; final S second; }
@Test public void pairHashTest() { Pair inserted = Pair.create("aa", "bbb"); Set<Pair> set = new HashSet<>(); assertFalse(set.contains(inserted)); set.add(inserted); assertTrue(set.contains(inserted)); }