mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-05 08:06:56 +07:00
14 lines
449 B
Java
14 lines
449 B
Java
// "Fix all 'Optional call chain can be simplified' problems in file" "false"
|
|
import java.util.Optional;
|
|
|
|
public class Test {
|
|
public String getDefaultValue() {
|
|
return "foo";
|
|
}
|
|
|
|
public void test(Optional<String> opt) {
|
|
// proposed change is longer:
|
|
// opt.filter(obj -> !obj.isEmpty()).map(obj -> obj.trim()).orElse(null);
|
|
String result = opt.map(obj -> obj.isEmpty() ? null : obj.trim()).orEl<caret>se(null);
|
|
}
|
|
} |