public List<String> getAllFields() {
return Arrays.stream(getClass().getDeclaredFields())
.filter(field -> !Modifier.isStatic(field.getModifiers()))
.map(this::getFieldValue)
.collect(Collectors.toList());
}
private String getFieldValue(final Field field) {
try {
return Objects.toString(field.get(this));
} catch (final IllegalAccessException e) {
throw new RuntimeException(e);
}
}
Edit: Som si nevšimol, že mapping používalo this, takže to s tou statickou metódou beriem späť, ale to si si asi už všimol.