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:
-
Nested Class Summary
Nested classes/interfaces inherited from class RecursiveToStringStyle
RecursiveToStringStyle.Builder -
Field Summary
Fields inherited from class ToStringStyle
DEFAULT_STYLE, JSON_STYLE, MULTI_LINE_STYLE, NO_CLASS_NAME_STYLE, NO_FIELD_NAMES_STYLE, SHORT_PREFIX_STYLE, SIMPLE_STYLEModifier and TypeFieldDescriptionstatic final ToStringStyleThe default toString style.static final ToStringStyleThe JSON toString style.static final ToStringStyleThe multi line toString style.static final ToStringStyleThe no class name toString style.static final ToStringStyleThe no field names toString style.static final ToStringStyleThe short prefix toString style.static final ToStringStyleThe simple toString style. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidappendDetail(StringBuffer buffer, String fieldName, boolean[] array) Appends to thetoStringthe detail of abooleanarray.protected voidappendDetail(StringBuffer buffer, String fieldName, byte[] array) Appends to thetoStringthe detail of abytearray.protected voidappendDetail(StringBuffer buffer, String fieldName, char[] array) Appends to thetoStringthe detail of achararray.protected voidappendDetail(StringBuffer buffer, String fieldName, double[] array) Appends to thetoStringthe detail of adoublearray.protected voidappendDetail(StringBuffer buffer, String fieldName, float[] array) Appends to thetoStringthe detail of afloatarray.protected voidappendDetail(StringBuffer buffer, String fieldName, int[] array) Appends to thetoStringthe detail of anintarray.protected voidappendDetail(StringBuffer buffer, String fieldName, long[] array) Appends to thetoStringthe detail of alongarray.protected voidappendDetail(StringBuffer buffer, String fieldName, short[] array) Appends to thetoStringthe detail of ashortarray.voidappendDetail(StringBuffer buffer, String fieldName, Object value) protected voidappendDetail(StringBuffer buffer, String fieldName, Object[] array) Appends to thetoStringthe detail of anObjectarray.protected voidreflectionAppendArrayDetail(StringBuffer buffer, String fieldName, Object array) Appends to thetoStringthe detail of an array type.Methods inherited from class RecursiveToStringStyle
accept, append, appendDetail, appendInternal, builderModifier and TypeMethodDescriptionprotected booleanTests whether or not to recursively format the givenClass.voidappend(StringBuffer buffer, String fieldName, Object[] array, Boolean fullDetail) Appends to thetoStringanObjectarray.protected voidappendDetail(StringBuffer buffer, String fieldName, Collection<?> coll) Appends to thetoStringaCollection.protected voidappendInternal(StringBuffer buffer, String fieldName, Object value, boolean detail) Appends to thetoStringanObject, correctly interpreting its type.builder()Creates a newRecursiveToStringStyle.BuilderforRecursiveToStringStyleinstances.Methods inherited from class ToStringStyle
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, 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, setUseShortClassNameModifier and TypeMethodDescriptionvoidappend(StringBuffer buffer, String fieldName, boolean value) Appends to thetoStringabooleanvalue.voidappend(StringBuffer buffer, String fieldName, boolean[] array, Boolean fullDetail) Appends to thetoStringabooleanarray.voidappend(StringBuffer buffer, String fieldName, byte value) Appends to thetoStringabytevalue.voidappend(StringBuffer buffer, String fieldName, byte[] array, Boolean fullDetail) Appends to thetoStringabytearray.voidappend(StringBuffer buffer, String fieldName, char value) Appends to thetoStringacharvalue.voidappend(StringBuffer buffer, String fieldName, char[] array, Boolean fullDetail) Appends to thetoStringachararray.voidappend(StringBuffer buffer, String fieldName, double value) Appends to thetoStringadoublevalue.voidappend(StringBuffer buffer, String fieldName, double[] array, Boolean fullDetail) Appends to thetoStringadoublearray.voidappend(StringBuffer buffer, String fieldName, float value) Appends to thetoStringafloatvalue.voidappend(StringBuffer buffer, String fieldName, float[] array, Boolean fullDetail) Appends to thetoStringafloatarray.voidappend(StringBuffer buffer, String fieldName, int value) Appends to thetoStringanintvalue.voidappend(StringBuffer buffer, String fieldName, int[] array, Boolean fullDetail) Appends to thetoStringanintarray.voidappend(StringBuffer buffer, String fieldName, long value) Appends to thetoStringalongvalue.voidappend(StringBuffer buffer, String fieldName, long[] array, Boolean fullDetail) Appends to thetoStringalongarray.voidappend(StringBuffer buffer, String fieldName, short value) Appends to thetoStringashortvalue.voidappend(StringBuffer buffer, String fieldName, short[] array, Boolean fullDetail) Appends to thetoStringashortarray.voidappend(StringBuffer buffer, String fieldName, Object value, Boolean fullDetail) protected voidappendClassName(StringBuffer buffer, Object object) Appends to thetoStringthe class name.protected voidappendContentEnd(StringBuffer buffer) Appends to thetoStringthe content end.protected voidappendContentStart(StringBuffer buffer) Appends to thetoStringthe content start.protected voidappendCyclicObject(StringBuffer buffer, String fieldName, Object value) Appends to thetoStringanObjectvalue that has been detected to participate in a cycle.protected voidappendDetail(StringBuffer buffer, String fieldName, boolean value) Appends to thetoStringabooleanvalue.protected voidappendDetail(StringBuffer buffer, String fieldName, byte value) Appends to thetoStringabytevalue.protected voidappendDetail(StringBuffer buffer, String fieldName, char value) Appends to thetoStringacharvalue.protected voidappendDetail(StringBuffer buffer, String fieldName, double value) Appends to thetoStringadoublevalue.protected voidappendDetail(StringBuffer buffer, String fieldName, float value) Appends to thetoStringafloatvalue.protected voidappendDetail(StringBuffer buffer, String fieldName, int value) Appends to thetoStringanintvalue.protected voidappendDetail(StringBuffer buffer, String fieldName, int i, Object item) Appends to thetoStringthe detail of anObjectarray item.protected voidappendDetail(StringBuffer buffer, String fieldName, long value) Appends to thetoStringalongvalue.protected voidappendDetail(StringBuffer buffer, String fieldName, short value) Appends to thetoStringashortvalue.protected voidappendDetail(StringBuffer buffer, String fieldName, Map<?, ?> map) Appends to thetoStringaMap.voidappendEnd(StringBuffer buffer, Object object) Appends to thetoStringthe end of data indicator.protected voidappendFieldEnd(StringBuffer buffer, String fieldName) Appends to thetoStringthe field end.protected voidappendFieldSeparator(StringBuffer buffer) Appends to thetoStringthe field separator.protected voidappendFieldStart(StringBuffer buffer, String fieldName) Appends to thetoStringthe field start.protected voidappendIdentityHashCode(StringBuffer buffer, Object object) Appends theSystem.identityHashCode(java.lang.Object).protected voidappendNullText(StringBuffer buffer, String fieldName) Appends to thetoStringan indicator fornull.voidappendStart(StringBuffer buffer, Object object) Appends to thetoStringthe start of data indicator.protected voidappendSummary(StringBuffer buffer, String fieldName, boolean[] array) Appends to thetoStringa summary of abooleanarray.protected voidappendSummary(StringBuffer buffer, String fieldName, byte[] array) Appends to thetoStringa summary of abytearray.protected voidappendSummary(StringBuffer buffer, String fieldName, char[] array) Appends to thetoStringa summary of achararray.protected voidappendSummary(StringBuffer buffer, String fieldName, double[] array) Appends to thetoStringa summary of adoublearray.protected voidappendSummary(StringBuffer buffer, String fieldName, float[] array) Appends to thetoStringa summary of afloatarray.protected voidappendSummary(StringBuffer buffer, String fieldName, int[] array) Appends to thetoStringa summary of anintarray.protected voidappendSummary(StringBuffer buffer, String fieldName, long[] array) Appends to thetoStringa summary of alongarray.protected voidappendSummary(StringBuffer buffer, String fieldName, short[] array) Appends to thetoStringa summary of ashortarray.protected voidappendSummary(StringBuffer buffer, String fieldName, Object value) protected voidappendSummary(StringBuffer buffer, String fieldName, Object[] array) Appends to thetoStringa summary of anObjectarray.protected voidappendSummarySize(StringBuffer buffer, String fieldName, int size) Appends to thetoStringa size summary.voidappendSuper(StringBuffer buffer, String superToString) Appends to thetoStringthe superclass toString.voidappendToString(StringBuffer buffer, String toString) Appends to thetoStringanother toString.protected StringGets the array end text.protected StringGets the array separator text.protected StringGets the array start text.protected StringGets the content end text.protected StringGets the content start text.protected StringGets the field name value separator text.protected StringGets the field separator text.protected StringGets the text to output whennullfound.Gets the registry of objects being traversed by thereflectionToStringmethods in the current thread.protected StringgetShortClassName(Class<?> cls) Gets the short class name for a class.protected StringGets the end text to output when aCollection,Mapor array size is output.protected StringGets the start text to output when aCollection,Mapor array size is output.protected StringGets the end text to output when anObjectis output in summary mode.protected StringGets the start text to output when anObjectis output in summary mode.protected booleanTests whether to output array content detail.protected booleanTests whether full detail is used when the caller does not specify a detail level.protected booleanTests whether the field separator should be added at the end of each buffer.protected booleanTests whether the field separator should be added at the start of each buffer.protected booleanisFullDetail(Boolean fullDetailRequest) Tests whether this field should be output in full detail.protected booleanTests whether to use the class name.protected booleanTests whether to use the field names passed in.protected booleanTests whether to use the identity hash code.protected booleanTests whether short class names should be output.protected voidremoveLastFieldSeparator(StringBuffer buffer) Remove the last field separator from the buffer.protected voidsetArrayContentDetail(boolean arrayContentDetail) Sets whether to output array content detail.protected voidsetArrayEnd(String arrayEnd) Sets the array end text.protected voidsetArraySeparator(String arraySeparator) Sets the array separator text.protected voidsetArrayStart(String arrayStart) Sets the array start text.protected voidsetContentEnd(String contentEnd) Sets the content end text.protected voidsetContentStart(String contentStart) Sets the content start text.protected voidsetDefaultFullDetail(boolean defaultFullDetail) Sets whether to use full detail when the caller doesn't specify.protected voidsetFieldNameValueSeparator(String fieldNameValueSeparator) Sets the field name value separator text.protected voidsetFieldSeparator(String fieldSeparator) Sets the field separator text.protected voidsetFieldSeparatorAtEnd(boolean fieldSeparatorAtEnd) Sets whether the field separator should be added at the end of each buffer.protected voidsetFieldSeparatorAtStart(boolean fieldSeparatorAtStart) Sets whether the field separator should be added at the start of each buffer.protected voidsetNullText(String nullText) Sets the text to output whennullfound.protected voidsetSizeEndText(String sizeEndText) Sets the end text to output when aCollection,Mapor array size is output.protected voidsetSizeStartText(String sizeStartText) Sets the start text to output when aCollection,Mapor array size is output.protected voidsetSummaryObjectEndText(String summaryObjectEndText) Sets the end text to output when anObjectis output in summary mode.protected voidsetSummaryObjectStartText(String summaryObjectStartText) Sets the start text to output when anObjectis output in summary mode.protected voidsetUseClassName(boolean useClassName) Sets whether to use the class name.protected voidsetUseFieldNames(boolean useFieldNames) Sets whether to use the field names passed in.protected voidsetUseIdentityHashCode(boolean useIdentityHashCode) Sets whether to use the identity hash code.protected voidsetUseShortClassName(boolean useShortClassName) Sets whether to output short or long class names.
-
Constructor Details
-
MultilineRecursiveToStringStyle
public MultilineRecursiveToStringStyle()Constructs a new instance.
-
-
Method Details
-
appendDetail
Description copied from class:ToStringStyleAppends to thetoStringthe detail of abooleanarray.- Overrides:
appendDetailin classToStringStyle- Parameters:
buffer- TheStringBufferto populate.fieldName- The field name, typically not used as already appended.array- The array to add to thetoString, notnull.
-
appendDetail
Description copied from class:ToStringStyleAppends to thetoStringthe detail of abytearray.- Overrides:
appendDetailin classToStringStyle- Parameters:
buffer- TheStringBufferto populate.fieldName- The field name, typically not used as already appended.array- The array to add to thetoString, notnull.
-
appendDetail
Description copied from class:ToStringStyleAppends to thetoStringthe detail of achararray.- Overrides:
appendDetailin classToStringStyle- Parameters:
buffer- TheStringBufferto populate.fieldName- The field name, typically not used as already appended.array- The array to add to thetoString, notnull.
-
appendDetail
Description copied from class:ToStringStyleAppends to thetoStringthe detail of adoublearray.- Overrides:
appendDetailin classToStringStyle- Parameters:
buffer- TheStringBufferto populate.fieldName- The field name, typically not used as already appendedarray- The array to add to thetoString, notnull.
-
appendDetail
Description copied from class:ToStringStyleAppends to thetoStringthe detail of afloatarray.- Overrides:
appendDetailin classToStringStyle- Parameters:
buffer- TheStringBufferto populate.fieldName- The field name, typically not used as already appended.array- The array to add to thetoString, notnull.
-
appendDetail
Description copied from class:ToStringStyleAppends to thetoStringthe detail of anintarray.- Overrides:
appendDetailin classToStringStyle- Parameters:
buffer- TheStringBufferto populate.fieldName- The field name, typically not used as already appended.array- The array to add to thetoString, notnull.
-
appendDetail
Description copied from class:ToStringStyleAppends to thetoStringthe detail of alongarray.- Overrides:
appendDetailin classToStringStyle- Parameters:
buffer- TheStringBufferto populate.fieldName- The field name, typically not used as already appended.array- The array to add to thetoString, notnull.
-
appendDetail
Description copied from class:ToStringStyle- Overrides:
appendDetailin classRecursiveToStringStyle- Parameters:
buffer- TheStringBufferto populate.fieldName- The field name, typically not used as already appended.value- The value to add to thetoString, notnull.
-
appendDetail
Description copied from class:ToStringStyleAppends to thetoStringthe detail of anObjectarray.- Overrides:
appendDetailin classToStringStyle- Parameters:
buffer- TheStringBufferto populate.fieldName- The field name, typically not used as already appended.array- The array to add to thetoString, notnull.
-
appendDetail
Description copied from class:ToStringStyleAppends to thetoStringthe detail of ashortarray.- Overrides:
appendDetailin classToStringStyle- Parameters:
buffer- TheStringBufferto populate.fieldName- The field name, typically not used as already appended.array- The array to add to thetoString, notnull.
-
reflectionAppendArrayDetail
Description copied from class:ToStringStyleAppends to thetoStringthe detail of an array type.- Overrides:
reflectionAppendArrayDetailin classToStringStyle- Parameters:
buffer- TheStringBufferto populate.fieldName- The field name, typically not used as already appended.array- The array to add to thetoString, notnull.
-