001/* 002 * Copyright (C) 2010 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 017package com.google.common.collect; 018 019import com.google.common.annotations.GwtCompatible; 020import com.google.errorprone.annotations.CanIgnoreReturnValue; 021import java.util.Map.Entry; 022import java.util.Set; 023import javax.annotation.CheckForNull; 024import org.checkerframework.checker.nullness.qual.Nullable; 025 026/** 027 * A set multimap which forwards all its method calls to another set multimap. Subclasses should 028 * override one or more methods to modify the behavior of the backing multimap as desired per the <a 029 * href="http://en.wikipedia.org/wiki/Decorator_pattern">decorator pattern</a>. 030 * 031 * <p><b>{@code default} method warning:</b> This class does <i>not</i> forward calls to {@code 032 * default} methods. Instead, it inherits their default implementations. When those implementations 033 * invoke methods, they invoke methods on the {@code ForwardingSetMultimap}. 034 * 035 * @author Kurt Alfred Kluever 036 * @since 3.0 037 */ 038@GwtCompatible 039@ElementTypesAreNonnullByDefault 040public abstract class ForwardingSetMultimap<K extends @Nullable Object, V extends @Nullable Object> 041 extends ForwardingMultimap<K, V> implements SetMultimap<K, V> { 042 /** Constructor for use by subclasses. */ 043 public ForwardingSetMultimap() {} 044 045 @Override 046 protected abstract SetMultimap<K, V> delegate(); 047 048 @Override 049 public Set<Entry<K, V>> entries() { 050 return delegate().entries(); 051 } 052 053 @Override 054 public Set<V> get(@ParametricNullness K key) { 055 return delegate().get(key); 056 } 057 058 @CanIgnoreReturnValue 059 @Override 060 public Set<V> removeAll(@CheckForNull Object key) { 061 return delegate().removeAll(key); 062 } 063 064 @CanIgnoreReturnValue 065 @Override 066 public Set<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values) { 067 return delegate().replaceValues(key, values); 068 } 069}