Java

Форк
0
/
TestStringSetGenerator.java 
69 строк · 2.1 Кб
1
/*
2
 * Copyright (C) 2007 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 com.google.common.collect.testing.SampleElements.Strings;
21
import java.util.List;
22
import java.util.Set;
23

24
/**
25
 * Create string sets for collection tests.
26
 *
27
 * @author Kevin Bourrillion
28
 */
29
@GwtCompatible
30
@ElementTypesAreNonnullByDefault
31
public abstract class TestStringSetGenerator implements TestSetGenerator<String> {
32
  @Override
33
  public SampleElements<String> samples() {
34
    return new Strings();
35
  }
36

37
  @Override
38
  public Set<String> create(Object... elements) {
39
    String[] array = new String[elements.length];
40
    int i = 0;
41
    for (Object e : elements) {
42
      array[i++] = (String) e;
43
    }
44
    return create(array);
45
  }
46

47
  protected abstract Set<String> create(String[] elements);
48

49
  @Override
50
  public String[] createArray(int length) {
51
    return new String[length];
52
  }
53

54
  /**
55
   * {@inheritDoc}
56
   *
57
   * <p>By default, returns the supplied elements in their given order; however, generators for
58
   * containers with a known order other than insertion order must override this method.
59
   *
60
   * <p>Note: This default implementation is overkill (but valid) for an unordered container. An
61
   * equally valid implementation for an unordered container is to throw an exception. The chosen
62
   * implementation, however, has the advantage of working for insertion-ordered containers, as
63
   * well.
64
   */
65
  @Override
66
  public List<String> order(List<String> insertionOrder) {
67
    return insertionOrder;
68
  }
69
}
70

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.