crazyboblee | 210bf43 | 2009-02-05 06:04:18 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 Google Inc. |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
limpbizkit@gmail.com | 9a227be | 2010-07-03 15:51:31 +0000 | [diff] [blame] | 17 | package com.google.inject.internal.util; |
crazyboblee | 210bf43 | 2009-02-05 06:04:18 +0000 | [diff] [blame] | 18 | |
| 19 | import java.util.concurrent.ConcurrentMap; |
| 20 | |
| 21 | /** |
| 22 | * A concurrent map which forwards all its method calls to another concurrent |
| 23 | * map. Subclasses should override one or more methods to modify the behavior of |
| 24 | * the backing map as desired per the <a |
| 25 | * href="http://en.wikipedia.org/wiki/Decorator_pattern">decorator pattern</a>. |
| 26 | * |
| 27 | * @see ForwardingObject |
| 28 | * @author Charles Fry |
| 29 | */ |
| 30 | public abstract class ForwardingConcurrentMap<K, V> extends ForwardingMap<K, V> |
| 31 | implements ConcurrentMap<K, V> { |
| 32 | |
| 33 | @Override protected abstract ConcurrentMap<K, V> delegate(); |
| 34 | |
| 35 | public V putIfAbsent(K key, V value) { |
| 36 | return delegate().putIfAbsent(key, value); |
| 37 | } |
| 38 | |
| 39 | public boolean remove(Object key, Object value) { |
| 40 | return delegate().remove(key, value); |
| 41 | } |
| 42 | |
| 43 | public V replace(K key, V value) { |
| 44 | return delegate().replace(key, value); |
| 45 | } |
| 46 | |
| 47 | public boolean replace(K key, V oldValue, V newValue) { |
| 48 | return delegate().replace(key, oldValue, newValue); |
| 49 | } |
| 50 | |
| 51 | } |