mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-30 18:28:55 +07:00
16 lines
492 B
Java
16 lines
492 B
Java
// "Fix all 'Optional can be replaced with sequence of if statements' problems in file" "true"
|
|
|
|
class Test {
|
|
|
|
void inStatement(String in) {
|
|
Optional.ofNullable<caret>(in).filter(s -> s.length > 2).map(s -> s.substring(3)).map(ss -> getStrOrNull(ss))
|
|
.ifPresentOrElse(value -> System.out.println("found value %s", value),
|
|
() -> System.out.println("value is null"));
|
|
}
|
|
|
|
|
|
private String getStrOrNull(String s) {
|
|
return s.length() > 2 ? s : null;
|
|
}
|
|
|
|
} |