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.Collection;
022import java.util.Map;
023import java.util.Map.Entry;
024import java.util.Set;
025
026import javax.annotation.Nullable;
027
028/**
029 * A multimap which forwards all its method calls to another multimap.
030 * Subclasses should override one or more methods to modify the behavior of
031 * the backing multimap as desired per the <a
032 * href="http://en.wikipedia.org/wiki/Decorator_pattern">decorator pattern</a>.
033 *
034 * @author Robert Konigsberg
035 * @since 2.0
036 */
037@GwtCompatible
038public abstract class ForwardingMultimap<K, V> extends ForwardingObject implements Multimap<K, V> {
039
040  /** Constructor for use by subclasses. */
041  protected ForwardingMultimap() {}
042
043  @Override
044  protected abstract Multimap<K, V> delegate();
045
046  @Override
047  public Map<K, Collection<V>> asMap() {
048    return delegate().asMap();
049  }
050
051  @Override
052  public void clear() {
053    delegate().clear();
054  }
055
056  @Override
057  public boolean containsEntry(@Nullable Object key, @Nullable Object value) {
058    return delegate().containsEntry(key, value);
059  }
060
061  @Override
062  public boolean containsKey(@Nullable Object key) {
063    return delegate().containsKey(key);
064  }
065
066  @Override
067  public boolean containsValue(@Nullable Object value) {
068    return delegate().containsValue(value);
069  }
070
071  @Override
072  public Collection<Entry<K, V>> entries() {
073    return delegate().entries();
074  }
075
076  @Override
077  public Collection<V> get(@Nullable K key) {
078    return delegate().get(key);
079  }
080
081  @Override
082  public boolean isEmpty() {
083    return delegate().isEmpty();
084  }
085
086  @Override
087  public Multiset<K> keys() {
088    return delegate().keys();
089  }
090
091  @Override
092  public Set<K> keySet() {
093    return delegate().keySet();
094  }
095
096  @Override
097  public boolean put(K key, V value) {
098    return delegate().put(key, value);
099  }
100
101  @Override
102  public boolean putAll(K key, Iterable<? extends V> values) {
103    return delegate().putAll(key, values);
104  }
105
106  @Override
107  public boolean putAll(Multimap<? extends K, ? extends V> multimap) {
108    return delegate().putAll(multimap);
109  }
110
111  @Override
112  public boolean remove(@Nullable Object key, @Nullable Object value) {
113    return delegate().remove(key, value);
114  }
115
116  @Override
117  public Collection<V> removeAll(@Nullable Object key) {
118    return delegate().removeAll(key);
119  }
120
121  @Override
122  public Collection<V> replaceValues(K key, Iterable<? extends V> values) {
123    return delegate().replaceValues(key, values);
124  }
125
126  @Override
127  public int size() {
128    return delegate().size();
129  }
130
131  @Override
132  public Collection<V> values() {
133    return delegate().values();
134  }
135
136  @Override
137  public boolean equals(@Nullable Object object) {
138    return object == this || delegate().equals(object);
139  }
140
141  @Override
142  public int hashCode() {
143    return delegate().hashCode();
144  }
145}