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[ <br>
name=Stephen, <br>
age=29, <br>
smokealse, <br>
job=Job@43cd2[ <br>
title=Manager <br>
] <br>
]
| Modifier and Type | Field and Description |
|---|---|
| private static final int | INDENT
Indenting of inner lines. |
| private static final long | serialVersionUID
Hides org. |
| private int | spaces
Current indenting. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected void | appendDetail(final StringBuffer buffer, final String fieldName, final boolean[] array)
Overrides org. Appends to the |
| protected void | appendDetail(final StringBuffer buffer, final String fieldName, final byte[] array)
Overrides org. Appends to the |
| protected void | appendDetail(final StringBuffer buffer, final String fieldName, final char[] array)
Overrides org. Appends to the |
| protected void | appendDetail(final StringBuffer buffer, final String fieldName, final double[] array)
Overrides org. Appends to the |
| protected void | appendDetail(final StringBuffer buffer, final String fieldName, final float[] array)
Overrides org. Appends to the |
| protected void | appendDetail(final StringBuffer buffer, final String fieldName, final int[] array)
Overrides org. Appends to the |
| protected void | appendDetail(final StringBuffer buffer, final String fieldName, final long[] array)
Overrides org. Appends to the |
| public void | appendDetail(final StringBuffer buffer, final String fieldName, final Object value)
Overrides org. Appends to the |
| protected void | appendDetail(final StringBuffer buffer, final String fieldName, final Object[] array)
Overrides org. Appends to the |
| protected void | appendDetail(final StringBuffer buffer, final String fieldName, final short[] array)
Overrides org. Appends to the |
| protected void | reflectionAppendArrayDetail(final StringBuffer buffer, final String fieldName, final Object array)
Overrides org. Appends to the |
| private void | |
| private String | Returns: a StringBuilder with {spaces} leading space characters.how far to indent spaces)Creates a StringBuilder responsible for the indenting. |
| INDENT | back to summary |
|---|---|
| private static final int INDENT Indenting of inner lines. | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Hides org. Required for serialization support.
| |
| spaces | back to summary |
|---|---|
| private int spaces Current indenting. | |
| MultilineRecursiveToStringStyle | back to summary |
|---|---|
| public MultilineRecursiveToStringStyle() Constructs a new instance. | |
| appendDetail | back to summary |
|---|---|
| protected void appendDetail(final StringBuffer buffer, final String fieldName, final boolean[] array) Overrides org. Doc from org. Appends to the
| |
| appendDetail | back to summary |
|---|---|
| protected void appendDetail(final StringBuffer buffer, final String fieldName, final byte[] array) Overrides org. Doc from org. Appends to the
| |
| appendDetail | back to summary |
|---|---|
| protected void appendDetail(final StringBuffer buffer, final String fieldName, final char[] array) Overrides org. Doc from org. Appends to the
| |
| appendDetail | back to summary |
|---|---|
| protected void appendDetail(final StringBuffer buffer, final String fieldName, final double[] array) Overrides org. Doc from org. Appends to the
| |
| appendDetail | back to summary |
|---|---|
| protected void appendDetail(final StringBuffer buffer, final String fieldName, final float[] array) Overrides org. Doc from org. Appends to the
| |
| appendDetail | back to summary |
|---|---|
| protected void appendDetail(final StringBuffer buffer, final String fieldName, final int[] array) Overrides org. Doc from org. Appends to the
| |
| appendDetail | back to summary |
|---|---|
| protected void appendDetail(final StringBuffer buffer, final String fieldName, final long[] array) Overrides org. Doc from org. Appends to the
| |
| appendDetail | back to summary |
|---|---|
| public void appendDetail(final StringBuffer buffer, final String fieldName, final Object value) Overrides org. Doc from org. Appends to the
| |
| appendDetail | back to summary |
|---|---|
| protected void appendDetail(final StringBuffer buffer, final String fieldName, final Object[] array) Overrides org. Doc from org. Appends to the
| |
| appendDetail | back to summary |
|---|---|
| protected void appendDetail(final StringBuffer buffer, final String fieldName, final short[] array) Overrides org. Doc from org. Appends to the
| |
| reflectionAppendArrayDetail | back to summary |
|---|---|
| protected void reflectionAppendArrayDetail(final StringBuffer buffer, final String fieldName, final Object array) Overrides org. Doc from org. Appends to the
| |
| resetIndent | back to summary |
|---|---|
| private void resetIndent() Resets the fields responsible for the line breaks and indenting.
Must be invoked after changing the | |
| spacer | back to summary |
|---|---|
| private String spacer(final int spaces) Creates a StringBuilder responsible for the indenting.
| |