final class FallbackObjectToStringConverter extends java.lang.Object implements ConditionalGenericConverter
Object.toString()
to convert any supported object
to a String
.
Supports CharSequence
, StringWriter
, and any class
with a String constructor or one of the following static factory methods:
valueOf(String)
, of(String)
, from(String)
.
Used by the DefaultConversionService
as a fallback if there
are no other explicit to-String converters registered.
ObjectToObjectConverter
GenericConverter.ConvertiblePair
Constructor and Description |
---|
FallbackObjectToStringConverter() |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
convert(java.lang.Object source,
TypeDescriptor sourceType,
TypeDescriptor targetType)
Convert the source object to the targetType described by the
TypeDescriptor . |
java.util.Set<GenericConverter.ConvertiblePair> |
getConvertibleTypes()
Return the source and target types that this converter can convert between.
|
boolean |
matches(TypeDescriptor sourceType,
TypeDescriptor targetType)
Should the conversion from
sourceType to targetType currently under
consideration be selected? |
public java.util.Set<GenericConverter.ConvertiblePair> getConvertibleTypes()
GenericConverter
Each entry is a convertible source-to-target type pair.
For conditional converters
this method may return
null
to indicate all source-to-target pairs should be considered.
getConvertibleTypes
in interface GenericConverter
public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType)
ConditionalConverter
sourceType
to targetType
currently under
consideration be selected?matches
in interface ConditionalConverter
sourceType
- the type descriptor of the field we are converting fromtargetType
- the type descriptor of the field we are converting topublic java.lang.Object convert(java.lang.Object source, TypeDescriptor sourceType, TypeDescriptor targetType)
GenericConverter
TypeDescriptor
.convert
in interface GenericConverter
source
- the source object to convert (may be null
)sourceType
- the type descriptor of the field we are converting fromtargetType
- the type descriptor of the field we are converting to