Class SimpleValueStyler
- All Implemented Interfaces:
ValueStyler
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
Modifier and TypeFieldDescriptionDefaultClass
styling function:Class.getCanonicalName()
.DefaultMethod
styling function: converts the suppliedMethod
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
ConstructorDescriptionCreate aSimpleValueStyler
using the supplied class and method stylers. -
Method Summary
Modifier and TypeMethodDescriptionprotected String
styleArray
(Object[] array) Generate a styled version of the supplied array.protected String
styleClass
(Class<?> clazz) Generate a styled version of the suppliedClass
.protected String
styleCollection
(Collection<?> collection) Generate a styled version of the suppliedCollection
.protected <K,
V> String Generate a styled version of the suppliedMap
.protected String
styleMethod
(Method method) Generate a styled version of the suppliedMethod
.protected String
Generate a styled version ofnull
.protected String
styleString
(String str) Generate a styled version of the suppliedString
.Methods inherited from class org.springframework.core.style.DefaultValueStyler
style, styleMapEntry, styleObject
-
Field Details
-
DEFAULT_CLASS_STYLER
DefaultClass
styling function:Class.getCanonicalName()
. -
DEFAULT_METHOD_STYLER
DefaultMethod
styling function: converts the suppliedMethod
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
-
Method Details
-
styleNull
Description copied from class:DefaultValueStyler
Generate a styled version ofnull
.The default implementation returns
"[null]"
.- Overrides:
styleNull
in classDefaultValueStyler
- Returns:
- a styled version of
null
-
styleString
Description copied from class:DefaultValueStyler
Generate a styled version of the suppliedString
.The default implementation returns the supplied string wrapped in single quotes.
- Overrides:
styleString
in classDefaultValueStyler
- Returns:
- a styled version of the supplied string
-
styleClass
Description copied from class:DefaultValueStyler
Generate a styled version of the suppliedClass
.The default implementation delegates to
ClassUtils.getShortName(Class)
.- Overrides:
styleClass
in classDefaultValueStyler
- Returns:
- a styled version of the supplied class
-
styleMethod
Description copied from class:DefaultValueStyler
Generate a styled version of the suppliedMethod
.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 classDefaultValueStyler
- Returns:
- a styled version of the supplied method
-
styleMap
Description copied from class:DefaultValueStyler
Generate a styled version of the suppliedMap
.- Overrides:
styleMap
in classDefaultValueStyler
- Returns:
- a styled version of the supplied map
-
styleCollection
Description copied from class:DefaultValueStyler
Generate a styled version of the suppliedCollection
.- Overrides:
styleCollection
in classDefaultValueStyler
- Returns:
- a styled version of the supplied collection
-
styleArray
Description copied from class:DefaultValueStyler
Generate a styled version of the supplied array.- Overrides:
styleArray
in classDefaultValueStyler
- Returns:
- a styled version of the supplied array
-