001/* 002 * Copyright (C) 2008 The Guava Authors 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package com.google.common.collect.testing.features; 018 019import com.google.common.annotations.GwtCompatible; 020import com.google.common.collect.testing.Helpers; 021import java.lang.annotation.Inherited; 022import java.lang.annotation.Retention; 023import java.lang.annotation.RetentionPolicy; 024import java.util.List; 025import java.util.Set; 026 027/** 028 * Optional features of classes derived from {@code List}. 029 * 030 * @author George van den Driessche 031 */ 032@SuppressWarnings("rawtypes") // maybe avoidable if we rework the whole package? 033@GwtCompatible 034public enum ListFeature implements Feature<List> { 035 SUPPORTS_SET, 036 SUPPORTS_ADD_WITH_INDEX(CollectionFeature.SUPPORTS_ADD), 037 SUPPORTS_REMOVE_WITH_INDEX(CollectionFeature.SUPPORTS_REMOVE), 038 039 GENERAL_PURPOSE( 040 CollectionFeature.GENERAL_PURPOSE, 041 SUPPORTS_SET, 042 SUPPORTS_ADD_WITH_INDEX, 043 SUPPORTS_REMOVE_WITH_INDEX), 044 045 /** Features supported by lists where only removal is allowed. */ 046 REMOVE_OPERATIONS(CollectionFeature.REMOVE_OPERATIONS, SUPPORTS_REMOVE_WITH_INDEX); 047 048 private final Set<Feature<? super List>> implied; 049 050 ListFeature(Feature<? super List>... implied) { 051 this.implied = Helpers.copyToSet(implied); 052 } 053 054 @Override 055 public Set<Feature<? super List>> getImpliedFeatures() { 056 return implied; 057 } 058 059 @Retention(RetentionPolicy.RUNTIME) 060 @Inherited 061 @TesterAnnotation 062 public @interface Require { 063 ListFeature[] value() default {}; 064 065 ListFeature[] absent() default {}; 066 } 067}