• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2007 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 
17 package com.google.common.collect;
18 
19 import com.google.common.annotations.GwtCompatible;
20 
21 import java.util.Collection;
22 import java.util.List;
23 import java.util.Map;
24 
25 import javax.annotation.Nullable;
26 
27 /**
28  * A {@code Multimap} that can hold duplicate key-value pairs and that maintains
29  * the insertion ordering of values for a given key. See the {@link Multimap}
30  * documentation for information common to all multimaps.
31  *
32  * <p>The {@link #get}, {@link #removeAll}, and {@link #replaceValues} methods
33  * each return a {@link List} of values. Though the method signature doesn't say
34  * so explicitly, the map returned by {@link #asMap} has {@code List} values.
35  *
36  * <p>See the Guava User Guide article on <a href=
37  * "http://code.google.com/p/guava-libraries/wiki/NewCollectionTypesExplained#Multimap">
38  * {@code Multimap}</a>.
39  *
40  * @author Jared Levy
41  * @since 2.0 (imported from Google Collections Library)
42  */
43 @GwtCompatible
44 public interface ListMultimap<K, V> extends Multimap<K, V> {
45   /**
46    * {@inheritDoc}
47    *
48    * <p>Because the values for a given key may have duplicates and follow the
49    * insertion ordering, this method returns a {@link List}, instead of the
50    * {@link java.util.Collection} specified in the {@link Multimap} interface.
51    */
52   @Override
get(@ullable K key)53   List<V> get(@Nullable K key);
54 
55   /**
56    * {@inheritDoc}
57    *
58    * <p>Because the values for a given key may have duplicates and follow the
59    * insertion ordering, this method returns a {@link List}, instead of the
60    * {@link java.util.Collection} specified in the {@link Multimap} interface.
61    */
62   @Override
removeAll(@ullable Object key)63   List<V> removeAll(@Nullable Object key);
64 
65   /**
66    * {@inheritDoc}
67    *
68    * <p>Because the values for a given key may have duplicates and follow the
69    * insertion ordering, this method returns a {@link List}, instead of the
70    * {@link java.util.Collection} specified in the {@link Multimap} interface.
71    */
72   @Override
replaceValues(K key, Iterable<? extends V> values)73   List<V> replaceValues(K key, Iterable<? extends V> values);
74 
75   /**
76    * {@inheritDoc}
77    *
78    * <p><b>Note:</b> The returned map's values are guaranteed to be of type
79    * {@link List}. To obtain this map with the more specific generic type
80    * {@code Map<K, List<V>>}, call {@link Multimaps#asMap(ListMultimap)}
81    * instead.
82    */
83   @Override
asMap()84   Map<K, Collection<V>> asMap();
85 
86   /**
87    * Compares the specified object to this multimap for equality.
88    *
89    * <p>Two {@code ListMultimap} instances are equal if, for each key, they
90    * contain the same values in the same order. If the value orderings disagree,
91    * the multimaps will not be considered equal.
92    *
93    * <p>An empty {@code ListMultimap} is equal to any other empty {@code
94    * Multimap}, including an empty {@code SetMultimap}.
95    */
96   @Override
equals(@ullable Object obj)97   boolean equals(@Nullable Object obj);
98 }
99