1/* 2 * Copyright (C) 2012 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 17package com.google.common.collect; 18 19import com.google.common.annotations.GwtCompatible; 20import com.google.common.base.Predicate; 21 22import java.util.Map.Entry; 23import java.util.Set; 24 25import javax.annotation.Nullable; 26 27/** 28 * Implementation of {@link Multimaps#filterKeys(SetMultimap, Predicate)}. 29 * 30 * @author Louis Wasserman 31 */ 32@GwtCompatible 33final class FilteredKeySetMultimap<K, V> extends FilteredKeyMultimap<K, V> 34 implements FilteredSetMultimap<K, V> { 35 36 FilteredKeySetMultimap(SetMultimap<K, V> unfiltered, Predicate<? super K> keyPredicate) { 37 super(unfiltered, keyPredicate); 38 } 39 40 @Override 41 public SetMultimap<K, V> unfiltered() { 42 return (SetMultimap<K, V>) unfiltered; 43 } 44 45 @Override 46 public Set<V> get(K key) { 47 return (Set<V>) super.get(key); 48 } 49 50 @Override 51 public Set<V> removeAll(Object key) { 52 return (Set<V>) super.removeAll(key); 53 } 54 55 @Override 56 public Set<V> replaceValues(K key, Iterable<? extends V> values) { 57 return (Set<V>) super.replaceValues(key, values); 58 } 59 60 @Override 61 public Set<Entry<K, V>> entries() { 62 return (Set<Entry<K, V>>) super.entries(); 63 } 64 65 @Override 66 Set<Entry<K, V>> createEntries() { 67 return new EntrySet(); 68 } 69 70 class EntrySet extends Entries implements Set<Entry<K, V>> { 71 @Override 72 public int hashCode() { 73 return Sets.hashCodeImpl(this); 74 } 75 76 @Override 77 public boolean equals(@Nullable Object o) { 78 return Sets.equalsImpl(this, o); 79 } 80 } 81} 82