TestStringSortedMapGenerator.java revision 3c77433663281544363151bf284b0240dfd22a42
1/* 2 * Copyright (C) 2008 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.testing; 18 19import static com.google.common.collect.testing.Helpers.orderEntriesByKey; 20 21import com.google.common.annotations.GwtCompatible; 22 23import java.util.List; 24import java.util.Map.Entry; 25import java.util.SortedMap; 26 27/** 28 * Implementation helper for {@link TestMapGenerator} for use with sorted maps of strings. 29 * 30 * <p>This class is GWT compatible. 31 * 32 * @author Chris Povirk 33 */ 34@GwtCompatible 35public abstract class TestStringSortedMapGenerator extends TestStringMapGenerator 36 implements TestSortedMapGenerator<String, String> { 37 @Override 38 public Entry<String, String> belowSamplesLesser() { 39 return Helpers.mapEntry("!! a", "below view"); 40 } 41 42 @Override 43 public Entry<String, String> belowSamplesGreater() { 44 return Helpers.mapEntry("!! b", "below view"); 45 } 46 47 @Override 48 public Entry<String, String> aboveSamplesLesser() { 49 return Helpers.mapEntry("~~ a", "above view"); 50 } 51 52 @Override 53 public Entry<String, String> aboveSamplesGreater() { 54 return Helpers.mapEntry("~~ b", "above view"); 55 } 56 57 @Override 58 public Iterable<Entry<String, String>> order(List<Entry<String, String>> insertionOrder) { 59 return orderEntriesByKey(insertionOrder); 60 } 61 62 @Override 63 protected abstract SortedMap<String, String> create(Entry<String, String>[] entries); 64 65 @Override 66 public SortedMap<String, String> create(Object... entries) { 67 return (SortedMap<String, String>) super.create(entries); 68 } 69} 70