• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2007 Google Inc.
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.
30  *
31  * <p>The {@link #get}, {@link #removeAll}, and {@link #replaceValues} methods
32  * each return a {@link List} of values. Though the method signature doesn't say
33  * so explicitly, the map returned by {@link #asMap} has {@code List} values.
34  *
35  * @author Jared Levy
36  * @since 2010.01.04 <b>stable</b> (imported from Google Collections Library)
37  */
38 @GwtCompatible
39 public interface ListMultimap<K, V> extends Multimap<K, V> {
40   /**
41    * {@inheritDoc}
42    *
43    * <p>Because the values for a given key may have duplicates and follow the
44    * insertion ordering, this method returns a {@link List}, instead of the
45    * {@link java.util.Collection} specified in the {@link Multimap} interface.
46    */
get(@ullable K key)47   List<V> get(@Nullable K key);
48 
49   /**
50    * {@inheritDoc}
51    *
52    * <p>Because the values for a given key may have duplicates and follow the
53    * insertion ordering, this method returns a {@link List}, instead of the
54    * {@link java.util.Collection} specified in the {@link Multimap} interface.
55    */
removeAll(@ullable Object key)56   List<V> removeAll(@Nullable Object key);
57 
58   /**
59    * {@inheritDoc}
60    *
61    * <p>Because the values for a given key may have duplicates and follow the
62    * insertion ordering, this method returns a {@link List}, instead of the
63    * {@link java.util.Collection} specified in the {@link Multimap} interface.
64    */
replaceValues(K key, Iterable<? extends V> values)65   List<V> replaceValues(K key, Iterable<? extends V> values);
66 
67   /**
68    * {@inheritDoc}
69    *
70    * <p>Though the method signature doesn't say so explicitly, the returned map
71    * has {@link List} values.
72    */
asMap()73   Map<K, Collection<V>> asMap();
74 
75   /**
76    * Compares the specified object to this multimap for equality.
77    *
78    * <p>Two {@code ListMultimap} instances are equal if, for each key, they
79    * contain the same values in the same order. If the value orderings disagree,
80    * the multimaps will not be considered equal.
81    */
equals(@ullable Object obj)82   boolean equals(@Nullable Object obj);
83 }
84