public class RecursiveToStringStyle extends ToStringStyle
ToStringBuilder to create a "deep" toString.
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 RecursiveToStringStyle()).toString();
}
}
This will produce a toString of the format:
Person@7f54[name=Stephen,age=29,smoker=false,job=Job@43cd2[title=Manager]]
DEFAULT_STYLE, JSON_STYLE, MULTI_LINE_STYLE, NO_CLASS_NAME_STYLE, NO_FIELD_NAMES_STYLE, SHORT_PREFIX_STYLE, SIMPLE_STYLE| Constructor and Description |
|---|
RecursiveToStringStyle()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
appendDetail(java.lang.StringBuffer buffer,
java.lang.String fieldName,
java.lang.Object value)
Appends to the
toString an Object
value, printing the full detail of the Object. |
append, append, append, append, append, append, append, append, append, append, append, append, append, append, append, append, append, append, appendEnd, appendStart, appendSuper, appendToString, getRegistrypublic void appendDetail(java.lang.StringBuffer buffer,
java.lang.String fieldName,
java.lang.Object value)
ToStringStyletoString an Object
value, printing the full detail of the Object.buffer - the StringBuffer to populatefieldName - the field name, typically not used as already appendedvalue - the value to add to the toString,
not nullCopyright © 2010 - 2023 Adobe. All Rights Reserved