mercredi 27 octobre 2021

Java reflection, is there an easy way to get field value by 'field path'?

I have a pretty complex class, like,

classA {
  public classB b;
}

classB {
  public classC c;
}

classC {
  public List<classD> d;
}
...

Now, given an instance of classA, and a field path like 'b.c.d.e.f.g', is there an easy way to get the target field value via reflection? Any existing library or something?

Many thanks.





Aucun commentaire:

Enregistrer un commentaire