1090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson/* 21d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * Copyright (C) 2007 The Guava Authors 3090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * 4090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * Licensed under the Apache License, Version 2.0 (the "License"); 5090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * you may not use this file except in compliance with the License. 6090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * You may obtain a copy of the License at 7090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * 8090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * http://www.apache.org/licenses/LICENSE-2.0 9090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * 10090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * Unless required by applicable law or agreed to in writing, software 11090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * distributed under the License is distributed on an "AS IS" BASIS, 12090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * See the License for the specific language governing permissions and 14090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * limitations under the License. 15090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson */ 16090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson 17090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilsonpackage com.google.common.collect; 18090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson 19090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilsonimport com.google.common.annotations.GwtCompatible; 20090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson 21090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilsonimport java.util.Collection; 22090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilsonimport java.util.Map; 23090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilsonimport java.util.Set; 24090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson 25090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilsonimport javax.annotation.Nullable; 26090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson 27090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson/** 28090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * A {@code Multimap} that cannot hold duplicate key-value pairs. Adding a 29090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * key-value pair that's already in the multimap has no effect. 30090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * 31090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * <p>The {@link #get}, {@link #removeAll}, and {@link #replaceValues} methods 32090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * each return a {@link Set} of values, while {@link #entries} returns a {@code 33090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * Set} of map entries. Though the method signature doesn't say so explicitly, 34090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * the map returned by {@link #asMap} has {@code Set} values. 35090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * 36090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * @author Jared Levy 371d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * @since 2.0 (imported from Google Collections Library) 38090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson */ 39090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson@GwtCompatible 40090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilsonpublic interface SetMultimap<K, V> extends Multimap<K, V> { 41090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson /** 42090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * {@inheritDoc} 43090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * 44090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * <p>Because a {@code SetMultimap} has unique values for a given key, this 45090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * method returns a {@link Set}, instead of the {@link java.util.Collection} 46090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * specified in the {@link Multimap} interface. 47090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson */ 481d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert @Override 49090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson Set<V> get(@Nullable K key); 50090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson 51090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson /** 52090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * {@inheritDoc} 53090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * 54090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * <p>Because a {@code SetMultimap} has unique values for a given key, this 55090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * method returns a {@link Set}, instead of the {@link java.util.Collection} 56090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * specified in the {@link Multimap} interface. 57090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson */ 581d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert @Override 59090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson Set<V> removeAll(@Nullable Object key); 60090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson 61090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson /** 62090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * {@inheritDoc} 63090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * 64090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * <p>Because a {@code SetMultimap} has unique values for a given key, this 65090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * method returns a {@link Set}, instead of the {@link java.util.Collection} 66090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * specified in the {@link Multimap} interface. 67090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * 68090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * <p>Any duplicates in {@code values} will be stored in the multimap once. 69090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson */ 701d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert @Override 71090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson Set<V> replaceValues(K key, Iterable<? extends V> values); 72090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson 73090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson /** 74090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * {@inheritDoc} 75090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * 76090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * <p>Because a {@code SetMultimap} has unique values for a given key, this 77090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * method returns a {@link Set}, instead of the {@link java.util.Collection} 78090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * specified in the {@link Multimap} interface. 79090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson */ 801d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert @Override 81090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson Set<Map.Entry<K, V>> entries(); 82090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson 83090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson /** 84090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * {@inheritDoc} 85090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * 86090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * <p>Though the method signature doesn't say so explicitly, the returned map 87090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * has {@link Set} values. 88090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson */ 891d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert @Override 90090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson Map<K, Collection<V>> asMap(); 91090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson 92090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson /** 93090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * Compares the specified object to this multimap for equality. 94090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * 95090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * <p>Two {@code SetMultimap} instances are equal if, for each key, they 96090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * contain the same values. Equality does not depend on the ordering of keys 97090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * or values. 981d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * 991d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * <p>An empty {@code SetMultimap} is equal to any other empty {@code 1001d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * Multimap}, including an empty {@code ListMultimap}. 101090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson */ 1021d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert @Override 103090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson boolean equals(@Nullable Object obj); 104090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson} 105