Java

Форк
0
94 строки · 3.0 Кб
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.features;
18

19
import com.google.common.annotations.GwtCompatible;
20
import com.google.common.collect.testing.Helpers;
21
import java.lang.annotation.Inherited;
22
import java.lang.annotation.Retention;
23
import java.lang.annotation.RetentionPolicy;
24
import java.util.Map;
25
import java.util.Set;
26

27
/**
28
 * Optional features of classes derived from {@code Map}.
29
 *
30
 * @author George van den Driessche
31
 */
32
@SuppressWarnings("rawtypes") // maybe avoidable if we rework the whole package?
33
@GwtCompatible
34
public enum MapFeature implements Feature<Map> {
35
  /**
36
   * The map does not throw {@code NullPointerException} on calls such as {@code containsKey(null)},
37
   * {@code get(null)}, {@code keySet().contains(null)} or {@code remove(null)}.
38
   */
39
  ALLOWS_NULL_KEY_QUERIES,
40
  ALLOWS_NULL_KEYS(ALLOWS_NULL_KEY_QUERIES),
41
  /**
42
   * The map does not throw {@code NullPointerException} on calls such as {@code
43
   * containsValue(null)}, {@code values().contains(null)} or {@code values().remove(null)}.
44
   */
45
  ALLOWS_NULL_VALUE_QUERIES,
46
  ALLOWS_NULL_VALUES(ALLOWS_NULL_VALUE_QUERIES),
47
  /**
48
   * The map does not throw {@code NullPointerException} on calls such as {@code
49
   * entrySet().contains(null)} or {@code entrySet().remove(null)}
50
   */
51
  ALLOWS_NULL_ENTRY_QUERIES,
52
  /**
53
   * The map does not throw {@code NullPointerException} on any {@code null} queries.
54
   *
55
   * @see #ALLOWS_NULL_KEY_QUERIES
56
   * @see #ALLOWS_NULL_VALUE_QUERIES
57
   * @see #ALLOWS_NULL_ENTRY_QUERIES
58
   */
59
  ALLOWS_ANY_NULL_QUERIES(
60
      ALLOWS_NULL_ENTRY_QUERIES, ALLOWS_NULL_KEY_QUERIES, ALLOWS_NULL_VALUE_QUERIES),
61
  RESTRICTS_KEYS,
62
  RESTRICTS_VALUES,
63
  SUPPORTS_PUT,
64
  SUPPORTS_REMOVE,
65
  FAILS_FAST_ON_CONCURRENT_MODIFICATION,
66
  /**
67
   * Indicates that the constructor or factory method of a map, usually an immutable map, throws an
68
   * {@link IllegalArgumentException} when presented with duplicate keys instead of discarding all
69
   * but one.
70
   */
71
  REJECTS_DUPLICATES_AT_CREATION,
72

73
  GENERAL_PURPOSE(SUPPORTS_PUT, SUPPORTS_REMOVE);
74

75
  private final Set<Feature<? super Map>> implied;
76

77
  MapFeature(Feature<? super Map>... implied) {
78
    this.implied = Helpers.copyToSet(implied);
79
  }
80

81
  @Override
82
  public Set<Feature<? super Map>> getImpliedFeatures() {
83
    return implied;
84
  }
85

86
  @Retention(RetentionPolicy.RUNTIME)
87
  @Inherited
88
  @TesterAnnotation
89
  public @interface Require {
90
    public abstract MapFeature[] value() default {};
91

92
    public abstract MapFeature[] absent() default {};
93
  }
94
}
95

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

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

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

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