, . , .
public static <@FunctionalInterface T extends Function<A, B>> T foo() {
return a -> bar;
}
, , , T, foo(), foo() foo(). .
, Erasure. foo(), . , T.
, , , . . new -.
, - , , , "". , factory, :
public static <A,B> Function<A,B> getter(Map<?, ? extends B> map) {
return a->map.get(a);
}
A B Map, Map.get A, , - B, ? extends B, B.
, Function, X,
interface X extends Function<String, Integer> {}
factory X, , :
Map<String, Integer> map=new HashMap<>();
X x=getter(map)::apply;
x.apply("foo");
X, , .