1090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson/*
21d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * Copyright (C) 2007 The Guava Authors
3090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson *
4090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * Licensed under the Apache License, Version 2.0 (the "License");
5090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * you may not use this file except in compliance with the License.
6090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * You may obtain a copy of the License at
7090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson *
8090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * http://www.apache.org/licenses/LICENSE-2.0
9090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson *
10090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * Unless required by applicable law or agreed to in writing, software
11090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * distributed under the License is distributed on an "AS IS" BASIS,
12090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * See the License for the specific language governing permissions and
14090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * limitations under the License.
15090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson */
16090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
17090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilsonpackage com.google.common.collect;
18090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
19090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilsonimport com.google.common.annotations.GwtCompatible;
20090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
21090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilsonimport java.util.Collection;
22090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilsonimport java.util.Map;
23090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilsonimport java.util.Map.Entry;
24090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilsonimport java.util.Set;
25090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
26090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilsonimport javax.annotation.Nullable;
27090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
28090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson/**
29090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * A multimap which forwards all its method calls to another multimap.
30090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * Subclasses should override one or more methods to modify the behavior of
31090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * the backing multimap as desired per the <a
32090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * href="http://en.wikipedia.org/wiki/Decorator_pattern">decorator pattern</a>.
33090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson *
34090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * @author Robert Konigsberg
351d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * @since 2.0 (imported from Google Collections Library)
36090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson */
37090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson@GwtCompatible
380888a09821a98ac0680fad765217302858e70fa4Paul Duffinpublic abstract class ForwardingMultimap<K, V> extends ForwardingObject
390888a09821a98ac0680fad765217302858e70fa4Paul Duffin    implements Multimap<K, V> {
40090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
411d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert  /** Constructor for use by subclasses. */
421d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert  protected ForwardingMultimap() {}
431d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert
440888a09821a98ac0680fad765217302858e70fa4Paul Duffin  @Override protected abstract Multimap<K, V> delegate();
457dd252788645e940eada959bdde927426e2531c9Paul Duffin
460888a09821a98ac0680fad765217302858e70fa4Paul Duffin  @Override
47090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  public Map<K, Collection<V>> asMap() {
48090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    return delegate().asMap();
49090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
50090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
510888a09821a98ac0680fad765217302858e70fa4Paul Duffin  @Override
52090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  public void clear() {
53090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    delegate().clear();
54090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
55090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
560888a09821a98ac0680fad765217302858e70fa4Paul Duffin  @Override
57090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  public boolean containsEntry(@Nullable Object key, @Nullable Object value) {
58090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    return delegate().containsEntry(key, value);
59090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
60090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
610888a09821a98ac0680fad765217302858e70fa4Paul Duffin  @Override
62090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  public boolean containsKey(@Nullable Object key) {
63090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    return delegate().containsKey(key);
64090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
65090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
660888a09821a98ac0680fad765217302858e70fa4Paul Duffin  @Override
67090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  public boolean containsValue(@Nullable Object value) {
68090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    return delegate().containsValue(value);
69090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
70090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
710888a09821a98ac0680fad765217302858e70fa4Paul Duffin  @Override
72090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  public Collection<Entry<K, V>> entries() {
73090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    return delegate().entries();
74090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
75090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
760888a09821a98ac0680fad765217302858e70fa4Paul Duffin  @Override
77090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  public Collection<V> get(@Nullable K key) {
78090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    return delegate().get(key);
79090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
80090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
810888a09821a98ac0680fad765217302858e70fa4Paul Duffin  @Override
82090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  public boolean isEmpty() {
83090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    return delegate().isEmpty();
84090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
85090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
860888a09821a98ac0680fad765217302858e70fa4Paul Duffin  @Override
87090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  public Multiset<K> keys() {
88090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    return delegate().keys();
89090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
90090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
910888a09821a98ac0680fad765217302858e70fa4Paul Duffin  @Override
92090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  public Set<K> keySet() {
93090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    return delegate().keySet();
94090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
95090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
960888a09821a98ac0680fad765217302858e70fa4Paul Duffin  @Override
97090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  public boolean put(K key, V value) {
98090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    return delegate().put(key, value);
99090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
100090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
1010888a09821a98ac0680fad765217302858e70fa4Paul Duffin  @Override
102090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  public boolean putAll(K key, Iterable<? extends V> values) {
103090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    return delegate().putAll(key, values);
104090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
105090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
1060888a09821a98ac0680fad765217302858e70fa4Paul Duffin  @Override
107090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  public boolean putAll(Multimap<? extends K, ? extends V> multimap) {
108090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    return delegate().putAll(multimap);
109090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
110090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
1110888a09821a98ac0680fad765217302858e70fa4Paul Duffin  @Override
112090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  public boolean remove(@Nullable Object key, @Nullable Object value) {
113090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    return delegate().remove(key, value);
114090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
115090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
1160888a09821a98ac0680fad765217302858e70fa4Paul Duffin  @Override
117090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  public Collection<V> removeAll(@Nullable Object key) {
118090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    return delegate().removeAll(key);
119090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
120090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
1210888a09821a98ac0680fad765217302858e70fa4Paul Duffin  @Override
122090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  public Collection<V> replaceValues(K key, Iterable<? extends V> values) {
123090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    return delegate().replaceValues(key, values);
124090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
125090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
1260888a09821a98ac0680fad765217302858e70fa4Paul Duffin  @Override
127090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  public int size() {
128090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    return delegate().size();
129090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
130090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
1310888a09821a98ac0680fad765217302858e70fa4Paul Duffin  @Override
132090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  public Collection<V> values() {
133090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    return delegate().values();
134090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
135090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
1360888a09821a98ac0680fad765217302858e70fa4Paul Duffin  @Override public boolean equals(@Nullable Object object) {
137090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    return object == this || delegate().equals(object);
138090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
139090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
1400888a09821a98ac0680fad765217302858e70fa4Paul Duffin  @Override public int hashCode() {
141090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    return delegate().hashCode();
142090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
143090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson}
144