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 22 import java.lang.annotation.Inherited; 23 import java.lang.annotation.Retention; 24 import java.lang.annotation.RetentionPolicy; 25 import java.util.List; 26 import java.util.Set; 27 28 /** 29 * Optional features of classes derived from {@code List}. 30 * 31 * @author George van den Driessche 32 */ 33 // Enum values use constructors with generic varargs. 34 @SuppressWarnings("unchecked") 35 @GwtCompatible 36 public enum ListFeature implements Feature<List> { 37 SUPPORTS_SET, 38 SUPPORTS_ADD_WITH_INDEX(CollectionFeature.SUPPORTS_ADD), 39 SUPPORTS_REMOVE_WITH_INDEX(CollectionFeature.SUPPORTS_REMOVE), 40 41 GENERAL_PURPOSE( 42 CollectionFeature.GENERAL_PURPOSE, 43 SUPPORTS_SET, 44 SUPPORTS_ADD_WITH_INDEX, 45 SUPPORTS_REMOVE_WITH_INDEX 46 ), 47 48 /** Features supported by lists where only removal is allowed. */ 49 REMOVE_OPERATIONS( 50 CollectionFeature.REMOVE_OPERATIONS, 51 SUPPORTS_REMOVE_WITH_INDEX 52 ); 53 54 private final Set<Feature<? super List>> implied; 55 56 ListFeature(Feature<? super List> ... implied) { 57 this.implied = Helpers.copyToSet(implied); 58 } 59 60 @Override 61 public Set<Feature<? super List>> getImpliedFeatures() { 62 return implied; 63 } 64 65 @Retention(RetentionPolicy.RUNTIME) 66 @Inherited 67 @TesterAnnotation 68 public @interface Require { 69 ListFeature[] value() default {}; 70 ListFeature[] absent() default {}; 71 } 72 } 73