I want to access Method via reflection. The Problem is that the Method is annotated in an Interface:
public interface MyRepository extends CrudRepository<MyClass, Long> {
@CustomAnnotation
MyClass findByName(String name);
}
As you see I use spring which provide a class that will implement this Repository. I want to create a Method, that will get a Repository and invoke all methods that are annotated with @CustomAnnotation.
public void do(Repository<?, ?> repository){
Method[] methods=repository.getClass().getMethodThatAreAnnotatedInInterfaceWith(CustomAnnotation.class);
....
}
Because the implementation of an interface won’t have the annotations of the interface present, I do not know how to query these methods.
Aucun commentaire:
Enregistrer un commentaire