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
17package com.google.common.collect;
18
19import com.google.common.annotations.GwtCompatible;
20
21import java.util.Collection;
22import java.util.List;
23import java.util.Map;
24
25import 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 2.0 (imported from Google Collections Library)
37 */
38@GwtCompatible
39public 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   */
47  @Override
48  List<V> get(@Nullable K key);
49
50  /**
51   * {@inheritDoc}
52   *
53   * <p>Because the values for a given key may have duplicates and follow the
54   * insertion ordering, this method returns a {@link List}, instead of the
55   * {@link java.util.Collection} specified in the {@link Multimap} interface.
56   */
57  @Override
58  List<V> removeAll(@Nullable Object key);
59
60  /**
61   * {@inheritDoc}
62   *
63   * <p>Because the values for a given key may have duplicates and follow the
64   * insertion ordering, this method returns a {@link List}, instead of the
65   * {@link java.util.Collection} specified in the {@link Multimap} interface.
66   */
67  @Override
68  List<V> replaceValues(K key, Iterable<? extends V> values);
69
70  /**
71   * {@inheritDoc}
72   *
73   * <p>Though the method signature doesn't say so explicitly, the returned map
74   * has {@link List} values.
75   */
76  @Override
77  Map<K, Collection<V>> asMap();
78
79  /**
80   * Compares the specified object to this multimap for equality.
81   *
82   * <p>Two {@code ListMultimap} instances are equal if, for each key, they
83   * contain the same values in the same order. If the value orderings disagree,
84   * the multimaps will not be considered equal.
85   *
86   * <p>An empty {@code ListMultimap} is equal to any other empty {@code
87   * Multimap}, including an empty {@code SetMultimap}.
88   */
89  @Override
90  boolean equals(@Nullable Object obj);
91}
92