Class MultilineRecursiveToStringStyle

All Implemented Interfaces:
Serializable

public class MultilineRecursiveToStringStyle extends RecursiveToStringStyle
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
See Also:
  • Constructor Details

    • MultilineRecursiveToStringStyle

      public MultilineRecursiveToStringStyle()
      Constructs a new instance.
  • Method Details

    • appendDetail

      protected void appendDetail(StringBuffer buffer, String fieldName, boolean[] array)
      Description copied from class: ToStringStyle
      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
    • appendDetail

      protected void appendDetail(StringBuffer buffer, String fieldName, byte[] array)
      Description copied from class: ToStringStyle
      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
    • appendDetail

      protected void appendDetail(StringBuffer buffer, String fieldName, char[] array)
      Description copied from class: ToStringStyle
      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
    • appendDetail

      protected void appendDetail(StringBuffer buffer, String fieldName, double[] array)
      Description copied from class: ToStringStyle
      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
    • appendDetail

      protected void appendDetail(StringBuffer buffer, String fieldName, float[] array)
      Description copied from class: ToStringStyle
      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
    • appendDetail

      protected void appendDetail(StringBuffer buffer, String fieldName, int[] array)
      Description copied from class: ToStringStyle
      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
    • appendDetail

      protected void appendDetail(StringBuffer buffer, String fieldName, long[] array)
      Description copied from class: ToStringStyle
      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
    • appendDetail

      public void appendDetail(StringBuffer buffer, String fieldName, Object value)
      Description copied from class: ToStringStyle
      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
    • appendDetail

      protected void appendDetail(StringBuffer buffer, String fieldName, Object[] array)
      Description copied from class: ToStringStyle
      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
    • appendDetail

      protected void appendDetail(StringBuffer buffer, String fieldName, short[] array)
      Description copied from class: ToStringStyle
      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
    • reflectionAppendArrayDetail

      protected void reflectionAppendArrayDetail(StringBuffer buffer, String fieldName, Object array)
      Description copied from class: ToStringStyle
      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