LRUMap extends LinkedHashMap<K, V> { @Override public V put(K key, V value) { V put = super.put(key, value); for (ModificationListener<K, V> listener : listeners) { listener.onPut(key, value); } return put; } LRUMap(final int capacity);  LRUMap(Map<? extends K, ? extends V> m, int capacity); int getCapacity(); synchronized void addListener(ModificationListener<K, V> listener); synchronized void removeListener(ModificationListener<K, V> listener); List<ModificationListener<K, V>> getListeners(); synchronized void removeListeners(); @Override V remove(Object key); @Override V put(K key, V value); @Override void putAll(Map<? extends K, ? extends V> m);  }
@Test public void capacity() { map.put("hello", 1); map.put("hello2", 2); assertThat(map.size(), equalTo(2)); map.put("hello3", 2); assertThat(map.size(), equalTo(2)); }