Top Description Fields Constructors Methods
org.apache.commons.lang3.builder

public Class MultilineRecursiveToStringStyle

extends RecursiveToStringStyle
Class Inheritance
Imports
org.apache.commons.lang3.ClassUtils, .StringUtils

Works with 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> ]

Since
3.4

Field Summary

Modifier and TypeField and Description
private static final int
INDENT

Indenting of inner lines.

private static final long
private int
spaces

Current indenting.

Constructor Summary

AccessConstructor and Description
public
MultilineRecursiveToStringStyle()

Constructs a new instance.

Method Summary

Modifier and TypeMethod and Description
protected void
appendDetail(final StringBuffer buffer, final String fieldName, final boolean[] array)

Overrides org.apache.commons.lang3.builder.ToStringStyle.appendDetail.

Appends to the toString the detail of a boolean array.

protected void
appendDetail(final StringBuffer buffer, final String fieldName, final byte[] array)

Overrides org.apache.commons.lang3.builder.ToStringStyle.appendDetail.

Appends to the toString the detail of a byte array.

protected void
appendDetail(final StringBuffer buffer, final String fieldName, final char[] array)

Overrides org.apache.commons.lang3.builder.ToStringStyle.appendDetail.

Appends to the toString the detail of a char array.

protected void
appendDetail(final StringBuffer buffer, final String fieldName, final double[] array)

Overrides org.apache.commons.lang3.builder.ToStringStyle.appendDetail.

Appends to the toString the detail of a double array.

protected void
appendDetail(final StringBuffer buffer, final String fieldName, final float[] array)

Overrides org.apache.commons.lang3.builder.ToStringStyle.appendDetail.

Appends to the toString the detail of a float array.

protected void
appendDetail(final StringBuffer buffer, final String fieldName, final int[] array)

Overrides org.apache.commons.lang3.builder.ToStringStyle.appendDetail.

Appends to the toString the detail of an int array.

protected void
appendDetail(final StringBuffer buffer, final String fieldName, final long[] array)

Overrides org.apache.commons.lang3.builder.ToStringStyle.appendDetail.

Appends to the toString the detail of a long array.

public void
appendDetail(final StringBuffer buffer, final String fieldName, final Object value)

Overrides org.apache.commons.lang3.builder.RecursiveToStringStyle.appendDetail.

Appends to the toString an Object value, printing the full detail of the Object.

protected void
appendDetail(final StringBuffer buffer, final String fieldName, final Object[] array)

Overrides org.apache.commons.lang3.builder.ToStringStyle.appendDetail.

Appends to the toString the detail of an Object array.

protected void
appendDetail(final StringBuffer buffer, final String fieldName, final short[] array)

Overrides org.apache.commons.lang3.builder.ToStringStyle.appendDetail.

Appends to the toString the detail of a short array.

protected void
reflectionAppendArrayDetail(final StringBuffer buffer, final String fieldName, final Object array)

Overrides org.apache.commons.lang3.builder.ToStringStyle.reflectionAppendArrayDetail.

Appends to the toString the detail of an array type.

private void
resetIndent()

Resets the fields responsible for the line breaks and indenting.

private String

Returns:

a StringBuilder with {spaces} leading space characters.
spacer
(final int
how far to indent
spaces
)

Creates a StringBuilder responsible for the indenting.

Inherited from org.apache.commons.lang3.builder.RecursiveToStringStyle:
acceptappendDetail

Field Detail

INDENTback to summary
private static final int INDENT

Indenting of inner lines.

serialVersionUIDback to summary
private static final long serialVersionUID

Hides org.apache.commons.lang3.builder.RecursiveToStringStyle.serialVersionUID.

Required for serialization support.

See Also
java.io.Serializable
spacesback to summary
private int spaces

Current indenting.

Constructor Detail

MultilineRecursiveToStringStyleback to summary
public MultilineRecursiveToStringStyle()

Constructs a new instance.

Method Detail

appendDetailback to summary
protected void appendDetail(final StringBuffer buffer, final String fieldName, final boolean[] array)

Overrides org.apache.commons.lang3.builder.ToStringStyle.appendDetail.

