Package org.springframework.core.style

# Class SimpleValueStyler

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

All Implemented Interfaces:
  `ValueStyler`

public class SimpleValueStyler extends DefaultValueStyler
`ValueStyler` that converts objects to String form — generally for debugging purposes — using simple styling conventions that mimic the `toString()` styling conventions for standard JDK implementations of collections, maps, and arrays.

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

Favor `SimpleValueStyler` over `DefaultValueStyler` when you wish to use styling similar to the JDK or when you need configurable control over the styling of classes and methods.

Since:
  6.0
Author:
  Sam Brannen

## Field Summary

Fields
Modifier and Type
Field
Description
`static final Function<Class<?>,String>`
`DEFAULT_CLASS_STYLER`
Default `Class` styling function: `Class.getCanonicalName()`.
`static final Function<Method,String>`
`DEFAULT_METHOD_STYLER`
Default `Method` styling function: converts the supplied `Method` to a simple string representation of the method's signature in the form of `<method name>(<parameter types>)`, where `<parameter types>` is a comma-separated list of the simple names of the parameter types.

## Constructor Summary

Constructors
Constructor
Description
`SimpleValueStyler()`
Create a `SimpleValueStyler` using the `DEFAULT_CLASS_STYLER` and `DEFAULT_METHOD_STYLER`.
`SimpleValueStyler(Function<Class<?>,String> classStyler, Function<Method,String> methodStyler)`
Create a `SimpleValueStyler` using the supplied class and method stylers.

## Method Summary

Modifier and Type
Method
Description
`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`
`styleMethod(Method method)`
Generate a styled version of the supplied `Method`.
`protected String`
`styleNull()`
Generate a styled version of `null`.
`protected String`
`styleString(String str)`
Generate a styled version of the supplied `String`.

### Methods inherited from class org.springframework.core.style.DefaultValueStyler

`style, styleMapEntry, styleObject`

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

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

## Field Details

### DEFAULT_CLASS_STYLER

public static final Function<Class<?>,String> DEFAULT_CLASS_STYLER
Default `Class` styling function: `Class.getCanonicalName()`.

### DEFAULT_METHOD_STYLER

public static final Function<Method,String> DEFAULT_METHOD_STYLER
Default `Method` styling function: converts the supplied `Method` to a simple string representation of the method's signature in the form of `<method name>(<parameter types>)`, where `<parameter types>` is a comma-separated list of the simple names of the parameter types.

For example, if the supplied method is a reference to `String.getBytes(java.nio.charset.Charset)`, this function will return `"getBytes(Charset)"`.

## Constructor Details

### SimpleValueStyler

public SimpleValueStyler()
Create a `SimpleValueStyler` using the `DEFAULT_CLASS_STYLER` and `DEFAULT_METHOD_STYLER`.

### SimpleValueStyler

public SimpleValueStyler(Function<Class<?>,String> classStyler, Function<Method,String> methodStyler)
Create a `SimpleValueStyler` using the supplied class and method stylers.

Parameters:
  `classStyler` - a function that applies styling to a `Class`
  `methodStyler` - a function that applies styling to a `Method`

## Method Details

### styleNull

protected String styleNull()
Description copied from class: `DefaultValueStyler`
Generate a styled version of `null`.

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

Overrides:
  `styleNull` in class `DefaultValueStyler`
Returns:
  a styled version of `null`

### styleString

protected String styleString(String str)
Description copied from class: `DefaultValueStyler`
Generate a styled version of the supplied `String`.

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

Overrides:
  `styleString` in class `DefaultValueStyler`
Returns:
  a styled version of the supplied string

### styleClass

protected String styleClass(Class<?> clazz)
Description copied from class: `DefaultValueStyler`
Generate a styled version of the supplied `Class`.

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

Overrides:
  `styleClass` in class `DefaultValueStyler`
Returns:
  a styled version of the supplied class

### styleMethod

protected String styleMethod(Method method)
Description copied from class: `DefaultValueStyler`
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.

Overrides:
  `styleMethod` in class `DefaultValueStyler`
Returns:
  a styled version of the supplied method

### styleMap

protected <K, V> String styleMap(Map<K,V> map)
Description copied from class: `DefaultValueStyler`
Generate a styled version of the supplied `Map`.

Overrides:
  `styleMap` in class `DefaultValueStyler`
Returns:
  a styled version of the supplied map

### styleCollection

protected String styleCollection(Collection<?> collection)
Description copied from class: `DefaultValueStyler`
Generate a styled version of the supplied `Collection`.

Overrides:
  `styleCollection` in class `DefaultValueStyler`
Returns:
  a styled version of the supplied collection

### styleArray

protected String styleArray(Object[] array)
Description copied from class: `DefaultValueStyler`
Generate a styled version of the supplied array.

Overrides:
  `styleArray` in class `DefaultValueStyler`
Returns:
  a styled version of the supplied array