Pair { @Override public int hashCode() { return ((null == v1) ? 0 : (v1.hashCode())) + ((null == v2) ? 0 : (v2.hashCode())); }  @Override int hashCode(); @SuppressWarnings({"unchecked"}) @Override boolean equals(Object obj); final T1 v1; final T2 v2; }
@Test public void testHashCode() { final Object[][] testParameters = new Object[][] {{"Hello", null, 69609650}, {null, "Hello", 69609650}, {"Hello", "World", 153375780}, {"World", "Hello", 153375780}}; for (final Object[] testParameter : testParameters) { int expected = (Integer) testParameter[2]; String v1 = (String) testParameter[0]; String v2 = (String) testParameter[1]; assertEquals(expected, new Pair<String, String>(v1, v2).hashCode()); } }
@Test public void shouldBeZeroOnNull() { assertEquals(0, new Pair<String, String>(null, null).hashCode()); }