mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-06 08:00:18 +07:00
GitOrigin-RevId: c4db6507c258e5611f6d47b9373a0c2531802345
10 lines
339 B
Java
10 lines
339 B
Java
// "Collapse loop with stream 'findFirst()'" "true-preview"
|
|
|
|
import java.util.*;
|
|
|
|
public class Main {
|
|
public Runnable getRunnable(List<String> data) {
|
|
Runnable def = () -> {};
|
|
return data.stream().filter(s -> s.startsWith("xyz")).findFirst().<Runnable>map(s -> s.length() > 2 ? s::trim : System.out::println).orElse(def);
|
|
}
|
|
} |