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.mapEntry;
020import static com.google.common.collect.testing.Helpers.orderEntriesByKey;
021
022import com.google.common.annotations.GwtCompatible;
023import java.util.List;
024import java.util.Map.Entry;
025import java.util.SortedMap;
026
027/**
028 * Implementation helper for {@link TestMapGenerator} for use with sorted maps of strings.
029 *
030 * @author Chris Povirk
031 */
032@GwtCompatible
033@ElementTypesAreNonnullByDefault
034public abstract class TestStringSortedMapGenerator extends TestStringMapGenerator
035    implements TestSortedMapGenerator<String, String> {
036  @Override
037  public Entry<String, String> belowSamplesLesser() {
038    return mapEntry("!! a", "below view");
039  }
040
041  @Override
042  public Entry<String, String> belowSamplesGreater() {
043    return mapEntry("!! b", "below view");
044  }
045
046  @Override
047  public Entry<String, String> aboveSamplesLesser() {
048    return mapEntry("~~ a", "above view");
049  }
050
051  @Override
052  public Entry<String, String> aboveSamplesGreater() {
053    return mapEntry("~~ b", "above view");
054  }
055
056  @Override
057  public Iterable<Entry<String, String>> order(List<Entry<String, String>> insertionOrder) {
058    return orderEntriesByKey(insertionOrder);
059  }
060
061  @Override
062  protected abstract SortedMap<String, String> create(Entry<String, String>[] entries);
063
064  @Override
065  public SortedMap<String, String> create(Object... entries) {
066    return (SortedMap<String, String>) super.create(entries);
067  }
068}