Coverage Summary for Class: TestStringMapGenerator (com.google.common.collect.testing)

Class Class, % Method, % Line, %
TestStringMapGenerator 100% (1/1) 100% (7/7) 100% (17/17)


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 com.google.common.annotations.GwtCompatible; 20 import java.util.List; 21 import java.util.Map; 22 import java.util.Map.Entry; 23  24 /** 25  * Implementation helper for {@link TestMapGenerator} for use with maps of strings. 26  * 27  * @author Chris Povirk 28  * @author Jared Levy 29  * @author George van den Driessche 30  */ 31 @GwtCompatible 32 public abstract class TestStringMapGenerator implements TestMapGenerator<String, String> { 33  34  @Override 35  public SampleElements<Entry<String, String>> samples() { 36  return new SampleElements<>( 37  Helpers.mapEntry("one", "January"), 38  Helpers.mapEntry("two", "February"), 39  Helpers.mapEntry("three", "March"), 40  Helpers.mapEntry("four", "April"), 41  Helpers.mapEntry("five", "May")); 42  } 43  44  @Override 45  public Map<String, String> create(Object... entries) { 46  @SuppressWarnings("unchecked") 47  Entry<String, String>[] array = new Entry[entries.length]; 48  int i = 0; 49  for (Object o : entries) { 50  @SuppressWarnings("unchecked") 51  Entry<String, String> e = (Entry<String, String>) o; 52  array[i++] = e; 53  } 54  return create(array); 55  } 56  57  protected abstract Map<String, String> create(Entry<String, String>[] entries); 58  59  @Override 60  @SuppressWarnings("unchecked") 61  public final Entry<String, String>[] createArray(int length) { 62  return new Entry[length]; 63  } 64  65  @Override 66  public final String[] createKeyArray(int length) { 67  return new String[length]; 68  } 69  70  @Override 71  public final String[] createValueArray(int length) { 72  return new String[length]; 73  } 74  75  /** Returns the original element list, unchanged. */ 76  @Override 77  public Iterable<Entry<String, String>> order(List<Entry<String, String>> insertionOrder) { 78  return insertionOrder; 79  } 80 }