Home | History | Annotate | Download | only in collect
      1 /*
      2  * Copyright (C) 2007 Google Inc.
      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  * @see ForwardingObject
     35  * @author Robert Konigsberg
     36  * @since 2010.01.04 <b>stable</b> (imported from Google Collections Library)
     37  */
     38 @GwtCompatible
     39 public abstract class ForwardingMultimap<K, V> extends ForwardingObject
     40     implements Multimap<K, V> {
     41 
     42   @Override protected abstract Multimap<K, V> delegate();
     43 
     44   public Map<K, Collection<V>> asMap() {
     45     return delegate().asMap();
     46   }
     47 
     48   public void clear() {
     49     delegate().clear();
     50   }
     51 
     52   public boolean containsEntry(@Nullable Object key, @Nullable Object value) {
     53     return delegate().containsEntry(key, value);
     54   }
     55 
     56   public boolean containsKey(@Nullable Object key) {
     57     return delegate().containsKey(key);
     58   }
     59 
     60   public boolean containsValue(@Nullable Object value) {
     61     return delegate().containsValue(value);
     62   }
     63 
     64   public Collection<Entry<K, V>> entries() {
     65     return delegate().entries();
     66   }
     67 
     68   public Collection<V> get(@Nullable K key) {
     69     return delegate().get(key);
     70   }
     71 
     72   public boolean isEmpty() {
     73     return delegate().isEmpty();
     74   }
     75 
     76   public Multiset<K> keys() {
     77     return delegate().keys();
     78   }
     79 
     80   public Set<K> keySet() {
     81     return delegate().keySet();
     82   }
     83 
     84   public boolean put(K key, V value) {
     85     return delegate().put(key, value);
     86   }
     87 
     88   public boolean putAll(K key, Iterable<? extends V> values) {
     89     return delegate().putAll(key, values);
     90   }
     91 
     92   public boolean putAll(Multimap<? extends K, ? extends V> multimap) {
     93     return delegate().putAll(multimap);
     94   }
     95 
     96   public boolean remove(@Nullable Object key, @Nullable Object value) {
     97     return delegate().remove(key, value);
     98   }
     99 
    100   public Collection<V> removeAll(@Nullable Object key) {
    101     return delegate().removeAll(key);
    102   }
    103 
    104   public Collection<V> replaceValues(K key, Iterable<? extends V> values) {
    105     return delegate().replaceValues(key, values);
    106   }
    107 
    108   public int size() {
    109     return delegate().size();
    110   }
    111 
    112   public Collection<V> values() {
    113     return delegate().values();
    114   }
    115 
    116   @Override public boolean equals(@Nullable Object object) {
    117     return object == this || delegate().equals(object);
    118   }
    119 
    120   @Override public int hashCode() {
    121     return delegate().hashCode();
    122   }
    123 }
    124