mercredi 12 décembre 2018

Introspect a method reference in "::" double-colon notation?

Suppose I have a bunch of classes with methods, for example

class A {
   public void foo();
}

can a function be written in another class...

public String getMethodName(Function<?> func) { ... }

which when called with any method reference, for example

String val = getMethodName(A::foo);

would return the name of the method as a String, in this example "foo"?





Aucun commentaire:

Enregistrer un commentaire