I want to go through an object and check for null fields using reflection. The problem starts when there are fields of a complex type/ list of objects. I tried to do it recursivly but got StackOverflowError. Object for scanning example:
public class MyModel {
private String name;
private Integer age;
private InnerModel innerModel;
private List<InnerModel> list;
}
public class InnerModel {
private String description;
}
And let's say I want to check if the description in InnerModel is null. What is the right way to do so with reflection and recursion?
Aucun commentaire:
Enregistrer un commentaire