001/* 002 * Copyright (C) 2008 The Guava Authors 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package com.google.common.collect.testing; 018 019import static com.google.common.collect.testing.Helpers.orderEntriesByKey; 020 021import com.google.common.annotations.GwtCompatible; 022import java.util.List; 023import java.util.Map.Entry; 024import java.util.SortedMap; 025 026/** 027 * Implementation helper for {@link TestMapGenerator} for use with sorted maps of strings. 028 * 029 * @author Chris Povirk 030 */ 031@GwtCompatible 032@ElementTypesAreNonnullByDefault 033public abstract class TestStringSortedMapGenerator extends TestStringMapGenerator 034 implements TestSortedMapGenerator<String, String> { 035 @Override 036 public Entry<String, String> belowSamplesLesser() { 037 return Helpers.mapEntry("!! a", "below view"); 038 } 039 040 @Override 041 public Entry<String, String> belowSamplesGreater() { 042 return Helpers.mapEntry("!! b", "below view"); 043 } 044 045 @Override 046 public Entry<String, String> aboveSamplesLesser() { 047 return Helpers.mapEntry("~~ a", "above view"); 048 } 049 050 @Override 051 public Entry<String, String> aboveSamplesGreater() { 052 return Helpers.mapEntry("~~ b", "above view"); 053 } 054 055 @Override 056 public Iterable<Entry<String, String>> order(List<Entry<String, String>> insertionOrder) { 057 return orderEntriesByKey(insertionOrder); 058 } 059 060 @Override 061 protected abstract SortedMap<String, String> create(Entry<String, String>[] entries); 062 063 @Override 064 public SortedMap<String, String> create(Object... entries) { 065 return (SortedMap<String, String>) super.create(entries); 066 } 067}