Was using org.reflections
API to find that it doesn't work with Enums
:
List<ClassLoader> classLoadersList = new LinkedList<>();
classLoadersList.add(ClasspathHelper.contextClassLoader());
classLoadersList.add(ClasspathHelper.staticClassLoader());
Reflections reflections = new Reflections(new org.reflections.util.ConfigurationBuilder()
.setScanners(new SubTypesScanner(false), new ResourcesScanner())
.setUrls(ClasspathHelper.forClassLoader(classLoadersList.toArray(new ClassLoader[0])))
.filterInputsBy(new FilterBuilder().include(FilterBuilder.prefix("my.package"))));
Set<Class<? extends Object>> allClasses = reflections.getSubTypesOf(Enum.class);
// Above line should've returned all enums recursively, doesn't work!
Any alternate ways?
Aucun commentaire:
Enregistrer un commentaire