public class DefaultToStringStyler extends Object implements ToStringStyler
toString()
styler.
This class is used by ToStringCreator
to style toString()
output in a consistent manner according to Spring conventions.
Constructor and Description |
---|
DefaultToStringStyler(ValueStyler valueStyler)
Create a new DefaultToStringStyler.
|
Modifier and Type | Method and Description |
---|---|
protected ValueStyler |
getValueStyler()
Return the ValueStyler used by this ToStringStyler.
|
void |
styleEnd(StringBuilder buffer,
Object o)
Style a
toString() 'ed object after it's fields are styled. |
void |
styleField(StringBuilder buffer,
String fieldName,
Object value)
Style a field value as a string.
|
protected void |
styleFieldEnd(StringBuilder buffer,
String fieldName) |
void |
styleFieldSeparator(StringBuilder buffer)
Style the field separator.
|
protected void |
styleFieldStart(StringBuilder buffer,
String fieldName) |
void |
styleStart(StringBuilder buffer,
Object obj)
Style a
toString() 'ed object before its fields are styled. |
void |
styleValue(StringBuilder buffer,
Object value)
Style the given value.
|
public DefaultToStringStyler(ValueStyler valueStyler)
valueStyler
- the ValueStyler to useprotected final ValueStyler getValueStyler()
public void styleStart(StringBuilder buffer, Object obj)
ToStringStyler
toString()
'ed object before its fields are styled.styleStart
in interface ToStringStyler
buffer
- the buffer to print toobj
- the object to stylepublic void styleEnd(StringBuilder buffer, Object o)
ToStringStyler
toString()
'ed object after it's fields are styled.styleEnd
in interface ToStringStyler
buffer
- the buffer to print too
- the object to stylepublic void styleField(StringBuilder buffer, String fieldName, @Nullable Object value)
ToStringStyler
styleField
in interface ToStringStyler
buffer
- the buffer to print tofieldName
- the he name of the fieldvalue
- the field valueprotected void styleFieldStart(StringBuilder buffer, String fieldName)
protected void styleFieldEnd(StringBuilder buffer, String fieldName)
public void styleValue(StringBuilder buffer, @Nullable Object value)
ToStringStyler
styleValue
in interface ToStringStyler
buffer
- the buffer to print tovalue
- the field valuepublic void styleFieldSeparator(StringBuilder buffer)
ToStringStyler
styleFieldSeparator
in interface ToStringStyler
buffer
- the buffer to print to