Revert ConversionService SPI interface
Remove canBypassConvert() methods from the ConversionService SPI interface, restoring it to the previous Spring 3.1 incarnation. Bypassing conversion is now only supported when using a GenericConversionService. Issue: SPR-9566
This commit is contained in:
@@ -55,30 +55,6 @@ public interface ConversionService {
|
|||||||
*/
|
*/
|
||||||
boolean canConvert(TypeDescriptor sourceType, TypeDescriptor targetType);
|
boolean canConvert(TypeDescriptor sourceType, TypeDescriptor targetType);
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if conversion between the sourceType and targetType can be bypassed.
|
|
||||||
* More precisely this method will return true if objects of sourceType can be
|
|
||||||
* converted to the targetType by returning the source object unchanged.
|
|
||||||
* @param sourceType context about the source type to convert from (may be null if source is null)
|
|
||||||
* @param targetType context about the target type to convert to (required)
|
|
||||||
* @return true if conversion can be bypassed
|
|
||||||
* @throws IllegalArgumentException if targetType is null
|
|
||||||
* @since 3.2
|
|
||||||
*/
|
|
||||||
boolean canBypassConvert(Class<?> sourceType, Class<?> targetType);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if conversion between the sourceType and targetType can be bypassed.
|
|
||||||
* More precisely this method will return true if objects of sourceType can be
|
|
||||||
* converted to the targetType by returning the source object unchanged.
|
|
||||||
* @param sourceType context about the source type to convert from (may be null if source is null)
|
|
||||||
* @param targetType context about the target type to convert to (required)
|
|
||||||
* @return true if conversion can be bypassed
|
|
||||||
* @throws IllegalArgumentException if targetType is null
|
|
||||||
* @since 3.2
|
|
||||||
*/
|
|
||||||
boolean canBypassConvert(TypeDescriptor sourceType, TypeDescriptor targetType);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert the source to targetType.
|
* Convert the source to targetType.
|
||||||
* @param source the source object to convert (may be null)
|
* @param source the source object to convert (may be null)
|
||||||
|
|||||||
@@ -55,8 +55,10 @@ final class ArrayToArrayConverter implements ConditionalGenericConverter {
|
|||||||
|
|
||||||
public Object convert(Object source, TypeDescriptor sourceType,
|
public Object convert(Object source, TypeDescriptor sourceType,
|
||||||
TypeDescriptor targetType) {
|
TypeDescriptor targetType) {
|
||||||
if (conversionService.canBypassConvert(sourceType.getElementTypeDescriptor(),
|
if ((conversionService instanceof GenericConversionService)
|
||||||
targetType.getElementTypeDescriptor())) {
|
&& ((GenericConversionService) conversionService).canBypassConvert(
|
||||||
|
sourceType.getElementTypeDescriptor(),
|
||||||
|
targetType.getElementTypeDescriptor())) {
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
List<Object> sourceList = Arrays.asList(ObjectUtils.toObjectArray(source));
|
List<Object> sourceList = Arrays.asList(ObjectUtils.toObjectArray(source));
|
||||||
|
|||||||
@@ -129,13 +129,16 @@ public class GenericConversionService implements ConfigurableConversionService {
|
|||||||
return (converter != null);
|
return (converter != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canBypassConvert(Class<?> sourceType, Class<?> targetType) {
|
/**
|
||||||
Assert.notNull(targetType, "The targetType to convert to cannot be null");
|
* Returns true if conversion between the sourceType and targetType can be bypassed.
|
||||||
return canBypassConvert(sourceType != null ?
|
* More precisely this method will return true if objects of sourceType can be
|
||||||
TypeDescriptor.valueOf(sourceType) : null,
|
* converted to the targetType by returning the source object unchanged.
|
||||||
TypeDescriptor.valueOf(targetType));
|
* @param sourceType context about the source type to convert from (may be null if source is null)
|
||||||
}
|
* @param targetType context about the target type to convert to (required)
|
||||||
|
* @return true if conversion can be bypassed
|
||||||
|
* @throws IllegalArgumentException if targetType is null
|
||||||
|
* @since 3.2
|
||||||
|
*/
|
||||||
public boolean canBypassConvert(TypeDescriptor sourceType, TypeDescriptor targetType) {
|
public boolean canBypassConvert(TypeDescriptor sourceType, TypeDescriptor targetType) {
|
||||||
Assert.notNull(targetType, "The targetType to convert to cannot be null");
|
Assert.notNull(targetType, "The targetType to convert to cannot be null");
|
||||||
if (sourceType == null) {
|
if (sourceType == null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user