public class RecursiveToStringStyle extends ToStringStyle
ToStringBuilder创建一个"deep" toString
public class Job {
String title;
...
}
public class Person {
String name;
int age;
boolean smoker;
Job job;
...
public String toString() {
return new ReflectionToStringBuilder(this, new RecursiveToStringStyle()).toString();
}
}
DEFAULT_STYLE, JSON_STYLE, MULTI_LINE_STYLE, NO_CLASS_NAME_STYLE, NO_FIELD_NAMES_STYLE, SHORT_PREFIX_STYLE, SIMPLE_STYLE| Constructor and Description |
|---|
RecursiveToStringStyle() |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
accept(Class<?> clazz)
返回是否递归格式化给定的Class。默认情况下,这个方法总是返回
true,
但是可能会被子类覆盖以过滤特定的类. |
protected void |
appendDetail(StringBuffer buffer,
String fieldName,
Collection<?> coll)
Append to the
toString a Collection. |
void |
appendDetail(StringBuffer buffer,
String fieldName,
Object value)
Append to the
toString an Object
value, printing the full detail of the Object. |
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, 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, reflectionAppendArrayDetail, removeLastFieldSeparator, setArrayContentDetail, setArrayEnd, setArraySeparator, setArrayStart, setContentEnd, setContentStart, setDefaultFullDetail, setFieldNameValueSeparator, setFieldSeparator, setFieldSeparatorAtEnd, setFieldSeparatorAtStart, setNullText, setSizeEndText, setSizeStartText, setSummaryObjectEndText, setSummaryObjectStartText, setUseClassName, setUseFieldNames, setUseIdentityHashCode, setUseShortClassNamepublic void appendDetail(StringBuffer buffer, String fieldName, Object value)
ToStringStyleAppend to the toString an Object
value, printing the full detail of the Object.
appendDetail in class ToStringStylebuffer - the StringBuffer to populatefieldName - the field name, typically not used as already appendedvalue - the value to add to the toString,
not nullprotected void appendDetail(StringBuffer buffer, String fieldName, Collection<?> coll)
ToStringStyleAppend to the toString a Collection.
appendDetail in class ToStringStylebuffer - the StringBuffer to populatefieldName - the field name, typically not used as already appendedcoll - the Collection to add to the
toString, not nullprotected boolean accept(Class<?> clazz)
true,
但是可能会被子类覆盖以过滤特定的类.clazz - 要测试的类.Class.Copyright © 2020. All rights reserved.