MapEntry implements Map.Entry<K, V> { public V setValue(V val) { if (modifiable) { V oldVal = this.value; this.value = val; return oldVal; } throw new UnsupportedOperationException("The map entry is not modifiable"); } 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 testSetValue() { MapEntry<String, String> entry = new MapEntry<String, String>("key", "value", true); assertEquals("value", entry.getValue()); entry.setValue("value2"); assertEquals("value2", entry.getValue()); }