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.Map; 23 import java.util.SortedSet; 24 25 import javax.annotation.Nullable; 26 27 /** 28 * Basic implementation of the {@link SortedSetMultimap} interface. It's a 29 * wrapper around {@link AbstractMultimap} that converts the returned 30 * collections into sorted sets. The {@link #createCollection} method 31 * must return a {@code SortedSet}. 32 * 33 * @author Jared Levy 34 */ 35 @GwtCompatible 36 abstract class AbstractSortedSetMultimap<K, V> 37 extends AbstractSetMultimap<K, V> implements SortedSetMultimap<K, V> { 38 /** 39 * Creates a new multimap that uses the provided map. 40 * 41 * @param map place to store the mapping from each key to its corresponding 42 * values 43 */ AbstractSortedSetMultimap(Map<K, Collection<V>> map)44 protected AbstractSortedSetMultimap(Map<K, Collection<V>> map) { 45 super(map); 46 } 47 createCollection()48 @Override abstract SortedSet<V> createCollection(); 49 get(@ullable K key)50 @Override public SortedSet<V> get(@Nullable K key) { 51 return (SortedSet<V>) super.get(key); 52 } 53 removeAll(@ullable Object key)54 @Override public SortedSet<V> removeAll(@Nullable Object key) { 55 return (SortedSet<V>) super.removeAll(key); 56 } 57 replaceValues( K key, Iterable<? extends V> values)58 @Override public SortedSet<V> replaceValues( 59 K key, Iterable<? extends V> values) { 60 return (SortedSet<V>) super.replaceValues(key, values); 61 } 62 63 /** 64 * {@inheritDoc} 65 * 66 * Consequently, the values do not follow their natural ordering or the 67 * ordering of the value comparator. 68 */ values()69 @Override public Collection<V> values() { 70 return super.values(); 71 } 72 73 private static final long serialVersionUID = 430848587173315748L; 74 }