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