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
FieldsModifier and TypeFieldDescriptionDefaultClassstyling function:Class.getCanonicalName().DefaultMethodstyling function: converts the suppliedMethodto 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
ConstructorsConstructorDescriptionCreate aSimpleValueStylerusing the supplied class and method stylers. -
Method Summary
Modifier and TypeMethodDescriptionprotected StringstyleArray(Object[] array) Generate a styled version of the supplied array.protected StringstyleClass(Class<?> clazz) Generate a styled version of the suppliedClass.protected StringstyleCollection(Collection<?> collection) Generate a styled version of the suppliedCollection.protected <K,V> String Generate a styled version of the suppliedMap.protected StringstyleMethod(Method method) Generate a styled version of the suppliedMethod.protected StringGenerate a styled version ofnull.protected StringstyleString(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
DefaultClassstyling function:Class.getCanonicalName(). -
DEFAULT_METHOD_STYLER
DefaultMethodstyling function: converts the suppliedMethodto 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:DefaultValueStylerGenerate a styled version ofnull.The default implementation returns
"[null]".- Overrides:
styleNullin classDefaultValueStyler- Returns:
- a styled version of
null
-
styleString
Description copied from class:DefaultValueStylerGenerate a styled version of the suppliedString.The default implementation returns the supplied string wrapped in single quotes.
- Overrides:
styleStringin classDefaultValueStyler- Returns:
- a styled version of the supplied string
-
styleClass
Description copied from class:DefaultValueStylerGenerate a styled version of the suppliedClass.The default implementation delegates to
ClassUtils.getShortName(Class).- Overrides:
styleClassin classDefaultValueStyler- Returns:
- a styled version of the supplied class
-
styleMethod
Description copied from class:DefaultValueStylerGenerate 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:
styleMethodin classDefaultValueStyler- Returns:
- a styled version of the supplied method
-
styleMap
Description copied from class:DefaultValueStylerGenerate a styled version of the suppliedMap.- Overrides:
styleMapin classDefaultValueStyler- Returns:
- a styled version of the supplied map
-
styleCollection
Description copied from class:DefaultValueStylerGenerate a styled version of the suppliedCollection.- Overrides:
styleCollectionin classDefaultValueStyler- Returns:
- a styled version of the supplied collection
-
styleArray
Description copied from class:DefaultValueStylerGenerate a styled version of the supplied array.- Overrides:
styleArrayin classDefaultValueStyler- Returns:
- a styled version of the supplied array
-