import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Collectors;
public final class Main {
private static <T, U> List<U> compactMap(
List<T> list,
Function<T, Optional<U>> transform) {
return list.stream()
.map(e -> transform.apply(e))
.flatMap(o -> o.stream())
.collect(Collectors.toList());
}
public static void main
(String[] args
) { "The", "quick", "brown", null, "jumps",
"over", "the", "lazy", null);
var all = compactMap(
list,
e -> Optional.ofNullable(e)
.
map(s
-> Integer.
valueOf(s.
length()))); for (var e : all) {
}
}
}
aW1wb3J0IGphdmEudXRpbC5BcnJheXM7CmltcG9ydCBqYXZhLnV0aWwuTGlzdDsKaW1wb3J0IGphdmEudXRpbC5PcHRpb25hbDsKaW1wb3J0IGphdmEudXRpbC5mdW5jdGlvbi5GdW5jdGlvbjsKaW1wb3J0IGphdmEudXRpbC5zdHJlYW0uQ29sbGVjdG9yczsKCnB1YmxpYyBmaW5hbCBjbGFzcyBNYWluIHsKIAoJcHJpdmF0ZSBzdGF0aWMgPFQsIFU+IExpc3Q8VT4gY29tcGFjdE1hcCgKCQkJTGlzdDxUPiBsaXN0LAoJCQlGdW5jdGlvbjxULCBPcHRpb25hbDxVPj4gdHJhbnNmb3JtKSB7CgkgICAgcmV0dXJuIGxpc3Quc3RyZWFtKCkKCSAgICAgICAgLm1hcChlIC0+IHRyYW5zZm9ybS5hcHBseShlKSkKCSAgICAgICAgLmZsYXRNYXAobyAtPiBvLnN0cmVhbSgpKQoJICAgICAgICAuY29sbGVjdChDb2xsZWN0b3JzLnRvTGlzdCgpKTsKCX0KCiAgICBwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmdbXSBhcmdzKSB7CiAgICAJdmFyIGxpc3QgPSBBcnJheXMuYXNMaXN0KAogICAgCQkiVGhlIiwgInF1aWNrIiwgImJyb3duIiwgbnVsbCwgImp1bXBzIiwKICAgIAkJIm92ZXIiLCAidGhlIiwgImxhenkiLCBudWxsKTsKICAgIAl2YXIgYWxsID0gY29tcGFjdE1hcCgKICAgIAkJbGlzdCwKICAgIAkJZSAtPiBPcHRpb25hbC5vZk51bGxhYmxlKGUpCiAgICAJCQkubWFwKHMgLT4gSW50ZWdlci52YWx1ZU9mKHMubGVuZ3RoKCkpKSk7CiAgICAJZm9yICh2YXIgZSA6IGFsbCkgewogICAgCQlTeXN0ZW0ub3V0LnByaW50bG4oZSk7CiAgICAJfQogICAgfQp9Cg==