I had a class:
class A {
public final Integer orgId;
}
I replaced it with the record in Java 17:
record A (Integer orgId) {
}
Also, I had a code that did a validation via reflection that is working with the regular class, but doesn't work with the Records:
Field[] fields = obj.getClass().getFields(); //getting empty array here for the record
for (Field field : fields) {
}
What would be the correct way to get the Record object fields and its values via reflection in Java 17?
Aucun commentaire:
Enregistrer un commentaire