Pair implements Serializable { @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof Pair)) return false; Pair<?, ?> other = (Pair<?, ?>) o; if (!Objects.equals(this.lv, other.lv)) { return false; } if (!Objects.equals(this.rv, other.rv)) { return false; } return true; } Pair(LT lv, RT rv); LT lv(); RT rv(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }
@Test public void testEquals() throws Exception { Pair<Long, String> p = new Pair<>(1L, "A"); assertTrue(p.equals(p)); assertTrue(new Pair<>(1L, "A").equals(new Pair<>(1L, "A"))); assertFalse(new Pair<>(1L, "A").equals(new Pair<>(1L, "B"))); assertFalse(new Pair<>(1L, "A").equals(new Pair<>(2L, "A"))); assertFalse(new Pair<>(1L, "A").equals(null)); }