001/*
002 * Copyright (C) 2007 The Guava Authors
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package com.google.common.collect;
018
019import com.google.common.annotations.GwtCompatible;
020
021import java.util.concurrent.ConcurrentMap;
022
023/**
024 * A concurrent map which forwards all its method calls to another concurrent
025 * map. Subclasses should override one or more methods to modify the behavior of
026 * the backing map as desired per the <a
027 * href="http://en.wikipedia.org/wiki/Decorator_pattern">decorator pattern</a>.
028 *
029 * @author Charles Fry
030 * @since 2.0
031 */
032@GwtCompatible
033public abstract class ForwardingConcurrentMap<K, V> extends ForwardingMap<K, V>
034    implements ConcurrentMap<K, V> {
035
036  /** Constructor for use by subclasses. */
037  protected ForwardingConcurrentMap() {}
038
039  @Override
040  protected abstract ConcurrentMap<K, V> delegate();
041
042  @Override
043  public V putIfAbsent(K key, V value) {
044    return delegate().putIfAbsent(key, value);
045  }
046
047  @Override
048  public boolean remove(Object key, Object value) {
049    return delegate().remove(key, value);
050  }
051
052  @Override
053  public V replace(K key, V value) {
054    return delegate().replace(key, value);
055  }
056
057  @Override
058  public boolean replace(K key, V oldValue, V newValue) {
059    return delegate().replace(key, oldValue, newValue);
060  }
061}