Package org.apache.commons.lang3.builder
Class MultilineRecursiveToStringStyle
java.lang.Object
org.apache.commons.lang3.builder.ToStringStyle
org.apache.commons.lang3.builder.RecursiveToStringStyle
org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle
- All Implemented Interfaces:
Serializable
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
- See Also:
-
Field Summary
Fields inherited from class org.apache.commons.lang3.builder.ToStringStyle
DEFAULT_STYLE, JSON_STYLE, MULTI_LINE_STYLE, NO_CLASS_NAME_STYLE, NO_FIELD_NAMES_STYLE, SHORT_PREFIX_STYLE, SIMPLE_STYLE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
appendDetail
(StringBuffer buffer, String fieldName, boolean[] array) Appends to thetoString
the detail of aboolean
array.protected void
appendDetail
(StringBuffer buffer, String fieldName, byte[] array) Appends to thetoString
the detail of abyte
array.protected void
appendDetail
(StringBuffer buffer, String fieldName, char[] array) Appends to thetoString
the detail of achar
array.protected void
appendDetail
(StringBuffer buffer, String fieldName, double[] array) Appends to thetoString
the detail of adouble
array.protected void
appendDetail
(StringBuffer buffer, String fieldName, float[] array) Appends to thetoString
the detail of afloat
array.protected void
appendDetail
(StringBuffer buffer, String fieldName, int[] array) Appends to thetoString
the detail of anint
array.protected void
appendDetail
(StringBuffer buffer, String fieldName, long[] array) Appends to thetoString
the detail of along
array.protected void
appendDetail
(StringBuffer buffer, String fieldName, short[] array) Appends to thetoString
the detail of ashort
array.void
appendDetail
(StringBuffer buffer, String fieldName, Object value) protected void
appendDetail
(StringBuffer buffer, String fieldName, Object[] array) Appends to thetoString
the detail of anObject
array.protected void
reflectionAppendArrayDetail
(StringBuffer buffer, String fieldName, Object array) Appends to thetoString
the detail of an array type.Methods inherited from class org.apache.commons.lang3.builder.RecursiveToStringStyle
accept, appendDetail
Methods inherited from class org.apache.commons.lang3.builder.ToStringStyle
append, append, append, append, append, append, append, append, append, append, append, append, append, append, append, append, append, append, appendClassName, appendContentEnd, appendContentStart, appendCyclicObject, appendDetail, appendDetail, appendDetail, appendDetail, appendDetail, appendDetail, appendDetail, appendDetail, appendDetail, appendDetail, appendEnd, appendFieldEnd, appendFieldSeparator, appendFieldStart, appendIdentityHashCode, appendInternal, appendNullText, appendStart, appendSummary, appendSummary, appendSummary, appendSummary, appendSummary, appendSummary, appendSummary, appendSummary, appendSummary, appendSummary, appendSummarySize, appendSuper, appendToString, getArrayEnd, getArraySeparator, getArrayStart, getContentEnd, getContentStart, getFieldNameValueSeparator, getFieldSeparator, getNullText, getRegistry, getShortClassName, getSizeEndText, getSizeStartText, getSummaryObjectEndText, getSummaryObjectStartText, isArrayContentDetail, isDefaultFullDetail, isFieldSeparatorAtEnd, isFieldSeparatorAtStart, isFullDetail, isUseClassName, isUseFieldNames, isUseIdentityHashCode, isUseShortClassName, removeLastFieldSeparator, setArrayContentDetail, setArrayEnd, setArraySeparator, setArrayStart, setContentEnd, setContentStart, setDefaultFullDetail, setFieldNameValueSeparator, setFieldSeparator, setFieldSeparatorAtEnd, setFieldSeparatorAtStart, setNullText, setSizeEndText, setSizeStartText, setSummaryObjectEndText, setSummaryObjectStartText, setUseClassName, setUseFieldNames, setUseIdentityHashCode, setUseShortClassName
-
Constructor Details
-
MultilineRecursiveToStringStyle
public MultilineRecursiveToStringStyle()Constructs a new instance.
-
-
Method Details
-
appendDetail
Description copied from class:ToStringStyle
Appends to thetoString
the detail of aboolean
array.- Overrides:
appendDetail
in classToStringStyle
- Parameters:
buffer
- theStringBuffer
to populatefieldName
- the field name, typically not used as already appendedarray
- the array to add to thetoString
, notnull
-
appendDetail
Description copied from class:ToStringStyle
Appends to thetoString
the detail of abyte
array.- Overrides:
appendDetail
in classToStringStyle
- Parameters:
buffer
- theStringBuffer
to populatefieldName
- the field name, typically not used as already appendedarray
- the array to add to thetoString
, notnull
-
appendDetail
Description copied from class:ToStringStyle
Appends to thetoString
the detail of achar
array.- Overrides:
appendDetail
in classToStringStyle
- Parameters:
buffer
- theStringBuffer
to populatefieldName
- the field name, typically not used as already appendedarray
- the array to add to thetoString
, notnull
-
appendDetail
Description copied from class:ToStringStyle
Appends to thetoString
the detail of adouble
array.- Overrides:
appendDetail
in classToStringStyle
- Parameters:
buffer
- theStringBuffer
to populatefieldName
- the field name, typically not used as already appendedarray
- the array to add to thetoString
, notnull
-
appendDetail
Description copied from class:ToStringStyle
Appends to thetoString
the detail of afloat
array.- Overrides:
appendDetail
in classToStringStyle
- Parameters:
buffer
- theStringBuffer
to populatefieldName
- the field name, typically not used as already appendedarray
- the array to add to thetoString
, notnull
-
appendDetail
Description copied from class:ToStringStyle
Appends to thetoString
the detail of anint
array.- Overrides:
appendDetail
in classToStringStyle
- Parameters:
buffer
- theStringBuffer
to populatefieldName
- the field name, typically not used as already appendedarray
- the array to add to thetoString
, notnull
-
appendDetail
Description copied from class:ToStringStyle
Appends to thetoString
the detail of along
array.- Overrides:
appendDetail
in classToStringStyle
- Parameters:
buffer
- theStringBuffer
to populatefieldName
- the field name, typically not used as already appendedarray
- the array to add to thetoString
, notnull
-
appendDetail
Description copied from class:ToStringStyle
- Overrides:
appendDetail
in classRecursiveToStringStyle
- Parameters:
buffer
- theStringBuffer
to populatefieldName
- the field name, typically not used as already appendedvalue
- the value to add to thetoString
, notnull
-
appendDetail
Description copied from class:ToStringStyle
Appends to thetoString
the detail of anObject
array.- Overrides:
appendDetail
in classToStringStyle
- Parameters:
buffer
- theStringBuffer
to populatefieldName
- the field name, typically not used as already appendedarray
- the array to add to thetoString
, notnull
-
appendDetail
Description copied from class:ToStringStyle
Appends to thetoString
the detail of ashort
array.- Overrides:
appendDetail
in classToStringStyle
- Parameters:
buffer
- theStringBuffer
to populatefieldName
- the field name, typically not used as already appendedarray
- the array to add to thetoString
, notnull
-
reflectionAppendArrayDetail
Description copied from class:ToStringStyle
Appends to thetoString
the detail of an array type.- Overrides:
reflectionAppendArrayDetail
in classToStringStyle
- Parameters:
buffer
- theStringBuffer
to populatefieldName
- the field name, typically not used as already appendedarray
- the array to add to thetoString
, notnull
-