001    /*
002     * Copyright (C) 2007 Google Inc.
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    
017    package com.google.common.collect;
018    
019    import com.google.common.annotations.GwtCompatible;
020    
021    import java.util.Collection;
022    import java.util.Map;
023    import java.util.Map.Entry;
024    import java.util.Set;
025    
026    import 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 (imported from Google Collections Library)
036     */
037    @GwtCompatible
038    public abstract class ForwardingMultimap<K, V> extends ForwardingObject
039        implements Multimap<K, V> {
040    
041      /** Constructor for use by subclasses. */
042      protected ForwardingMultimap() {}
043    
044      @Override protected abstract Multimap<K, V> delegate();
045    
046      public Map<K, Collection<V>> asMap() {
047        return delegate().asMap();
048      }
049    
050      public void clear() {
051        delegate().clear();
052      }
053    
054      public boolean containsEntry(@Nullable Object key, @Nullable Object value) {
055        return delegate().containsEntry(key, value);
056      }
057    
058      public boolean containsKey(@Nullable Object key) {
059        return delegate().containsKey(key);
060      }
061    
062      public boolean containsValue(@Nullable Object value) {
063        return delegate().containsValue(value);
064      }
065    
066      public Collection<Entry<K, V>> entries() {
067        return delegate().entries();
068      }
069    
070      public Collection<V> get(@Nullable K key) {
071        return delegate().get(key);
072      }
073    
074      public boolean isEmpty() {
075        return delegate().isEmpty();
076      }
077    
078      public Multiset<K> keys() {
079        return delegate().keys();
080      }
081    
082      public Set<K> keySet() {
083        return delegate().keySet();
084      }
085    
086      public boolean put(K key, V value) {
087        return delegate().put(key, value);
088      }
089    
090      public boolean putAll(K key, Iterable<? extends V> values) {
091        return delegate().putAll(key, values);
092      }
093    
094      public boolean putAll(Multimap<? extends K, ? extends V> multimap) {
095        return delegate().putAll(multimap);
096      }
097    
098      public boolean remove(@Nullable Object key, @Nullable Object value) {
099        return delegate().remove(key, value);
100      }
101    
102      public Collection<V> removeAll(@Nullable Object key) {
103        return delegate().removeAll(key);
104      }
105    
106      public Collection<V> replaceValues(K key, Iterable<? extends V> values) {
107        return delegate().replaceValues(key, values);
108      }
109    
110      public int size() {
111        return delegate().size();
112      }
113    
114      public Collection<V> values() {
115        return delegate().values();
116      }
117    
118      @Override public boolean equals(@Nullable Object object) {
119        return object == this || delegate().equals(object);
120      }
121    
122      @Override public int hashCode() {
123        return delegate().hashCode();
124      }
125    }