ScopedMap implements ScopeSubscriber, Map<K, V> { public V get(final Object key) { final Stack<ScopedMapItem<V>> stack = map.get(key); if (stack == null) { return null; } if (stack.empty()) { return null; } final ScopedMapItem<V> item = stack.peek(); return item.getValue(); } ScopedMap(final ScopeObserver scopeObserver); void close(); void enterScope(final Scope previous, final Scope next); void exitScope(final Scope previous, final Scope next); int size(); boolean isEmpty(); boolean containsKey(final Object key); boolean containsValue(final Object value); V get(final Object key); V put(final K key, final V value); V remove(final Object key); void putAll(final Map<? extends K, ? extends V> t); void clear(); Set<K> keySet(); Collection<V> values(); Set<Map.Entry<K, V>> entrySet(); @Override boolean equals(final Object o); @Override int hashCode();  }
@Test public void testGet() { final ScopedMap<String, String> map = new ScopedMap<String, String>(observer); Assert.assertNull(map.get("nokey")); map.put("key1", "value1"); Assert.assertEquals("value1", map.get("key1")); map.put("key2", "value2"); Assert.assertEquals("value1", map.get("key1")); Assert.assertEquals("value2", map.get("key2")); map.clear(); Assert.assertNull(map.get("key1")); Assert.assertNull(map.get("key2")); }