Q:

getFieldsAnnotatedWith annotation containing

Annotation
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Searchable {
    SearchType[] types() default { SearchType.ALL };
}

Reflections in some method
Reflections reflections = new Reflections(packageName);
reflections.getFieldsAnnotatedWith(); // Here's the problem

I would like to return all fields annotated with Searchable containing at least SearchType.ALL. I have tried defining a new Searchable() { ... } to pass with this method. Though this would result in only fields with an exact match. E.g. ONLY containing SearchType.ALL. This way:
new Searchable() {
        @Override public SearchType[] types() { return { SearchType.ALL }; }
        @Override public Class<? extends Annotation> annotationType() { return Searchable.class; }
        }

I would like fields with @Searchable(types = { SearchType.ALL, SearchType.TEXT }) to be a hit too, since it contains SearchType.ALL. How can I accomplish this?

A:

I don't know much about the Reflections API, but you can simply get all the fields annotated with the Searchable annotation, and then check if their Searchable annotation's types contains SearchType.ALL:
Set<Field> fields = reflections.getFieldsAnnotatedWith(Searchable.class);
Set<Field> wanted = new HashSet<Field>();
for (Field field : fields) {
    Searchable annotation = field.getAnnotation(Searchable.class);
    if (Arrays.asList(annotation.types).contains(SearchType.ALL)) {
        wanted.add(field);
    }
}

