At the moment there is the method
Object convert(@Nullable Object source, @Nullable TypeDescriptor sourceType, TypeDescriptor targetType);
And usually sourceType
can be deduced from source
and it is unnecessary to specify the sourceType
. Please add a new convert
method which will remove necessity to specify the type descriptor if it is the same as source
.
Object convert(@Nullable Object source, TypeDescriptor targetType) {
return convert(source, TypeDescriptor.forObject(source), targetType);
}
Comment From: sbrannen
Does the existing <T> T convert(@Nullable Object source, Class<T> targetType)
method not meet your needs in terms of convenience?
Comment From: raderio
Can you please advise how to use it when I need to convert an object to a List<T>
?
Comment From: dPechman42
Would it be possible for me to work on this?
Comment From: sbrannen
Can you please advise how to use it when I need to convert an object to a
List<T>
?
You would need a target TypeDescriptor
for that.
Comment From: sbrannen
Team Decision: assigned to the General Backlog to allow this issue to gain wider community interest.
Comment From: jhoeller
Since the Class
-based methods can be seen as a convenience already (in comparison to the SpEL TypeConverter
which just has the essential SPI methods) and since GenericConversionService
has a convert(Object, TypeDescriptor)
already, let's expose that method as a default method on the ConversionService
interface for 6.1 now.