1/*
2 * Copyright (C) 2007 The Guava Authors
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
17package com.google.common.collect;
18
19import com.google.common.annotations.GwtCompatible;
20
21import java.util.Collection;
22import java.util.Map;
23import java.util.Map.Entry;
24import java.util.Set;
25
26import javax.annotation.Nullable;
27
28/**
29 * A multimap which forwards all its method calls to another multimap.
30 * Subclasses should override one or more methods to modify the behavior of
31 * the backing multimap as desired per the <a
32 * href="http://en.wikipedia.org/wiki/Decorator_pattern">decorator pattern</a>.
33 *
34 * @author Robert Konigsberg
35 * @since 2.0 (imported from Google Collections Library)
36 */
37@GwtCompatible
38public abstract class ForwardingMultimap<K, V> extends ForwardingObject
39    implements Multimap<K, V> {
40
41  /** Constructor for use by subclasses. */
42  protected ForwardingMultimap() {}
43
44  @Override protected abstract Multimap<K, V> delegate();
45
46  @Override
47  public Map<K, Collection<V>> asMap() {
48    return delegate().asMap();
49  }
50
51  @Override
52  public void clear() {
53    delegate().clear();
54  }
55
56  @Override
57  public boolean containsEntry(@Nullable Object key, @Nullable Object value) {
58    return delegate().containsEntry(key, value);
59  }
60
61  @Override
62  public boolean containsKey(@Nullable Object key) {
63    return delegate().containsKey(key);
64  }
65
66  @Override
67  public boolean containsValue(@Nullable Object value) {
68    return delegate().containsValue(value);
69  }
70
71  @Override
72  public Collection<Entry<K, V>> entries() {
73    return delegate().entries();
74  }
75
76  @Override
77  public Collection<V> get(@Nullable K key) {
78    return delegate().get(key);
79  }
80
81  @Override
82  public boolean isEmpty() {
83    return delegate().isEmpty();
84  }
85
86  @Override
87  public Multiset<K> keys() {
88    return delegate().keys();
89  }
90
91  @Override
92  public Set<K> keySet() {
93    return delegate().keySet();
94  }
95
96  @Override
97  public boolean put(K key, V value) {
98    return delegate().put(key, value);
99  }
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 public boolean equals(@Nullable Object object) {
137    return object == this || delegate().equals(object);
138  }
139
140  @Override public int hashCode() {
141    return delegate().hashCode();
142  }
143}
144