A cache which forwards all its method calls to another cache. Subclasses should override one or more methods to modify the behavior of the backing cache as desired per the <a href="http://en.wikipedia.org/wiki/Decorator_pattern">decorator pattern</a>. @author Charles Fry @since 10.0
| 34 | * @since 10.0 |
| 35 | */ |
| 36 | @GwtIncompatible |
| 37 | public abstract class ForwardingCache<K, V> extends ForwardingObject implements Cache<K, V> { |
| 38 | |
| 39 | /** Constructor for use by subclasses. */ |
| 40 | protected ForwardingCache() {} |
| 41 | |
| 42 | @Override |
| 43 | protected abstract Cache<K, V> delegate(); |
| 44 | |
| 45 | /** |
| 46 | * @since 11.0 |
| 47 | */ |
| 48 | @Override |
| 49 | public @Nullable V getIfPresent(Object key) { |
| 50 | return delegate().getIfPresent(key); |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * @since 11.0 |
| 55 | */ |
| 56 | @Override |
| 57 | public V get(K key, Callable<? extends V> valueLoader) throws ExecutionException { |
| 58 | return delegate().get(key, valueLoader); |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * @since 11.0 |
| 63 | */ |
| 64 | @Override |
| 65 | /* |
| 66 | * <? extends Object> is mostly the same as <?> to plain Java. But to nullness checkers, they |
| 67 | * differ: <? extends Object> means class="st">"non-null types," while <?> means class="st">"all types." |
| 68 | */ |
| 69 | public ImmutableMap<K, V> getAllPresent(Iterable<? extends Object> keys) { |
| 70 | return delegate().getAllPresent(keys); |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * @since 11.0 |
| 75 | */ |
| 76 | @Override |
| 77 | public void put(K key, V value) { |
| 78 | delegate().put(key, value); |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * @since 12.0 |
| 83 | */ |
| 84 | @Override |
| 85 | public void putAll(Map<? extends K, ? extends V> m) { |
| 86 | delegate().putAll(m); |
| 87 | } |
| 88 | |
| 89 | @Override |
| 90 | public void invalidate(Object key) { |
| 91 | delegate().invalidate(key); |
| 92 | } |
| 93 |
nothing calls this directly
no outgoing calls
no test coverage detected