Class ToStringBuilder

  • Direct Known Subclasses:
    ReflectionToStringBuilder

    @Deprecated(since="2021-04-30")
    public class ToStringBuilder
    extends java.lang.Object
    Deprecated.
    Commons Lang 2 is in maintenance mode. Commons Lang 3 should be used instead.

    Assists in implementing Object.toString() methods.

    This class enables a good and consistent toString() to be built for any class or object. This class aims to simplify the process by:

    • allowing field names
    • handling all types consistently
    • handling nulls consistently
    • outputting arrays and multi-dimensional arrays
    • enabling the detail level to be controlled for Objects and Collections
    • handling class hierarchies

    To use this class write code as follows:

      public class Person {
        String name;
        int age;
        boolean smoker;
    
        ...
    
        public String toString() {
          return new ToStringBuilder(this).
            append("name", name).
            append("age", age).
            append("smoker", smoker).
            toString();
        }
      }
      

    This will produce a toString of the format: Person@7f54[name=Stephen,age=29,smoker=false]

    To add the superclass toString, use appendSuper(java.lang.String). To append the toString from an object that is delegated to (or any other object), use appendToString(java.lang.String).

    Alternatively, there is a method that uses reflection to determine the fields to test. Because these fields are usually private, the method, reflectionToString, uses AccessibleObject.setAccessible to change the visibility of the fields. This will fail under a security manager, unless the appropriate permissions are set up correctly. It is also slower than testing explicitly.

    A typical invocation for this method would look like:

      public String toString() {
        return ToStringBuilder.reflectionToString(this);
      }
      

    You can also use the builder to debug 3rd party objects:

      System.out.println("An object: " + ToStringBuilder.reflectionToString(anObject));
      

    The exact format of the toString is determined by the ToStringStyle passed into the constructor.

    Since:
    1.0
    • Constructor Summary

      Constructors 
      Constructor Description
      ToStringBuilder​(java.lang.Object object)
      Deprecated.
      Constructs a builder for the specified object using the default output style.
      ToStringBuilder​(java.lang.Object object, ToStringStyle style)
      Deprecated.
      Constructs a builder for the specified object using the a defined output style.
      ToStringBuilder​(java.lang.Object object, ToStringStyle style, java.lang.StringBuffer buffer)
      Deprecated.
      Constructs a builder for the specified object.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      ToStringBuilder append​(boolean value)
      Deprecated.
      Append to the toString a boolean value.
      ToStringBuilder append​(boolean[] array)
      Deprecated.
      Append to the toString a boolean array.
      ToStringBuilder append​(byte value)
      Deprecated.
      Append to the toString a byte value.
      ToStringBuilder append​(byte[] array)
      Deprecated.
      Append to the toString a byte array.
      ToStringBuilder append​(char value)
      Deprecated.
      Append to the toString a char value.
      ToStringBuilder append​(char[] array)
      Deprecated.
      Append to the toString a char array.
      ToStringBuilder append​(double value)
      Deprecated.
      Append to the toString a double value.
      ToStringBuilder append​(double[] array)
      Deprecated.
      Append to the toString a double array.
      ToStringBuilder append​(float value)
      Deprecated.
      Append to the toString a float value.
      ToStringBuilder append​(float[] array)
      Deprecated.
      Append to the toString a float array.
      ToStringBuilder append​(int value)
      Deprecated.
      Append to the toString an int value.
      ToStringBuilder append​(int[] array)
      Deprecated.
      Append to the toString an int array.
      ToStringBuilder append​(long value)
      Deprecated.
      Append to the toString a long value.
      ToStringBuilder append​(long[] array)
      Deprecated.
      Append to the toString a long array.
      ToStringBuilder append​(short value)
      Deprecated.
      Append to the toString a short value.
      ToStringBuilder append​(short[] array)
      Deprecated.
      Append to the toString a short array.
      ToStringBuilder append​(java.lang.Object obj)
      Deprecated.
      Append to the toString an Object value.
      ToStringBuilder append​(java.lang.Object[] array)
      Deprecated.
      Append to the toString an Object array.
      ToStringBuilder append​(java.lang.String fieldName, boolean value)
      Deprecated.
      Append to the toString a boolean value.
      ToStringBuilder append​(java.lang.String fieldName, boolean[] array)
      Deprecated.
      Append to the toString a boolean array.
      ToStringBuilder append​(java.lang.String fieldName, boolean[] array, boolean fullDetail)
      Deprecated.
      Append to the toString a boolean array.
      ToStringBuilder append​(java.lang.String fieldName, byte value)
      Deprecated.
      Append to the toString an byte value.
      ToStringBuilder append​(java.lang.String fieldName, byte[] array)
      Deprecated.
      Append to the toString a byte array.
      ToStringBuilder append​(java.lang.String fieldName, byte[] array, boolean fullDetail)
      Deprecated.
      Append to the toString a byte array.
      ToStringBuilder append​(java.lang.String fieldName, char value)
      Deprecated.
      Append to the toString a char value.
      ToStringBuilder append​(java.lang.String fieldName, char[] array)
      Deprecated.
      Append to the toString a char array.
      ToStringBuilder append​(java.lang.String fieldName, char[] array, boolean fullDetail)
      Deprecated.
      Append to the toString a char array.
      ToStringBuilder append​(java.lang.String fieldName, double value)
      Deprecated.
      Append to the toString a double value.
      ToStringBuilder append​(java.lang.String fieldName, double[] array)
      Deprecated.
      Append to the toString a double array.
      ToStringBuilder append​(java.lang.String fieldName, double[] array, boolean fullDetail)
      Deprecated.
      Append to the toString a double array.
      ToStringBuilder append​(java.lang.String fieldName, float value)
      Deprecated.
      Append to the toString an float value.
      ToStringBuilder append​(java.lang.String fieldName, float[] array)
      Deprecated.
      Append to the toString a float array.
      ToStringBuilder append​(java.lang.String fieldName, float[] array, boolean fullDetail)
      Deprecated.
      Append to the toString a float array.
      ToStringBuilder append​(java.lang.String fieldName, int value)
      Deprecated.
      Append to the toString an int value.
      ToStringBuilder append​(java.lang.String fieldName, int[] array)
      Deprecated.
      Append to the toString an int array.
      ToStringBuilder append​(java.lang.String fieldName, int[] array, boolean fullDetail)
      Deprecated.
      Append to the toString an int array.
      ToStringBuilder append​(java.lang.String fieldName, long value)
      Deprecated.
      Append to the toString a long value.
      ToStringBuilder append​(java.lang.String fieldName, long[] array)
      Deprecated.
      Append to the toString a long array.
      ToStringBuilder append​(java.lang.String fieldName, long[] array, boolean fullDetail)
      Deprecated.
      Append to the toString a long array.
      ToStringBuilder append​(java.lang.String fieldName, short value)
      Deprecated.
      Append to the toString an short value.
      ToStringBuilder append​(java.lang.String fieldName, short[] array)
      Deprecated.
      Append to the toString a short array.
      ToStringBuilder append​(java.lang.String fieldName, short[] array, boolean fullDetail)
      Deprecated.
      Append to the toString a short array.
      ToStringBuilder append​(java.lang.String fieldName, java.lang.Object obj)
      Deprecated.
      Append to the toString an Object value.
      ToStringBuilder append​(java.lang.String fieldName, java.lang.Object[] array)
      Deprecated.
      Append to the toString an Object array.
      ToStringBuilder append​(java.lang.String fieldName, java.lang.Object[] array, boolean fullDetail)
      Deprecated.
      Append to the toString an Object array.
      ToStringBuilder append​(java.lang.String fieldName, java.lang.Object obj, boolean fullDetail)
      Deprecated.
      Append to the toString an Object value.
      ToStringBuilder appendAsObjectToString​(java.lang.Object object)
      Deprecated.
      Appends with the same format as the default Object toString() method.
      ToStringBuilder appendSuper​(java.lang.String superToString)
      Deprecated.
      Append the toString from the superclass.
      ToStringBuilder appendToString​(java.lang.String toString)
      Deprecated.
      Append the toString from another object.
      static ToStringStyle getDefaultStyle()
      Deprecated.
      Gets the default ToStringStyle to use.
      java.lang.Object getObject()
      Deprecated.
      Returns the Object being output.
      java.lang.StringBuffer getStringBuffer()
      Deprecated.
      Gets the StringBuffer being populated.
      ToStringStyle getStyle()
      Deprecated.
      Gets the ToStringStyle being used.
      static java.lang.String reflectionToString​(java.lang.Object object)
      Deprecated.
      Uses ReflectionToStringBuilder to generate a toString for the specified object.
      static java.lang.String reflectionToString​(java.lang.Object object, ToStringStyle style)
      Deprecated.
      Uses ReflectionToStringBuilder to generate a toString for the specified object.
      static java.lang.String reflectionToString​(java.lang.Object object, ToStringStyle style, boolean outputTransients)
      Deprecated.
      Uses ReflectionToStringBuilder to generate a toString for the specified object.
      static java.lang.String reflectionToString​(java.lang.Object object, ToStringStyle style, boolean outputTransients, java.lang.Class reflectUpToClass)
      Deprecated.
      Uses ReflectionToStringBuilder to generate a toString for the specified object.
      static void setDefaultStyle​(ToStringStyle style)
      Deprecated.
      Sets the default ToStringStyle to use.
      java.lang.String toString()
      Deprecated.
      Returns the built toString.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • ToStringBuilder

        public ToStringBuilder​(java.lang.Object object)
        Deprecated.

        Constructs a builder for the specified object using the default output style.

        This default style is obtained from getDefaultStyle().

        Parameters:
        object - the Object to build a toString for, not recommended to be null
      • ToStringBuilder

        public ToStringBuilder​(java.lang.Object object,
                               ToStringStyle style)
        Deprecated.

        Constructs a builder for the specified object using the a defined output style.

        If the style is null, the default style is used.

        Parameters:
        object - the Object to build a toString for, not recommended to be null
        style - the style of the toString to create, null uses the default style
      • ToStringBuilder

        public ToStringBuilder​(java.lang.Object object,
                               ToStringStyle style,
                               java.lang.StringBuffer buffer)
        Deprecated.

        Constructs a builder for the specified object.

        If the style is null, the default style is used.

        If the buffer is null, a new one is created.

        Parameters:
        object - the Object to build a toString for, not recommended to be null
        style - the style of the toString to create, null uses the default style
        buffer - the StringBuffer to populate, may be null
    • Method Detail

      • getDefaultStyle

        public static ToStringStyle getDefaultStyle()
        Deprecated.

        Gets the default ToStringStyle to use.

        This method gets a singleton default value, typically for the whole JVM. Changing this default should generally only be done during application startup. It is recommended to pass a ToStringStyle to the constructor instead of using this global default.

        This method can be used from multiple threads. Internally, a volatile variable is used to provide the guarantee that the latest value set using setDefaultStyle(org.apache.commons.lang.builder.ToStringStyle) is the value returned. It is strongly recommended that the default style is only changed during application startup.

        One reason for changing the default could be to have a verbose style during development and a compact style in production.

        Returns:
        the default ToStringStyle, never null
      • setDefaultStyle

        public static void setDefaultStyle​(ToStringStyle style)
        Deprecated.

        Sets the default ToStringStyle to use.

        This method sets a singleton default value, typically for the whole JVM. Changing this default should generally only be done during application startup. It is recommended to pass a ToStringStyle to the constructor instead of changing this global default.

        This method is not intended for use from multiple threads. Internally, a volatile variable is used to provide the guarantee that the latest value set is the value returned from getDefaultStyle().

        Parameters:
        style - the default ToStringStyle
        Throws:
        java.lang.IllegalArgumentException - if the style is null
      • reflectionToString

        public static java.lang.String reflectionToString​(java.lang.Object object)
        Deprecated.

        Uses ReflectionToStringBuilder to generate a toString for the specified object.

        Parameters:
        object - the Object to be output
        Returns:
        the String result
        See Also:
        ReflectionToStringBuilder.toString(Object)
      • reflectionToString

        public static java.lang.String reflectionToString​(java.lang.Object object,
                                                          ToStringStyle style)
        Deprecated.

        Uses ReflectionToStringBuilder to generate a toString for the specified object.

        Parameters:
        object - the Object to be output
        style - the style of the toString to create, may be null
        Returns:
        the String result
        See Also:
        ReflectionToStringBuilder.toString(Object,ToStringStyle)
      • reflectionToString

        public static java.lang.String reflectionToString​(java.lang.Object object,
                                                          ToStringStyle style,
                                                          boolean outputTransients)
        Deprecated.

        Uses ReflectionToStringBuilder to generate a toString for the specified object.

        Parameters:
        object - the Object to be output
        style - the style of the toString to create, may be null
        outputTransients - whether to include transient fields
        Returns:
        the String result
        See Also:
        ReflectionToStringBuilder.toString(Object,ToStringStyle,boolean)
      • reflectionToString

        public static java.lang.String reflectionToString​(java.lang.Object object,
                                                          ToStringStyle style,
                                                          boolean outputTransients,
                                                          java.lang.Class reflectUpToClass)
        Deprecated.

        Uses ReflectionToStringBuilder to generate a toString for the specified object.

        Parameters:
        object - the Object to be output
        style - the style of the toString to create, may be null
        outputTransients - whether to include transient fields
        reflectUpToClass - the superclass to reflect up to (inclusive), may be null
        Returns:
        the String result
        Since:
        2.0
        See Also:
        ReflectionToStringBuilder.toString(Object,ToStringStyle,boolean,boolean,Class)
      • append

        public ToStringBuilder append​(boolean value)
        Deprecated.

        Append to the toString a boolean value.

        Parameters:
        value - the value to add to the toString
        Returns:
        this
      • append

        public ToStringBuilder append​(boolean[] array)
        Deprecated.

        Append to the toString a boolean array.

        Parameters:
        array - the array to add to the toString
        Returns:
        this
      • append

        public ToStringBuilder append​(byte value)
        Deprecated.

        Append to the toString a byte value.

        Parameters:
        value - the value to add to the toString
        Returns:
        this
      • append

        public ToStringBuilder append​(byte[] array)
        Deprecated.

        Append to the toString a byte array.

        Parameters:
        array - the array to add to the toString
        Returns:
        this
      • append

        public ToStringBuilder append​(char value)
        Deprecated.

        Append to the toString a char value.

        Parameters:
        value - the value to add to the toString
        Returns:
        this
      • append

        public ToStringBuilder append​(char[] array)
        Deprecated.

        Append to the toString a char array.

        Parameters:
        array - the array to add to the toString
        Returns:
        this
      • append

        public ToStringBuilder append​(double value)
        Deprecated.

        Append to the toString a double value.

        Parameters:
        value - the value to add to the toString
        Returns:
        this
      • append

        public ToStringBuilder append​(double[] array)
        Deprecated.

        Append to the toString a double array.

        Parameters:
        array - the array to add to the toString
        Returns:
        this
      • append

        public ToStringBuilder append​(float value)
        Deprecated.

        Append to the toString a float value.

        Parameters:
        value - the value to add to the toString
        Returns:
        this
      • append

        public ToStringBuilder append​(float[] array)
        Deprecated.

        Append to the toString a float array.

        Parameters:
        array - the array to add to the toString
        Returns:
        this
      • append

        public ToStringBuilder append​(int value)
        Deprecated.

        Append to the toString an int value.

        Parameters:
        value - the value to add to the toString
        Returns:
        this
      • append

        public ToStringBuilder append​(int[] array)
        Deprecated.

        Append to the toString an int array.

        Parameters:
        array - the array to add to the toString
        Returns:
        this
      • append

        public ToStringBuilder append​(long value)
        Deprecated.

        Append to the toString a long value.

        Parameters:
        value - the value to add to the toString
        Returns:
        this
      • append

        public ToStringBuilder append​(long[] array)
        Deprecated.

        Append to the toString a long array.

        Parameters:
        array - the array to add to the toString
        Returns:
        this
      • append

        public ToStringBuilder append​(java.lang.Object obj)
        Deprecated.

        Append to the toString an Object value.

        Parameters:
        obj - the value to add to the toString
        Returns:
        this
      • append

        public ToStringBuilder append​(java.lang.Object[] array)
        Deprecated.

        Append to the toString an Object array.

        Parameters:
        array - the array to add to the toString
        Returns:
        this
      • append

        public ToStringBuilder append​(short value)
        Deprecated.

        Append to the toString a short value.

        Parameters:
        value - the value to add to the toString
        Returns:
        this
      • append

        public ToStringBuilder append​(short[] array)
        Deprecated.

        Append to the toString a short array.

        Parameters:
        array - the array to add to the toString
        Returns:
        this
      • append

        public ToStringBuilder append​(java.lang.String fieldName,
                                      boolean value)
        Deprecated.

        Append to the toString a boolean value.

        Parameters:
        fieldName - the field name
        value - the value to add to the toString
        Returns:
        this
      • append

        public ToStringBuilder append​(java.lang.String fieldName,
                                      boolean[] array)
        Deprecated.

        Append to the toString a boolean array.

        Parameters:
        fieldName - the field name
        array - the array to add to the hashCode
        Returns:
        this
      • append

        public ToStringBuilder append​(java.lang.String fieldName,
                                      boolean[] array,
                                      boolean fullDetail)
        Deprecated.

        Append to the toString a boolean array.

        A boolean parameter controls the level of detail to show. Setting true will output the array in full. Setting false will output a summary, typically the size of the array.

        Parameters:
        fieldName - the field name
        array - the array to add to the toString
        fullDetail - true for detail, false for summary info
        Returns:
        this
      • append

        public ToStringBuilder append​(java.lang.String fieldName,
                                      byte value)
        Deprecated.

        Append to the toString an byte value.

        Parameters:
        fieldName - the field name
        value - the value to add to the toString
        Returns:
        this
      • append

        public ToStringBuilder append​(java.lang.String fieldName,
                                      byte[] array)
        Deprecated.

        Append to the toString a byte array.

        Parameters:
        fieldName - the field name
        array - the array to add to the toString
        Returns:
        this
      • append

        public ToStringBuilder append​(java.lang.String fieldName,
                                      byte[] array,
                                      boolean fullDetail)
        Deprecated.

        Append to the toString a byte array.

        A boolean parameter controls the level of detail to show. Setting true will output the array in full. Setting false will output a summary, typically the size of the array.

        Parameters:
        fieldName - the field name
        array - the array to add to the toString
        fullDetail - true for detail, false for summary info
        Returns:
        this
      • append

        public ToStringBuilder append​(java.lang.String fieldName,
                                      char value)
        Deprecated.

        Append to the toString a char value.

        Parameters:
        fieldName - the field name
        value - the value to add to the toString
        Returns:
        this
      • append

        public ToStringBuilder append​(java.lang.String fieldName,
                                      char[] array)
        Deprecated.

        Append to the toString a char array.

        Parameters:
        fieldName - the field name
        array - the array to add to the toString
        Returns:
        this
      • append

        public ToStringBuilder append​(java.lang.String fieldName,
                                      char[] array,
                                      boolean fullDetail)
        Deprecated.

        Append to the toString a char array.

        A boolean parameter controls the level of detail to show. Setting true will output the array in full. Setting false will output a summary, typically the size of the array.

        Parameters:
        fieldName - the field name
        array - the array to add to the toString
        fullDetail - true for detail, false for summary info
        Returns:
        this
      • append

        public ToStringBuilder append​(java.lang.String fieldName,
                                      double value)
        Deprecated.

        Append to the toString a double value.

        Parameters:
        fieldName - the field name
        value - the value to add to the toString
        Returns:
        this
      • append

        public ToStringBuilder append​(java.lang.String fieldName,
                                      double[] array)
        Deprecated.

        Append to the toString a double array.

        Parameters:
        fieldName - the field name
        array - the array to add to the toString
        Returns:
        this
      • append

        public ToStringBuilder append​(java.lang.String fieldName,
                                      double[] array,
                                      boolean fullDetail)
        Deprecated.

        Append to the toString a double array.

        A boolean parameter controls the level of detail to show. Setting true will output the array in full. Setting false will output a summary, typically the size of the array.

        Parameters:
        fieldName - the field name
        array - the array to add to the toString
        fullDetail - true for detail, false for summary info
        Returns:
        this
      • append

        public ToStringBuilder append​(java.lang.String fieldName,
                                      float value)
        Deprecated.

        Append to the toString an float value.

        Parameters:
        fieldName - the field name
        value - the value to add to the toString
        Returns:
        this
      • append

        public ToStringBuilder append​(java.lang.String fieldName,
                                      float[] array)
        Deprecated.

        Append to the toString a float array.

        Parameters:
        fieldName - the field name
        array - the array to add to the toString
        Returns:
        this
      • append

        public ToStringBuilder append​(java.lang.String fieldName,
                                      float[] array,
                                      boolean fullDetail)
        Deprecated.

        Append to the toString a float array.

        A boolean parameter controls the level of detail to show. Setting true will output the array in full. Setting false will output a summary, typically the size of the array.

        Parameters:
        fieldName - the field name
        array - the array to add to the toString
        fullDetail - true for detail, false for summary info
        Returns:
        this
      • append

        public ToStringBuilder append​(java.lang.String fieldName,
                                      int value)
        Deprecated.

        Append to the toString an int value.

        Parameters:
        fieldName - the field name
        value - the value to add to the toString
        Returns:
        this
      • append

        public ToStringBuilder append​(java.lang.String fieldName,
                                      int[] array)
        Deprecated.

        Append to the toString an int array.

        Parameters:
        fieldName - the field name
        array - the array to add to the toString
        Returns:
        this
      • append

        public ToStringBuilder append​(java.lang.String fieldName,
                                      int[] array,
                                      boolean fullDetail)
        Deprecated.

        Append to the toString an int array.

        A boolean parameter controls the level of detail to show. Setting true will output the array in full. Setting false will output a summary, typically the size of the array.

        Parameters:
        fieldName - the field name
        array - the array to add to the toString
        fullDetail - true for detail, false for summary info
        Returns:
        this
      • append

        public ToStringBuilder append​(java.lang.String fieldName,
                                      long value)
        Deprecated.

        Append to the toString a long value.

        Parameters:
        fieldName - the field name
        value - the value to add to the toString
        Returns:
        this
      • append

        public ToStringBuilder append​(java.lang.String fieldName,
                                      long[] array)
        Deprecated.

        Append to the toString a long array.

        Parameters:
        fieldName - the field name
        array - the array to add to the toString
        Returns:
        this
      • append

        public ToStringBuilder append​(java.lang.String fieldName,
                                      long[] array,
                                      boolean fullDetail)
        Deprecated.

        Append to the toString a long array.

        A boolean parameter controls the level of detail to show. Setting true will output the array in full. Setting false will output a summary, typically the size of the array.

        Parameters:
        fieldName - the field name
        array - the array to add to the toString
        fullDetail - true for detail, false for summary info
        Returns:
        this
      • append

        public ToStringBuilder append​(java.lang.String fieldName,
                                      java.lang.Object obj)
        Deprecated.

        Append to the toString an Object value.

        Parameters:
        fieldName - the field name
        obj - the value to add to the toString
        Returns:
        this
      • append

        public ToStringBuilder append​(java.lang.String fieldName,
                                      java.lang.Object obj,
                                      boolean fullDetail)
        Deprecated.

        Append to the toString an Object value.

        Parameters:
        fieldName - the field name
        obj - the value to add to the toString
        fullDetail - true for detail, false for summary info
        Returns:
        this
      • append

        public ToStringBuilder append​(java.lang.String fieldName,
                                      java.lang.Object[] array)
        Deprecated.

        Append to the toString an Object array.

        Parameters:
        fieldName - the field name
        array - the array to add to the toString
        Returns:
        this
      • append

        public ToStringBuilder append​(java.lang.String fieldName,
                                      java.lang.Object[] array,
                                      boolean fullDetail)
        Deprecated.

        Append to the toString an Object array.

        A boolean parameter controls the level of detail to show. Setting true will output the array in full. Setting false will output a summary, typically the size of the array.

        Parameters:
        fieldName - the field name
        array - the array to add to the toString
        fullDetail - true for detail, false for summary info
        Returns:
        this
      • append

        public ToStringBuilder append​(java.lang.String fieldName,
                                      short value)
        Deprecated.

        Append to the toString an short value.

        Parameters:
        fieldName - the field name
        value - the value to add to the toString
        Returns:
        this
      • append

        public ToStringBuilder append​(java.lang.String fieldName,
                                      short[] array)
        Deprecated.

        Append to the toString a short array.

        Parameters:
        fieldName - the field name
        array - the array to add to the toString
        Returns:
        this
      • append

        public ToStringBuilder append​(java.lang.String fieldName,
                                      short[] array,
                                      boolean fullDetail)
        Deprecated.

        Append to the toString a short array.

        A boolean parameter controls the level of detail to show. Setting true will output the array in full. Setting false will output a summary, typically the size of the array.

        Parameters:
        fieldName - the field name
        array - the array to add to the toString
        fullDetail - true for detail, false for summary info
        Returns:
        this
      • appendAsObjectToString

        public ToStringBuilder appendAsObjectToString​(java.lang.Object object)
        Deprecated.

        Appends with the same format as the default Object toString() method. Appends the class name followed by System.identityHashCode(java.lang.Object).

        Parameters:
        object - the Object whose class name and id to output
        Returns:
        this
        Since:
        2.0
      • appendSuper

        public ToStringBuilder appendSuper​(java.lang.String superToString)
        Deprecated.

        Append the toString from the superclass.

        This method assumes that the superclass uses the same ToStringStyle as this one.

        If superToString is null, no change is made.

        Parameters:
        superToString - the result of super.toString()
        Returns:
        this
        Since:
        2.0
      • appendToString

        public ToStringBuilder appendToString​(java.lang.String toString)
        Deprecated.

        Append the toString from another object.

        This method is useful where a class delegates most of the implementation of its properties to another class. You can then call toString() on the other class and pass the result into this method.

           private AnotherObject delegate;
           private String fieldInThisClass;
        
           public String toString() {
             return new ToStringBuilder(this).
               appendToString(delegate.toString()).
               append(fieldInThisClass).
               toString();
           }

        This method assumes that the other object uses the same ToStringStyle as this one.

        If the toString is null, no change is made.

        Parameters:
        toString - the result of toString() on another object
        Returns:
        this
        Since:
        2.0
      • getObject

        public java.lang.Object getObject()
        Deprecated.

        Returns the Object being output.

        Returns:
        The object being output.
        Since:
        2.0
      • getStringBuffer

        public java.lang.StringBuffer getStringBuffer()
        Deprecated.

        Gets the StringBuffer being populated.

        Returns:
        the StringBuffer being populated
      • getStyle

        public ToStringStyle getStyle()
        Deprecated.

        Gets the ToStringStyle being used.

        Returns:
        the ToStringStyle being used
        Since:
        2.0
      • toString

        public java.lang.String toString()
        Deprecated.

        Returns the built toString.

        This method appends the end of data indicator, and can only be called once. Use getStringBuffer() to get the current string state.

        If the object is null, return the style's nullText

        Overrides:
        toString in class java.lang.Object
        Returns:
        the String toString