Pair { @SuppressWarnings({"unchecked"}) @Override public boolean equals(Object obj) { if (!(obj instanceof Pair)) { return false; } final Pair<Object, Object> other = (Pair<Object, Object>) obj; return Objects.equal(v1, other.v1) && Objects.equal(v2, other.v2); }  @Override int hashCode(); @SuppressWarnings({"unchecked"}) @Override boolean equals(Object obj); final T1 v1; final T2 v2; }
@Test public void testEquals() { final Pair<String, String> pair = new Pair<String, String>("Hello", "World"); final Object[][] testParameters = new Object[][] {{new String(), false}, {new HashMap<String, String>(), false}, {new Pair<String, String>("Hello", "World"), true}}; for (final Object[] testParameter : testParameters) { boolean expected = (Boolean) testParameter[1]; Object obj = (Object) testParameter[0]; assertEquals(expected, pair.equals(obj)); } }