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 decorator pattern . @author Charles Fry @since 10.0
| 35 | |
| 36 | |
| 37 | @GwtIncompatible |
| 38 | public abstract class ForwardingCache<K, V> extends ForwardingObject implements Cache<K, V> { |
| 39 | |
| 40 | /** Constructor for use by subclasses. */ |
| 41 | |
| 42 | |
| 43 | protected ForwardingCache() {} |
| 44 | |
| 45 | @Override |
| 46 | protected abstract Cache<K, V> delegate(); |
| 47 | |
| 48 | /** |
| 49 | * @since 11.0 |
| 50 | */ |
| 51 | |
| 52 | @Override |
| 53 | @Nullable |
| 54 | public V getIfPresent(Object key) { |
| 55 | return delegate().getIfPresent(key); |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * @since 11.0 |
| 60 | */ |
| 61 | |
| 62 | @Override |
| 63 | public V get(K key, Callable<? extends V> valueLoader) throws ExecutionException { |
| 64 | return delegate().get(key, valueLoader); |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * @since 11.0 |
| 69 | */ |
| 70 | |
| 71 | @Override |
| 72 | public ImmutableMap<K, V> getAllPresent(Iterable<?> keys) { |
| 73 | return delegate().getAllPresent(keys); |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * @since 11.0 |
| 78 | */ |
| 79 | |
| 80 | @Override |
| 81 | public void put(K key, V value) { |
| 82 | delegate().put(key, value); |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * @since 12.0 |
| 87 | */ |
| 88 | |
| 89 | @Override |
| 90 | public void putAll(Map<? extends K, ? extends V> m) { |
| 91 | delegate().putAll(m); |
| 92 | } |
| 93 | |
| 94 | @Override |
nothing calls this directly
no outgoing calls
no test coverage detected