Package org.springframework.core.style
Class ToStringCreator
- java.lang.Object
- org.springframework.core.style.ToStringCreator
public class ToStringCreator extends Object
Utility class that builds pretty-printingtoString()
methods with pluggable styling conventions. By default, ToStringCreator adheres to Spring'stoString()
styling conventions.- Since:
- 1.2.2
- Author:
- Keith Donald, Juergen Hoeller
Constructor Summary
Constructors Constructor Description ToStringCreator(Object obj)
Create a ToStringCreator for the given object.ToStringCreator(Object obj, ToStringStyler styler)
Create a ToStringCreator for the given object, using the provided style.ToStringCreator(Object obj, ValueStyler styler)
Create a ToStringCreator for the given object, using the provided style.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ToStringCreator
append(Object value)
Append the provided value.ToStringCreator
append(String fieldName, boolean value)
Append a boolean field value.ToStringCreator
append(String fieldName, byte value)
Append a byte field value.ToStringCreator
append(String fieldName, double value)
Append a double field value.ToStringCreator
append(String fieldName, float value)
Append a float field value.ToStringCreator
append(String fieldName, int value)
Append a integer field value.ToStringCreator
append(String fieldName, long value)
Append a long field value.ToStringCreator
append(String fieldName, short value)
Append a short field value.ToStringCreator
append(String fieldName, Object value)
Append a field value.String
toString()
Return the String representation that this ToStringCreator built.
Constructor Detail
ToStringCreator
public ToStringCreator(Object obj)
Create a ToStringCreator for the given object.- Parameters:
obj
- the object to be stringified
ToStringCreator
public ToStringCreator(Object obj, ValueStyler styler)
Create a ToStringCreator for the given object, using the provided style.- Parameters:
obj
- the object to be stringifiedstyler
- the ValueStyler encapsulating pretty-print instructions
ToStringCreator
public ToStringCreator(Object obj, ToStringStyler styler)
Create a ToStringCreator for the given object, using the provided style.- Parameters:
obj
- the object to be stringifiedstyler
- the ToStringStyler encapsulating pretty-print instructions
Method Detail
append
public ToStringCreator append(String fieldName, byte value)
Append a byte field value.- Parameters:
fieldName
- the name of the field, usually the member variable namevalue
- the field value- Returns:
- this, to support call-chaining
append
public ToStringCreator append(String fieldName, short value)
Append a short field value.- Parameters:
fieldName
- the name of the field, usually the member variable namevalue
- the field value- Returns:
- this, to support call-chaining
append
public ToStringCreator append(String fieldName, int value)
Append a integer field value.- Parameters:
fieldName
- the name of the field, usually the member variable namevalue
- the field value- Returns:
- this, to support call-chaining
append
public ToStringCreator append(String fieldName, long value)
Append a long field value.- Parameters:
fieldName
- the name of the field, usually the member variable namevalue
- the field value- Returns:
- this, to support call-chaining
append
public ToStringCreator append(String fieldName, float value)
Append a float field value.- Parameters:
fieldName
- the name of the field, usually the member variable namevalue
- the field value- Returns:
- this, to support call-chaining
append
public ToStringCreator append(String fieldName, double value)
Append a double field value.- Parameters:
fieldName
- the name of the field, usually the member variable namevalue
- the field value- Returns:
- this, to support call-chaining
append
public ToStringCreator append(String fieldName, boolean value)
Append a boolean field value.- Parameters:
fieldName
- the name of the field, usually the member variable namevalue
- the field value- Returns:
- this, to support call-chaining
append
public ToStringCreator append(String fieldName, Object value)
Append a field value.- Parameters:
fieldName
- the name of the field, usually the member variable namevalue
- the field value- Returns:
- this, to support call-chaining
append
public ToStringCreator append(Object value)
Append the provided value.- Parameters:
value
- The value to append- Returns:
- this, to support call-chaining.