Doc from org.apache.commons.lang3.builder.ToStringStyle.appendDetail.

Appends to the toString the detail of a boolean array.

Annotations
@Override
appendDetailback to summary
protected void appendDetail(final StringBuffer buffer, final String fieldName, final byte[] array)

Overrides org.apache.commons.lang3.builder.ToStringStyle.appendDetail.

Doc from org.apache.commons.lang3.builder.ToStringStyle.appendDetail.

Appends to the toString the detail of a byte array.

Annotations
@Override
appendDetailback to summary
protected void appendDetail(final StringBuffer buffer, final String fieldName, final char[] array)

Overrides org.apache.commons.lang3.builder.ToStringStyle.appendDetail.

Doc from org.apache.commons.lang3.builder.ToStringStyle.appendDetail.

Appends to the toString the detail of a char array.

Annotations
@Override
appendDetailback to summary
protected void appendDetail(final StringBuffer buffer, final String fieldName, final double[] array)

Overrides org.apache.commons.lang3.builder.ToStringStyle.appendDetail.

Doc from org.apache.commons.lang3.builder.ToStringStyle.appendDetail.

Appends to the toString the detail of a double array.

Annotations
@Override
appendDetailback to summary
protected void appendDetail(final StringBuffer buffer, final String fieldName, final float[] array)

Overrides org.apache.commons.lang3.builder.ToStringStyle.appendDetail.

Doc from org.apache.commons.lang3.builder.ToStringStyle.appendDetail.

Appends to the toString the detail of a float array.

Annotations
@Override
appendDetailback to summary
protected void appendDetail(final StringBuffer buffer, final String fieldName, final int[] array)

Overrides org.apache.commons.lang3.builder.ToStringStyle.appendDetail.

Doc from org.apache.commons.lang3.builder.ToStringStyle.appendDetail.

Appends to the toString the detail of an int array.

Annotations
@Override
appendDetailback to summary
protected void appendDetail(final StringBuffer buffer, final String fieldName, final long[] array)

Overrides org.apache.commons.lang3.builder.ToStringStyle.appendDetail.

Doc from org.apache.commons.lang3.builder.ToStringStyle.appendDetail.

Appends to the toString the detail of a long array.

Annotations
@Override
appendDetailback to summary
public void appendDetail(final StringBuffer buffer, final String fieldName, final Object value)

Overrides org.apache.commons.lang3.builder.RecursiveToStringStyle.appendDetail.

Doc from org.apache.commons.lang3.builder.ToStringStyle.appendDetail.

Appends to the toString an Object value, printing the full detail of the Object.

Annotations
@Override
appendDetailback to summary
protected void appendDetail(final StringBuffer buffer, final String fieldName, final Object[] array)

Overrides org.apache.commons.lang3.builder.ToStringStyle.appendDetail.

Doc from org.apache.commons.lang3.builder.ToStringStyle.appendDetail.

Appends to the toString the detail of an Object array.

Annotations
@Override
appendDetailback to summary
protected void appendDetail(final StringBuffer buffer, final String fieldName, final short[] array)

Overrides org.apache.commons.lang3.builder.ToStringStyle.appendDetail.

Doc from org.apache.commons.lang3.builder.ToStringStyle.appendDetail.

Appends to the toString the detail of a short array.

Annotations
@Override
reflectionAppendArrayDetailback to summary
protected void reflectionAppendArrayDetail(final StringBuffer buffer, final String fieldName, final Object array)

Overrides org.apache.commons.lang3.builder.ToStringStyle.reflectionAppendArrayDetail.

Doc from org.apache.commons.lang3.builder.ToStringStyle.reflectionAppendArrayDetail.

Appends to the toString the detail of an array type.

Annotations
@Override
resetIndentback to summary
private void resetIndent()

Resets the fields responsible for the line breaks and indenting. Must be invoked after changing the spaces value.

spacerback to summary
private String spacer(final int spaces)

Creates a StringBuilder responsible for the indenting.

Parameters
spaces:int

how far to indent

Returns:String

a StringBuilder with {spaces} leading space characters.