blob: cb8442e59d12b149f2480e7b3cec60fb7771f66c (
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
|
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Collectors;
class Test {
private static class Thing {
final String val;
public Thing(String val) {
this.val = val;
}
}
public static Optional<List<String>> highlights() {
return Optional.of(Collections.singletonList(new Thing("Hello")))
.map(l -> l
.stream()
.map(t -> t.val + " world!")
.collect(Collectors.toList()));
}
public static Optional<List<String>> works() {
return Optional.of(Collections.singletonList(new Thing("Hello")))
.map(l -> l
.stream()
.map(t -> t.val + " world!")
.collect(Collectors.toList()));
}
}
|