Package org.springframework.core.style

# Class DefaultValueStyler

java.lang.Object
org.springframework.core.style.DefaultValueStyler

All Implemented Interfaces:
  `ValueStyler`

Direct Known Subclasses:
  `SimpleValueStyler`

public class DefaultValueStyler extends Object implements ValueStyler
Converts objects to String form, generally for debugging purposes, using Spring's `toString` styling conventions.

Uses the reflective visitor pattern underneath the hood to nicely encapsulate styling algorithms for each type of styled object.

Since:
  1.2.2
Author:
  Keith Donald, Juergen Hoeller, Sam Brannen

## Constructor Summary

Constructors
Constructor
Description
`DefaultValueStyler()`

## Method Summary

Modifier and Type
Method
Description
`String`
`style(Object value)`
Style the given value, returning a String representation.
`protected String`
`styleArray(Object[] array)`
Generate a styled version of the supplied array.
`protected String`
`styleClass(Class<?> clazz)`
Generate a styled version of the supplied `Class`.
`protected String`
`styleCollection(Collection<?> collection)`
Generate a styled version of the supplied `Collection`.
`protected <K, V> String`
`styleMap(Map<K,V> map)`
Generate a styled version of the supplied `Map`.
`protected String`
`styleMapEntry(Map.Entry<?,?> entry)`
Generate a styled version of the supplied `Map.Entry`.
`protected String`
`styleMethod(Method method)`
Generate a styled version of the supplied `Method`.
`protected String`
`styleNull()`
Generate a styled version of `null`.
`protected String`
`styleObject(Object obj)`
Generate a styled version of the supplied `Object`.
`protected String`
`styleString(String str)`
Generate a styled version of the supplied `String`.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### DefaultValueStyler

public DefaultValueStyler()

## Method Details

### style

public String style(@Nullable Object value)
Description copied from interface: `ValueStyler`
Style the given value, returning a String representation.

Specified by:
  `style` in interface `ValueStyler`
Parameters:
  `value` - the Object value to style
Returns:
  the styled String

### styleNull

protected String styleNull()
Generate a styled version of `null`.

The default implementation returns `"[null]"`.

Returns:
  a styled version of `null`
Since:
  6.0

### styleString

protected String styleString(String str)
Generate a styled version of the supplied `String`.

The default implementation returns the supplied string wrapped in single quotes.

Returns:
  a styled version of the supplied string
Since:
  6.0

### styleClass

protected String styleClass(Class<?> clazz)
Generate a styled version of the supplied `Class`.

The default implementation delegates to `ClassUtils.getShortName(Class)`.

Returns:
  a styled version of the supplied class
Since:
  6.0

### styleMethod

protected String styleMethod(Method method)
Generate a styled version of the supplied `Method`.

The default implementation returns the method's name and the short name of the method's declaring class, separated by the `"@"` symbol.

Returns:
  a styled version of the supplied method
Since:
  6.0

### styleMap

protected <K, V> String styleMap(Map<K,V> map)
Generate a styled version of the supplied `Map`.

Returns:
  a styled version of the supplied map
Since:
  6.0

### styleMapEntry

protected String styleMapEntry(Map.Entry<?,?> entry)
Generate a styled version of the supplied `Map.Entry`.

Returns:
  a styled version of the supplied map entry
Since:
  6.0

### styleCollection

protected String styleCollection(Collection<?> collection)
Generate a styled version of the supplied `Collection`.

Returns:
  a styled version of the supplied collection
Since:
  6.0

### styleArray

protected String styleArray(Object[] array)
Generate a styled version of the supplied array.

Returns:
  a styled version of the supplied array
Since:
  6.0

### styleObject

protected String styleObject(Object obj)
Generate a styled version of the supplied `Object`.

This method is only invoked by `style(Object)` as a fallback, if none of the other `style*()` methods is suitable for the object's type.

The default implementation delegates to `String.valueOf(Object)`.

Returns:
  a styled version of the supplied object
Since:
  6.0