Im trying to create a generic lambda so I dont need to redefine it for individual types. To do that I need to access the type parameters that were passed to the function. Unfortunately I didnt find any documentation on how to do that.
This is an example of what I want to do but the in front of the lambda wont compile:
import java.util.ArrayList;
public class Test {
interface SolveFunction {
<In, Out> Out apply(In in);
}
public static void main(String...args) {
SolveFunction f = <In, Out> (In a) -> {
ArrayList<Out> list = new ArrayList<>();
return list;
};
System.out.println(f.<String, Integer>apply("Hi").size());
}
}