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
032public abstract class TestStringSortedMapGenerator extends TestStringMapGenerator
033    implements TestSortedMapGenerator<String, String> {
034  @Override
035  public Entry<String, String> belowSamplesLesser() {
036    return Helpers.mapEntry("!! a", "below view");
037  }
038
039  @Override
040  public Entry<String, String> belowSamplesGreater() {
041    return Helpers.mapEntry("!! b", "below view");
042  }
043
044  @Override
045  public Entry<String, String> aboveSamplesLesser() {
046    return Helpers.mapEntry("~~ a", "above view");
047  }
048
049  @Override
050  public Entry<String, String> aboveSamplesGreater() {
051    return Helpers.mapEntry("~~ b", "above view");
052  }
053
054  @Override
055  public Iterable<Entry<String, String>> order(List<Entry<String, String>> insertionOrder) {
056    return orderEntriesByKey(insertionOrder);
057  }
058
059  @Override
060  protected abstract SortedMap<String, String> create(Entry<String, String>[] entries);
061
062  @Override
063  public SortedMap<String, String> create(Object... entries) {
064    return (SortedMap<String, String>) super.create(entries);
065  }
066}