On this page

MultilineRecursiveToStringStyle

public class org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle extends RecursiveToStringStyle[source]

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> &nbsp; name=Stephen, <br> &nbsp; age=29, <br> &nbsp; smokealse, <br> &nbsp; job=Job@43cd2[ <br> &nbsp; &nbsp; title=Manager <br> &nbsp;  ] <br> ]
Since:

3.4

Constructors

MultilineRecursiveToStringStyle()

Constructs a new instance.

public MultilineRecursiveToStringStyle()[source]

Constructs a new instance.

Methods

protected void

appendDetail(StringBuffer buffer, String fieldName, boolean[] array)

Appends to the toString the detail of a boolean array.

protected void

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

Appends to the toString the detail of a byte array.

protected void

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

Appends to the toString the detail of a char array.

protected void

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

Appends to the toString the detail of a double array.

protected void

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

Appends to the toString the detail of a float array.

protected void

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

Appends to the toString the detail of an int array.

void

appendDetail(StringBuffer buffer, String fieldName, Object value)

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

protected void

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

Appends to the toString the detail of an Object array.

protected void

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

Appends to the toString the detail of a long array.

protected void

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

Appends to the toString the detail of a short array.

protected void

reflectionAppendArrayDetail(StringBuffer buffer, String fieldName, Object array)

Appends to the toString the detail of an array type.

protected void appendDetail(StringBuffer buffer, String fieldName, boolean[] array)[source]

Appends to the toString the detail of a boolean array.

Overrides:

appendDetail in class ToStringStyle

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended.

  • array – The array to add to the toString, not null.

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

Appends to the toString the detail of a byte array.

Overrides:

appendDetail in class ToStringStyle

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended.

  • array – The array to add to the toString, not null.

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

Appends to the toString the detail of a char array.

Overrides:

appendDetail in class ToStringStyle

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended.

  • array – The array to add to the toString, not null.

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

Appends to the toString the detail of a double array.

Overrides:

appendDetail in class ToStringStyle

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended

  • array – The array to add to the toString, not null.

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

Appends to the toString the detail of a float array.

Overrides:

appendDetail in class ToStringStyle

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended.

  • array – The array to add to the toString, not null.

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

Appends to the toString the detail of an int array.

Overrides:

appendDetail in class ToStringStyle

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended.

  • array – The array to add to the toString, not null.

public void appendDetail(StringBuffer buffer, String fieldName, Object value)[source]

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

Overrides:

appendDetail in class RecursiveToStringStyle

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended.

  • value – The value to add to the toString, not null.

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

Appends to the toString the detail of an Object array.

Overrides:

appendDetail in class ToStringStyle

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended.

  • array – The array to add to the toString, not null.

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

Appends to the toString the detail of a long array.

Overrides:

appendDetail in class ToStringStyle

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended.

  • array – The array to add to the toString, not null.

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

Appends to the toString the detail of a short array.

Overrides:

appendDetail in class ToStringStyle

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended.

  • array – The array to add to the toString, not null.

protected void reflectionAppendArrayDetail(StringBuffer buffer, String fieldName, Object array)[source]

Appends to the toString the detail of an array type.

Overrides:

reflectionAppendArrayDetail in class ToStringStyle

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended.

  • array – The array to add to the toString, not null.