mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-06 08:00:18 +07:00
24 lines
662 B
Java
24 lines
662 B
Java
// "Replace null check with ifPresent()" "false"
|
|
import java.util.Optional;
|
|
import java.lang.reflect.Field;
|
|
import java.util.ArrayList;
|
|
import java.util.Optional;
|
|
|
|
public class Test {
|
|
static Optional<String> getFoo(Class<?> type) {
|
|
return Optional.empty();
|
|
}
|
|
static Optional<String> getBar(Field field) {
|
|
return Optional.empty();
|
|
}
|
|
|
|
public static void main(String[] args) {
|
|
final Class<?> cls = ArrayList.class;
|
|
for (Field f : cls.getFields()) {
|
|
final String fieldType = getFoo(f.getType()).orElseGet(() -> getBar(f).<caret>orElse(null));
|
|
if (fieldType != null) {
|
|
System.out.println(fieldType);
|
|
}
|
|
}
|
|
}
|
|
} |