public class MultilineRecursiveToStringStyle extends RecursiveToStringStyle
ToStringBuilder to create a "deep" toString.
But instead a single line like the RecursiveToStringStyle this creates a multiline String
similar to the ToStringStyle.MULTI_LINE_STYLE.
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
]
]
DEFAULT_STYLE, JSON_STYLE, MULTI_LINE_STYLE, NO_CLASS_NAME_STYLE, NO_FIELD_NAMES_STYLE, SHORT_PREFIX_STYLE, SIMPLE_STYLE| Constructor and Description |
|---|
MultilineRecursiveToStringStyle()
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 MultilineRecursiveToStringStyle()
public 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.appendDetail in class RecursiveToStringStylebuffer - 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