I need to retrieve some annotated methods from various classes. I'm using this code:
Reflections reflections = new Reflections(
new ConfigurationBuilder()
.setUrls(ClasspathHelper.forPackage("my.package"))
.setScanners(new MethodAnnotationsScanner())
);
Set<Method> resources =
reflections.getMethodsAnnotatedWith(org.testng.annotations.Test.class);
I found the code for the Reflections class. However, this code is for the entire package
(and with that said, for some reason the code returns all annotated methods in my project, and not just the specified package).
However, I just want to get the annotated methods from one specific class. I can't make heads or tails of the Reflections javadoc.
How can I change the constructor so that only the annotated methods from a specific class are returned?
Aucun commentaire:
Enregistrer un commentaire