/** {@inheritDoc} */ public V put(K key, V value) { LazyInitializer<V> c = cache.put(key, new NoopInitializer(value)); if (c != null) { return c.get(); } return null; }
/** {@inheritDoc} */ public V remove(Object key) { LazyInitializer<V> c = cache.remove(key); if (c != null) { return c.get(); } return null; }
/** * If the specified key is not already associated with a value, associate it with the given value. * This is equivalent to * * <pre> * if (!map.containsKey(key)) * return map.put(key, value); * else * return map.get(key);</pre> * * except that the action is performed atomically. * * @param key key with which the specified value is to be associated * @param value a lazy initialized value object. * @return the previous value associated with the specified key, or <tt>null</tt> if there was no * mapping for the key * @throws NullPointerException if the specified key or value is null */ public V putIfAbsent(K key, LazyInitializer<V> value) { LazyInitializer<V> v = cache.get(key); if (v == null) { v = cache.putIfAbsent(key, value); if (v == null) { return value.get(); } } return v.get(); }