Java toString - ToStringBuilder not sufficient; won't traverse

前端 未结 7 1875
Happy的楠姐
Happy的楠姐 2020-12-07 23:18

I need to be able to traverse through my entire object graph and log all contents of all member fields.

For example: Object A has a collection of Object B\'s which

相关标签:
7条回答
  • 2020-12-07 23:46

    Apache commons-lang 3.10 has the new RecursiveToStringStyle.

    ToStringBuilder.reflectionToString(table, new RecursiveToStringStyle());
    

    Outout

    Person@7f54[name=Stephen,age=29,smoker=false,job=Job@43cd2[title=Manager]]
    
    0 讨论(0)
提交回复
热议问题