mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-20 11:36:16 +07:00
12 lines
342 B
Java
12 lines
342 B
Java
// "Simplify optional chain to 'opt.filter(...).map(...).orElseGet(...)'" "true"
|
|
import java.util.Optional;
|
|
|
|
public class Test {
|
|
public String getDefaultValue() {
|
|
return "foo";
|
|
}
|
|
|
|
public void test(Optional<String> opt) {
|
|
String result = opt.filter(obj -> !obj.isEmpty()).map(String::trim).orElseGet(this::getDefaultValue);
|
|
}
|
|
} |