refined collection element conversion (SPR-8674)

This commit is contained in:
Juergen Hoeller
2011-12-22 02:14:55 +01:00
parent 2006eecb18
commit 836e3c9253
2 changed files with 138 additions and 134 deletions

View File

@@ -138,6 +138,9 @@ class TypeConverterDelegate {
if (editor == null && conversionService != null && convertedValue != null) {
TypeDescriptor sourceTypeDesc = TypeDescriptor.forObject(convertedValue);
TypeDescriptor targetTypeDesc = typeDescriptor;
if (requiredType != null && !requiredType.isAssignableFrom(typeDescriptor.getType())) {
targetTypeDesc = typeDescriptor.forElementType(requiredType);
}
if (conversionService.canConvert(sourceTypeDesc, targetTypeDesc)) {
return (T) conversionService.convert(convertedValue, sourceTypeDesc, targetTypeDesc);
}
@@ -529,7 +532,7 @@ class TypeConverterDelegate {
methodParam.increaseNestingLevel();
}
Object convertedElement = convertIfNecessary(
indexedPropertyName, null, element, elementType, typeDescriptor.getElementTypeDescriptor(element));
indexedPropertyName, null, element, elementType, typeDescriptor);
if (methodParam != null) {
methodParam.decreaseNestingLevel();
}
@@ -623,13 +626,11 @@ class TypeConverterDelegate {
methodParam.increaseNestingLevel();
methodParam.setTypeIndexForCurrentLevel(0);
}
Object convertedKey = convertIfNecessary(keyedPropertyName, null, key, keyType,
typeDescriptor.getMapKeyTypeDescriptor(key));
Object convertedKey = convertIfNecessary(keyedPropertyName, null, key, keyType, typeDescriptor);
if (methodParam != null) {
methodParam.setTypeIndexForCurrentLevel(1);
}
Object convertedValue = convertIfNecessary(keyedPropertyName, null, value, valueType,
typeDescriptor.getMapValueTypeDescriptor(value));
Object convertedValue = convertIfNecessary(keyedPropertyName, null, value, valueType, typeDescriptor);
if (methodParam != null) {
methodParam.decreaseNestingLevel();
}