I am new to Java andJavaReflections and I am struggling with this for the last few hours. I have classes that are annotated this way @BaseProp(category = Property.CATEGORY1) where Property is a class defined as
public enum Property{ CATEGORY1("category1"), CATTEGORY2("category2");
public static Property getCategory(String value) {
return Property
.valueOf(Optional.ofNullable(value).orElseThrow(IllegalArgumentException::new).toUpperCase());
}
It has appropriate getters,setters , constructors and this method getCategory().
My other classes in multiple packages are annottated as @Prop(category = Property.CATGORY1)
These classes extend a base class.
I want to create 2 ARRAYLISTS of objects for classes - 1. that extends BaseClass and category is annotated as CATEGORY1 2. that extends BaseClass and category is annotated as CATEGORY2
In the sense I want to identify the classes and create objects for them and put them in a general ArrayList of Objectx. How can I do this using reflections and Java??
Aucun commentaire:
Enregistrer un commentaire