vendredi 17 novembre 2017

Retrieve annotated and concrete methods in class

I have 1 interface, 1 abstract class and 1 concrete class. The annotation @Handler is used in two methods in the interface and abstract class:

public interface A<T> {
    @Handler
    void a(T data);
}

public abstract class B<V> implements A<Integer> {
    @Override
    void a(Integer data) {
        // implementation
    }

    @Handler
    public abstract void b(V data);
}

public abstract class C extends B<String> {
    @Override
    void b(String data) {
        // implementation
    }
}

I'd like to retrieve all concrete methods that are decorated with @Handler from C (including superclasses), i.e. B.a(Integer) and C.b(String), along with the method parameters Integer and String.

I tried using Apache Commons Lang's MethodUtils.getMethodsListWithAnnotation(), but it could only find the abstract methods (where the annotations are actually placed) without parameters' info:

A.a(java.lang.Object) 
B.b(java.lang.Object)

Is it possible to retrieve the concrete methods from the abstract ones?





Aucun commentaire:

Enregistrer un commentaire