mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-30 12:34:00 +07:00
for "Null check can be replaced with method call" inspection GitOrigin-RevId: ffa45cce88afb341cdeb9a49d4ee256251865bfc
28 lines
760 B
Java
28 lines
760 B
Java
// "Replace 'if' statement with 'Stream.ofNullable()' call" "true"
|
|
|
|
import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.IntStream;
|
|
import java.util.stream.Stream;
|
|
|
|
public class Main {
|
|
private static final Map<String, String> meaningfulData
|
|
= Collections.unmodifiableMap(new HashMap<>() {{
|
|
put("IntelliJ", "IDEA");
|
|
put("San Francisco", "California");
|
|
put("Java", "One");
|
|
put("Java 9", "Jigsaw");
|
|
}});
|
|
|
|
|
|
public static List<String> request(Set<String> keys) {
|
|
System.out.println("IntelliService in module: " + Main.class.getModule());
|
|
|
|
return keys.stream().flatMap(key -> {
|
|
String val = meaningfulData.get(key);
|
|
return Stream.ofNullable(val);
|
|
}).collect(Collectors.toList());
|
|
}
|
|
|
|
}
|