UnionMap extends AbstractMap<K, V> { @Override public boolean containsKey(Object key) { return first.containsKey(key) || second.containsKey(key); } UnionMap(Map<K, V> first, Map<K, V> second); @Override int size(); @Override boolean isEmpty(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override V get(Object key); @Override V put(K key, V value); @Override V remove(Object key); @Override void clear(); @Override Set<Entry<K, V>> entrySet();  }
@Test void testContainsKey() { assertThat(new UnionMap<>(of("1", "a"), of("2", "b"))).containsKey("1"); assertThat(new UnionMap<>(of("1", "a"), of("2", "b"))).containsKey("2"); }