vendredi 17 avril 2015

How to get method references via reflection? [duplicate]


This question already has an answer here:




Suppose I have some functional interface like Function and some methods of different classes for which I can take method references, for example:



class A {
public int getPrimitive() { return 0; }
public Integer getBoxed() { return 0; }
public static int getStaticPrimitive(A a) { return 1; }
}

Function<Integer, A> primitive = A::getPrimitive;
Function<Integer, A> boxed = A::getBoxed;
Function<Integer, A> staticPrimitive = A::getStaticPrimitive;


How I can get these method references converted to instances of Function interface via reflection?






Aucun commentaire:

Enregistrer un commentaire