Top Description Fields Constructors Methods
org.springframework.core.style

public Class DefaultValueStyler

extends Object
implements ValueStyler
Class Inheritance
All Implemented Interfaces
org.springframework.core.style.ValueStyler
Known Direct Subclasses
org.springframework.core.style.SimpleValueStyler
Imports
java.lang.reflect.Method, java.util.Collection, .List, .Map, .Set, .StringJoiner, org.springframework.lang.Nullable, org.springframework.util.ClassUtils, .ObjectUtils

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.

Authors
Keith Donald, Juergen Hoeller, Sam Brannen
Since
1.2.2

Field Summary

Modifier and TypeField and Description
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static String
public String
style(Object
the Object value to style
value
)

Implements org.springframework.core.style.ValueStyler.style.

Style the given value, returning a String representation.

protected String

Returns:

a styled version of the supplied array
styleArray
(Object[] array)

Generate a styled version of the supplied array.

protected String

Returns:

a styled version of the supplied class
styleClass
(Class<?> clazz)

Generate a styled version of the supplied Class.

protected String

Returns:

a styled version of the supplied collection
styleCollection
(Collection<?> collection)

Generate a styled version of the supplied Collection.

protected <K, V> String

Returns:

a styled version of the supplied map
styleMap
(Map<K, V> map)

Generate a styled version of the supplied Map.

protected String

Returns:

a styled version of the supplied map entry
styleMapEntry
(Map.Entry<?, ?> entry)

Generate a styled version of the supplied Map.Entry.

protected String

Returns:

a styled version of the supplied method
styleMethod
(Method method)

Generate a styled version of the supplied Method.

protected String

Returns:

a styled version of null
styleNull
()

Generate a styled version of null.

protected String

Returns:

a styled version of the supplied object
styleObject
(Object obj)

Generate a styled version of the supplied Object.

protected String

Returns:

a styled version of the supplied string
styleString
(String str)

Generate a styled version of the supplied String.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ARRAYback to summary
private static final String ARRAY
COLLECTIONback to summary
private static final String COLLECTION
EMPTYback to summary
private static final String EMPTY
EMPTY_MAPback to summary
private static final String EMPTY_MAP
LISTback to summary
private static final String LIST
MAPback to summary
private static final String MAP
NULLback to summary
private static final String NULL
SETback to summary
private static final String SET

Constructor Detail

DefaultValueStylerback to summary
public DefaultValueStyler()

Method Detail

getCollectionTypeStringback to summary
private static String getCollectionTypeString(Collection<?> collection)
styleback to summary
public String style(Object value)

Implements org.springframework.core.style.ValueStyler.style.

Doc from org.springframework.core.style.ValueStyler.style.

Style the given value, returning a String representation.

Parameters
value:Object

the Object value to style

Returns:String

the styled String

Annotations
@Override
styleArrayback to summary
protected String styleArray(Object[] array)

Generate a styled version of the supplied array.

Returns:String

a styled version of the supplied array

Since
6.0
styleClassback to summary
protected String styleClass(Class<?> clazz)

Generate a styled version of the supplied Class.

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

Returns:String

a styled version of the supplied class

Since
6.0
styleCollectionback to summary
protected String styleCollection(Collection<?> collection)

Generate a styled version of the supplied Collection.

Returns:String

a styled version of the supplied collection

Since
6.0
styleMapback to summary
protected <K, V> String styleMap(Map<K, V> map)

Generate a styled version of the supplied Map.

Returns:String

a styled version of the supplied map

Since
6.0
styleMapEntryback to summary
protected String styleMapEntry(Map.Entry<?, ?> entry)

Generate a styled version of the supplied Map.Entry.

Returns:String

a styled version of the supplied map entry

Since
6.0
styleMethodback to summary
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:String

a styled version of the supplied method

Since
6.0
styleNullback to summary
protected String styleNull()

Generate a styled version of null.

The default implementation returns "[null]".

Returns:String

a styled version of null

Since
6.0
styleObjectback to summary
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:String

a styled version of the supplied object

Since
6.0
styleStringback to summary
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:String

a styled version of the supplied string

Since
6.0