/** * Normal {@link Map#clear()} behavior with the addition of clearing all * expiration entries as well. */ @Override public void clear() { super.clear(); expirationMap.clear(); }
/** * Gets the map being decorated. * * @return the decorated map */ @Override protected SortedMap<K, V> decorated() { return (SortedMap<K, V>) super.decorated(); }
/** * {@inheritDoc} * <p> * NOTE: the returned Entry objects will contain as value a {@link Collection} * of all values that are mapped to the given key. To get a "flattened" version * of all mappings contained in this map, use {@link #iterator()}. * * @see #iterator() */ @Override public Set<Entry<K, Object>> entrySet() { // NOPMD return super.entrySet(); }
@Override public Set<K> keySet() { final Set<K> set = super.keySet(); return UnmodifiableSet.unmodifiableSet(set); }
/** * Add the given key-value pair to this map as well as recording the entry's expiration time based on * the current time in milliseconds and this map's {@link #expiringPolicy}. * <p> * {@inheritDoc} */ @Override public V put(final K key, final V value) { // record expiration time of new entry final long expirationTime = expiringPolicy.expirationTime(key, value); expirationMap.put(key, Long.valueOf(expirationTime)); return super.put(key, value); }
/** * Copies all of the keys and values from the specified map to this map. * Each key must be non-null and a MultiKey object. * * @param mapToCopy to this map * @throws NullPointerException if the mapToCopy or any key within is null * @throws ClassCastException if any key in mapToCopy is not a MultiKey */ @Override public void putAll(final Map<? extends MultiKey<? extends K>, ? extends V> mapToCopy) { for (final MultiKey<? extends K> key : mapToCopy.keySet()) { checkKey(key); } super.putAll(mapToCopy); }
/** * All expired entries are removed from the map prior to determining the * contains result. * {@inheritDoc} */ @Override public boolean containsKey(final Object key) { removeIfExpired(key, now()); return super.containsKey(key); }
/** * All expired entries are removed from the map prior to determining the * contains result. * {@inheritDoc} */ @Override public boolean containsValue(final Object value) { removeAllExpired(now()); return super.containsValue(value); }
/** * All expired entries are removed from the map prior to returning the entry value. * {@inheritDoc} */ @Override public V get(final Object key) { removeIfExpired(key, now()); return super.get(key); }
/** * All expired entries are removed from the map prior to determining if it is empty. * {@inheritDoc} */ @Override public boolean isEmpty() { removeAllExpired(now()); return super.isEmpty(); }
/** * All expired entries are removed from the map prior to returning the key set. * {@inheritDoc} */ @Override public Set<K> keySet() { removeAllExpired(now()); return super.keySet(); }
/** * Puts the key and value into the map, where the key must be a non-null * MultiKey object. * * @param key the non-null MultiKey object * @param value the value to store * @return the previous value for the key * @throws NullPointerException if the key is null * @throws ClassCastException if the key is not a MultiKey */ @Override public V put(final MultiKey<? extends K> key, final V value) { checkKey(key); return super.put(key, value); }
/** * Gets the map being decorated. * * @return the decorated map */ @Override protected OrderedMap<K, V> decorated() { return (OrderedMap<K, V>) super.decorated(); }
@Override public Set<Map.Entry<K, V>> entrySet() { final Set<Map.Entry<K, V>> set = super.entrySet(); return UnmodifiableEntrySet.unmodifiableEntrySet(set); }
/** * Gets the map being decorated. * * @return the decorated map */ @Override protected BidiMap<K, V> decorated() { return (BidiMap<K, V>) super.decorated(); }
/** * All expired entries are removed from the map prior to returning the entry set. * {@inheritDoc} */ @Override public Set<Entry<K, V>> entrySet() { removeAllExpired(now()); return super.entrySet(); }
/** * {@inheritDoc} */ @Override protected AbstractHashedMap<MultiKey<? extends K>, V> decorated() { return (AbstractHashedMap<MultiKey<? extends K>, V>) super.decorated(); }
@Override public boolean equals(final Object object) { if (object == this) { return true; } return decorated().equals(object); }
@Override public boolean containsKey(final Object key) { return decorated().containsKey(key); }
@Override public Collection<V> values() { return decorated().values(); }