DC
Size: a a a
DC
AB
AE
IO
IO
AB
D
IO
IO
NG
IO
IO
IO
SP
NG
IO
IO
SP
IO
D
Function<Integer, Optional<Integer>> f = x -> {
if (x == null) {
x = -1;
} else if (x == 2) {
x = null;
} else {
x = x + 1;
}
return Optional.ofNullable(x);
};
Optional.of(1).flatMap(f).equals(f.apply(1)); // ok
Optional.ofNullable((Integer) null).flatMap(f).equals(f.apply(null)); // упс