GenericConverter.getConvertibleTypes returns a pair of Class<?>
, while GenericConverter. convert accepts a pair of TypeDescriptor
. This is inconsistent because the getConvertibleTypes
has no way to specify generic type information that's available in the TypeDescriptor
. If I wrote a converter to convert comma-separated string to a list of integers, and another to convert comma-separated string to a list of floats, the getConvertibleTypes
wouldn't be able to differentiate between them.
It makes a lot of sense to return a pair of TypeDescriptor
from getConvertibleTypes, so that it's consistent with the convert
method.
Comment From: jhoeller
getConvertibleTypes
is only meant as a basic indication for early filtering. For non-unique cases, you need to implement ConditionalGenericConverter
and indicate an actual fit with the intended generics via matches(TypeDescriptor sourceType, TypeDescriptor targetType)
.