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
297dd252788645e940eada959bdde927426e2531c9Paul Duffin * key-value pair that's already in the multimap has no effect. See the {@link
307dd252788645e940eada959bdde927426e2531c9Paul Duffin * Multimap} documentation for information common to all multimaps.
31090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson *
32090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * <p>The {@link #get}, {@link #removeAll}, and {@link #replaceValues} methods
33090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * each return a {@link Set} of values, while {@link #entries} returns a {@code
34090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * Set} of map entries. Though the method signature doesn't say so explicitly,
35090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * the map returned by {@link #asMap} has {@code Set} values.
36090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson *
377dd252788645e940eada959bdde927426e2531c9Paul Duffin * <p>If the values corresponding to a single key should be ordered according to
387dd252788645e940eada959bdde927426e2531c9Paul Duffin * a {@link java.util.Comparator} (or the natural order), see the
397dd252788645e940eada959bdde927426e2531c9Paul Duffin * {@link SortedSetMultimap} subinterface.
400888a09821a98ac0680fad765217302858e70fa4Paul Duffin *
410888a09821a98ac0680fad765217302858e70fa4Paul Duffin * <p>Since the value collections are sets, the behavior of a {@code SetMultimap}
420888a09821a98ac0680fad765217302858e70fa4Paul Duffin * is not specified if key <em>or value</em> objects already present in the
430888a09821a98ac0680fad765217302858e70fa4Paul Duffin * multimap change in a manner that affects {@code equals} comparisons.
440888a09821a98ac0680fad765217302858e70fa4Paul Duffin * Use caution if mutable objects are used as keys or values in a
450888a09821a98ac0680fad765217302858e70fa4Paul Duffin * {@code SetMultimap}.
467dd252788645e940eada959bdde927426e2531c9Paul Duffin *
477dd252788645e940eada959bdde927426e2531c9Paul Duffin * <p>See the Guava User Guide article on <a href=
487dd252788645e940eada959bdde927426e2531c9Paul Duffin * "http://code.google.com/p/guava-libraries/wiki/NewCollectionTypesExplained#Multimap">
497dd252788645e940eada959bdde927426e2531c9Paul Duffin * {@code Multimap}</a>.
507dd252788645e940eada959bdde927426e2531c9Paul Duffin *
51090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * @author Jared Levy
521d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * @since 2.0 (imported from Google Collections Library)
53090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson */
54090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson@GwtCompatible
55090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilsonpublic interface SetMultimap<K, V> extends Multimap<K, V> {
56090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  /**
57090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * {@inheritDoc}
58090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   *
59090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * <p>Because a {@code SetMultimap} has unique values for a given key, this
60090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * method returns a {@link Set}, instead of the {@link java.util.Collection}
61090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * specified in the {@link Multimap} interface.
62090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   */
630888a09821a98ac0680fad765217302858e70fa4Paul Duffin  @Override
64090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  Set<V> get(@Nullable K key);
65090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
66090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  /**
67090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * {@inheritDoc}
68090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   *
69090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * <p>Because a {@code SetMultimap} has unique values for a given key, this
70090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * method returns a {@link Set}, instead of the {@link java.util.Collection}
71090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * specified in the {@link Multimap} interface.
72090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   */
730888a09821a98ac0680fad765217302858e70fa4Paul Duffin  @Override
74090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  Set<V> removeAll(@Nullable Object key);
75090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
76090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  /**
77090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * {@inheritDoc}
78090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   *
79090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * <p>Because a {@code SetMultimap} has unique values for a given key, this
80090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * method returns a {@link Set}, instead of the {@link java.util.Collection}
81090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * specified in the {@link Multimap} interface.
82090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   *
83090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * <p>Any duplicates in {@code values} will be stored in the multimap once.
84090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   */
850888a09821a98ac0680fad765217302858e70fa4Paul Duffin  @Override
86090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  Set<V> replaceValues(K key, Iterable<? extends V> values);
87090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
88090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  /**
89090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * {@inheritDoc}
90090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   *
91090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * <p>Because a {@code SetMultimap} has unique values for a given key, this
92090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * method returns a {@link Set}, instead of the {@link java.util.Collection}
93090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * specified in the {@link Multimap} interface.
94090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   */
950888a09821a98ac0680fad765217302858e70fa4Paul Duffin  @Override
96090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  Set<Map.Entry<K, V>> entries();
97090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
98090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  /**
99090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * {@inheritDoc}
100090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   *
1010888a09821a98ac0680fad765217302858e70fa4Paul Duffin   * <p><b>Note:</b> The returned map's values are guaranteed to be of type
1020888a09821a98ac0680fad765217302858e70fa4Paul Duffin   * {@link Set}. To obtain this map with the more specific generic type
1030888a09821a98ac0680fad765217302858e70fa4Paul Duffin   * {@code Map<K, Set<V>>}, call {@link Multimaps#asMap(SetMultimap)} instead.
104090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   */
1050888a09821a98ac0680fad765217302858e70fa4Paul Duffin  @Override
106090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  Map<K, Collection<V>> asMap();
107090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
108090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  /**
109090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * Compares the specified object to this multimap for equality.
110090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   *
111090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * <p>Two {@code SetMultimap} instances are equal if, for each key, they
112090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * contain the same values. Equality does not depend on the ordering of keys
113090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * or values.
1141d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert   *
1151d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert   * <p>An empty {@code SetMultimap} is equal to any other empty {@code
1161d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert   * Multimap}, including an empty {@code ListMultimap}.
117090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   */
1180888a09821a98ac0680fad765217302858e70fa4Paul Duffin  @Override
119090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  boolean equals(@Nullable Object obj);
120090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson}
121