Takhle?
public ArrayList<String> getAllFields() {
var fields = Arrays.stream(getClass().getDeclaredFields());
var list = fields
.filter(f -> !Modifier.isStatic(f.getModifiers()))
.map(this::getFieldValue)
.collect(Collectors.toCollection(ArrayList::new));
return list;
}
private String getFieldValue(Field field) {
try {
return field.get(this).toString();
} catch (IllegalArgumentException | IllegalAccessException e) {
return "";
}
}
Nepochopil jsem to s tou RuntimeException respektive jak to napsat?
Díky