MapEntryArrayValues extends MapEntry<K, V[]> { @Override public int hashCode() { int valueHash = 0; V[] value = getValue(); if (value != null) { for (int i = 0; i < value.length; i++) { valueHash += value[i].hashCode(); } } return (this.getKey() == null ? 0 : this.getKey().hashCode()) ^ valueHash; } MapEntryArrayValues(K key, V[] value, boolean modifiable); @Override int hashCode(); @Override @SuppressWarnings("unchecked") boolean equals(Object o);  }
@Test public void testHashCode() { MapEntryArrayValues<String, String> entry = new MapEntryArrayValues<String, String>( "key", new String[] { "value1", "value2" }, false); assertEquals("key".hashCode() ^ ("value1".hashCode() + "value2".hashCode()), entry.hashCode()); entry = new MapEntryArrayValues<String, String>( null, new String[] { "value1", "value2" }, false); assertEquals(0 ^ ("value1".hashCode() + "value2".hashCode()), entry.hashCode()); entry = new MapEntryArrayValues<String, String>( "key", null, false); assertEquals("key".hashCode() ^ 0, entry.hashCode()); entry = new MapEntryArrayValues<String, String>( null, null, false); assertEquals(0 ^ 0, entry.hashCode()); }