public class RecursiveToStringStyle extends ToStringStyle
Works with 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)
Append to the
toString an Object
value, printing the full detail of the Object . |
public void appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, java.lang.Object value)
ToStringStyle
Append to the toString
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 null
Copyright © 2010 - 2020 Adobe. All Rights Reserved