CompareUtil { public static int nullSafeHashCode(Object obj) { if (obj != null) { return obj.hashCode(); } return 0; } private  CompareUtil(); static boolean nullSafeEquals(Object obj1, Object obj2); static int nullSafeHashCode(Object obj);  }
@Test public void testNullSafeHashCode() { assertEquals(TEST_VALUE.hashCode(), CompareUtil.nullSafeHashCode(TEST_VALUE)); assertEquals(0, CompareUtil.nullSafeHashCode(null)); }