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    
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.0 (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      
045      @Override
046      protected abstract Multimap<K, V> delegate();
047    
048      public Map<K, Collection<V>> asMap() {
049        return delegate().asMap();
050      }
051    
052      public void clear() {
053        delegate().clear();
054      }
055    
056      public boolean containsEntry(@Nullable Object key, @Nullable Object value) {
057        return delegate().containsEntry(key, value);
058      }
059    
060      public boolean containsKey(@Nullable Object key) {
061        return delegate().containsKey(key);
062      }
063    
064      public boolean containsValue(@Nullable Object value) {
065        return delegate().containsValue(value);
066      }
067    
068      public Collection<Entry<K, V>> entries() {
069        return delegate().entries();
070      }
071    
072      public Collection<V> get(@Nullable K key) {
073        return delegate().get(key);
074      }
075    
076      public boolean isEmpty() {
077        return delegate().isEmpty();
078      }
079    
080      public Multiset<K> keys() {
081        return delegate().keys();
082      }
083    
084      public Set<K> keySet() {
085        return delegate().keySet();
086      }
087    
088      public boolean put(K key, V value) {
089        return delegate().put(key, value);
090      }
091    
092      public boolean putAll(K key, Iterable<? extends V> values) {
093        return delegate().putAll(key, values);
094      }
095    
096      public boolean putAll(Multimap<? extends K, ? extends V> multimap) {
097        return delegate().putAll(multimap);
098      }
099    
100      public boolean remove(@Nullable Object key, @Nullable Object value) {
101        return delegate().remove(key, value);
102      }
103    
104      public Collection<V> removeAll(@Nullable Object key) {
105        return delegate().removeAll(key);
106      }
107    
108      public Collection<V> replaceValues(K key, Iterable<? extends V> values) {
109        return delegate().replaceValues(key, values);
110      }
111    
112      public int size() {
113        return delegate().size();
114      }
115    
116      public Collection<V> values() {
117        return delegate().values();
118      }
119    
120      
121      @Override
122      public boolean equals(@Nullable Object object) {
123        return object == this || delegate().equals(object);
124      }
125    
126      
127      @Override
128      public int hashCode() {
129        return delegate().hashCode();
130      }
131    }