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