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:
java.io.Serializable
public class MultilineRecursiveToStringStyle extends RecursiveToStringStyle
Works with
ToStringBuilder
to create a "deep"toString
. But instead a single line like theRecursiveToStringStyle
this creates a multiline String similar to theToStringStyle.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[
name=Stephen,
age=29,
smoker=false,
job=Job@43cd2[
title=Manager
]
]- Since:
- 3.4
- See Also:
- Serialized Form
-
-
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
Constructors Constructor Description MultilineRecursiveToStringStyle()
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, boolean[] array)
Append to thetoString
the detail of aboolean
array.protected void
appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, byte[] array)
Append to thetoString
the detail of abyte
array.protected void
appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, char[] array)
Append to thetoString
the detail of achar
array.protected void
appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, double[] array)
Append to thetoString
the detail of adouble
array.protected void
appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, float[] array)
Append to thetoString
the detail of afloat
array.protected void
appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, int[] array)
Append to thetoString
the detail of anint
array.protected void
appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, long[] array)
Append to thetoString
the detail of along
array.protected void
appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, short[] array)
Append to thetoString
the detail of ashort
array.void
appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, java.lang.Object value)
Append to thetoString
anObject
value, printing the full detail of theObject
.protected void
appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, java.lang.Object[] array)
Append to thetoString
the detail of anObject
array.protected void
reflectionAppendArrayDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, java.lang.Object array)
Append 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, 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
-
-
-
-
Method Detail
-
appendDetail
public void appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, java.lang.Object value)
Description copied from class:ToStringStyle
Append to the
toString
anObject
value, printing the full detail of theObject
.- 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
protected void appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, java.lang.Object[] array)
Description copied from class:ToStringStyle
Append to the
toString
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
-
reflectionAppendArrayDetail
protected void reflectionAppendArrayDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, java.lang.Object array)
Description copied from class:ToStringStyle
Append to the
toString
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
-
appendDetail
protected void appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, long[] array)
Description copied from class:ToStringStyle
Append to the
toString
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
protected void appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, int[] array)
Description copied from class:ToStringStyle
Append to the
toString
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
protected void appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, short[] array)
Description copied from class:ToStringStyle
Append to the
toString
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
-
appendDetail
protected void appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, byte[] array)
Description copied from class:ToStringStyle
Append to the
toString
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
protected void appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, char[] array)
Description copied from class:ToStringStyle
Append to the
toString
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
protected void appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, double[] array)
Description copied from class:ToStringStyle
Append to the
toString
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
protected void appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, float[] array)
Description copied from class:ToStringStyle
Append to the
toString
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
protected void appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, boolean[] array)
Description copied from class:ToStringStyle
Append to the
toString
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
-
-