MapEntry implements Map.Entry<K, V> { @Override @SuppressWarnings("unchecked") public boolean equals(Object o) { if (o != null && o instanceof Map.Entry) { Map.Entry<K, V> entry = (Map.Entry<K, V>) o; return (this.getKey() == null ? entry.getKey() == null : this .getKey().equals(entry.getKey())) && (this.getValue() == null ? entry.getValue() == null : this.getValue().equals(entry.getValue())); } return false; } MapEntry(K key, V value, boolean modifiable); K getKey(); V getValue(); V setValue(V val); @Override @SuppressWarnings("unchecked") boolean equals(Object o); @Override int hashCode();  }
@Test public void testEqualsObject() { MapEntry<String, String> entry = new MapEntry<String, String>("key", "value", false); assertFalse(entry.equals(null)); assertFalse(entry.equals("whatever")); MapEntry<String, String> entry2 = new MapEntry<String, String>("key", "value", false); assertTrue(entry.equals(entry2)); entry2 = new MapEntry<String, String>("key2", "value", false); assertFalse(entry.equals(entry2)); entry2 = new MapEntry<String, String>("key", "value2", false); assertFalse(entry.equals(entry2)); entry = new MapEntry<String, String>(null, "value", false); entry2 = new MapEntry<String, String>(null, "value", false); assertTrue(entry.equals(entry2)); entry = new MapEntry<String, String>("key", null, false); entry2 = new MapEntry<String, String>("key", null, false); assertTrue(entry.equals(entry2)); }