-
-
Notifications
You must be signed in to change notification settings - Fork 705
Repeatable Annotations #144
Copy link
Copy link
Open
Description
I am using reflections version 0.9.10 with javassist version 3.20.0-GA. I have the following annotations and classes:
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
public @interface Names {
Name[] value() default {};
}
@Repeatable(Names.class)
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
public @interface Names {
String name();
}
@Name(name = "foo")
public class SingleName extends BaseClass {}
@Name(name = "foo")
@Name(name = "bar")
public class MultiName extends BaseClass {}I am trying to look up all classes that have occurrence of the @Name annotation. I used the following to try to do that:
new Reflections(BaseClass.class.getPackage().getName()).getTypesAnnotatedWith(Name.class)The above only works when the class has as single @Name. To get a classes with more than one occurrence of the @Name I need to use the following:
new Reflections(BaseClass.class.getPackage().getName()).getTypesAnnotatedWith(Names.class)I ideally I would like to not have to merge the results from both of these calls. It seems that java supports that because when I do the following:
SingleName.class.getAnnotationsByType(Name.class); //Return an array of one
MultiName.class.getAnnotationsByType(Name.class); //Returns an array of twoDoes reflections currently support this and I am using it wrong? If not would it be possible to add support for repeatable annotations? Thanks.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels