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 17 package com.google.common.collect; 18 19 import com.google.common.annotations.GwtCompatible; 20 21 import java.util.Collection; 22 import java.util.Map; 23 import java.util.Map.Entry; 24 import java.util.Set; 25 26 import 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 38 public abstract class ForwardingMultimap<K, V> extends ForwardingObject 39 implements Multimap<K, V> { 40 41 /** Constructor for use by subclasses. */ ForwardingMultimap()42 protected ForwardingMultimap() {} 43 delegate()44 @Override protected abstract Multimap<K, V> delegate(); 45 46 @Override asMap()47 public Map<K, Collection<V>> asMap() { 48 return delegate().asMap(); 49 } 50 51 @Override clear()52 public void clear() { 53 delegate().clear(); 54 } 55 56 @Override containsEntry(@ullable Object key, @Nullable Object value)57 public boolean containsEntry(@Nullable Object key, @Nullable Object value) { 58 return delegate().containsEntry(key, value); 59 } 60 61 @Override containsKey(@ullable Object key)62 public boolean containsKey(@Nullable Object key) { 63 return delegate().containsKey(key); 64 } 65 66 @Override containsValue(@ullable Object value)67 public boolean containsValue(@Nullable Object value) { 68 return delegate().containsValue(value); 69 } 70 71 @Override entries()72 public Collection<Entry<K, V>> entries() { 73 return delegate().entries(); 74 } 75 76 @Override get(@ullable K key)77 public Collection<V> get(@Nullable K key) { 78 return delegate().get(key); 79 } 80 81 @Override isEmpty()82 public boolean isEmpty() { 83 return delegate().isEmpty(); 84 } 85 86 @Override keys()87 public Multiset<K> keys() { 88 return delegate().keys(); 89 } 90 91 @Override keySet()92 public Set<K> keySet() { 93 return delegate().keySet(); 94 } 95 96 @Override put(K key, V value)97 public boolean put(K key, V value) { 98 return delegate().put(key, value); 99 } 100 101 @Override putAll(K key, Iterable<? extends V> values)102 public boolean putAll(K key, Iterable<? extends V> values) { 103 return delegate().putAll(key, values); 104 } 105 106 @Override putAll(Multimap<? extends K, ? extends V> multimap)107 public boolean putAll(Multimap<? extends K, ? extends V> multimap) { 108 return delegate().putAll(multimap); 109 } 110 111 @Override remove(@ullable Object key, @Nullable Object value)112 public boolean remove(@Nullable Object key, @Nullable Object value) { 113 return delegate().remove(key, value); 114 } 115 116 @Override removeAll(@ullable Object key)117 public Collection<V> removeAll(@Nullable Object key) { 118 return delegate().removeAll(key); 119 } 120 121 @Override replaceValues(K key, Iterable<? extends V> values)122 public Collection<V> replaceValues(K key, Iterable<? extends V> values) { 123 return delegate().replaceValues(key, values); 124 } 125 126 @Override size()127 public int size() { 128 return delegate().size(); 129 } 130 131 @Override values()132 public Collection<V> values() { 133 return delegate().values(); 134 } 135 equals(@ullable Object object)136 @Override public boolean equals(@Nullable Object object) { 137 return object == this || delegate().equals(object); 138 } 139 hashCode()140 @Override public int hashCode() { 141 return delegate().hashCode(); 142 } 143 } 144