blob: c7af9bf3a892708238d3596acc346f2255e04c43 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
// version 8:
class MethodReference {
public MethodReference() {
}
public <T> MethodReference(T in) {
}
public void simpleInstanceReference() {
Runnable r = this::foo;
}
public void simpleConstructorReference() {
Runnable r = MethodReference::new;
}
public void simpleStaticReference() {
Runnable r = MethodReference::staticFoo;
}
public void generifiedStaticReference() {
StringConverter sc = MethodReference::<String>generifiedStaticFoo;
}
public void generifiedConstructorReference() {
FooConverter<MethodReference> fc = MethodReference::<String>new;
}
public void foo() {
}
private static void staticFoo() {
}
public static <T> T generifiedStaticFoo(T foo) {
return foo;
}
@FunctionalInterface
public interface StringConverter {
public String hello(String x);
}
@FunctionalInterface
public interface FooConverter<K> {
public K hello(String x);
}
}
|