jeudi 27 avril 2023

Get fields of a class including the fields of objects with in a class using Java Reflection

Problem: I need to get all fields of a class including fields from properties whose type of another class.

Example:

class A { int test1, string test2, class B classb }

class B { string test3 }

Out-put should be test1, test2, test3

It looks like I need to use getDeclaredFields() on the class but how can I achieve above ?

Tried getDeclaredFields() but it only gives fields from one class

NOTE: the classes are actually POJO models.





Aucun commentaire:

Enregistrer un commentaire