1090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson/*
2090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * Copyright (C) 2007 Google Inc.
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.SortedSet;
24090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
25090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilsonimport javax.annotation.Nullable;
26090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
27090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson/**
28090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * Basic implementation of the {@link SortedSetMultimap} interface. It's a
29090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * wrapper around {@link AbstractMultimap} that converts the returned
30090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * collections into sorted sets. The {@link #createCollection} method
31090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * must return a {@code SortedSet}.
32090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson *
33090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * @author Jared Levy
34090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson */
35090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson@GwtCompatible
36090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilsonabstract class AbstractSortedSetMultimap<K, V>
37090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    extends AbstractSetMultimap<K, V> implements SortedSetMultimap<K, V> {
38090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  /**
39090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * Creates a new multimap that uses the provided map.
40090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   *
41090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * @param map place to store the mapping from each key to its corresponding
42090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   *     values
43090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   */
44090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  protected AbstractSortedSetMultimap(Map<K, Collection<V>> map) {
45090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    super(map);
46090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
47090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
48090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  @Override abstract SortedSet<V> createCollection();
49090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
50090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  @Override public SortedSet<V> get(@Nullable K key) {
51090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    return (SortedSet<V>) super.get(key);
52090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
53090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
54090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  @Override public SortedSet<V> removeAll(@Nullable Object key) {
55090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    return (SortedSet<V>) super.removeAll(key);
56090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
57090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
58090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  @Override public SortedSet<V> replaceValues(
59090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson      K key, Iterable<? extends V> values) {
60090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    return (SortedSet<V>) super.replaceValues(key, values);
61090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
62090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
63090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  /**
64090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * {@inheritDoc}
65090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   *
66090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * Consequently, the values do not follow their natural ordering or the
67090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * ordering of the value comparator.
68090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   */
69090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  @Override public Collection<V> values() {
70090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    return super.values();
71090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
72090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
73090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  private static final long serialVersionUID = 430848587173315748L;
74090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson}