Works with {@link ToStringBuilder} to create a "deep" toString
. But instead a single line like the {@link RecursiveToStringStyle} this creates a multiline String similar to the {@link ToStringStyle.MultiLineToStringStyle}.
To use this class write code as follows:
public class Job { String title; ... } public class Person { String name; int age; boolean smoker; Job job; ... public String toString() { return new ReflectionToStringBuilder(this, new MultilineRecursiveToStringStyle()).toString(); } }
This will produce a toString of the format:
Person@7f54[
name=Stephen,
age=29,
smoker=false,
job=Job@43cd2[
title=Manager
]
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|