INT-1974 removed the IF statement which was checking the state of the collection in favor of delegating to the ConversionService

This commit is contained in:
Oleg Zhurakousky
2011-07-13 12:36:51 -04:00
parent b99504ad96
commit f8acd850dc
2 changed files with 1 additions and 9 deletions

View File

@@ -17,7 +17,6 @@
package org.springframework.integration.util;
import java.beans.PropertyEditor;
import java.util.Collection;
import org.springframework.beans.BeansException;
import org.springframework.beans.SimpleTypeConverter;
@@ -28,7 +27,6 @@ import org.springframework.core.convert.ConversionService;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.core.convert.support.ConversionServiceFactory;
import org.springframework.expression.TypeConverter;
import org.springframework.util.CollectionUtils;
/**
* @author Dave Syer
@@ -99,11 +97,6 @@ public class BeanFactoryTypeConverter implements TypeConverter, BeanFactoryAware
if (targetType.getType() == Void.class || targetType.getType() == Void.TYPE) {
return null;
}
if (value instanceof Collection<?>
&& CollectionUtils.isEmpty((Collection<?>) value)
&& Collection.class.isAssignableFrom(targetType.getObjectType())){
return value;
}
if (conversionService.canConvert(sourceType, targetType)) {
return conversionService.convert(value, sourceType, targetType);
}

View File

@@ -25,9 +25,8 @@ public class BeanFactoryTypeConverterTests {
public void testEmptyCollectionConversion(){
BeanFactoryTypeConverter typeConverter = new BeanFactoryTypeConverter();
List<String> sourceObject = new ArrayList<String>();
// source type doesn't even matter
ArrayList<BeanFactoryTypeConverterTests> convertedCollection =
(ArrayList<BeanFactoryTypeConverterTests>) typeConverter.convertValue(sourceObject, null, TypeDescriptor.forObject(new ArrayList<BeanFactoryTypeConverterTests>()));
(ArrayList<BeanFactoryTypeConverterTests>) typeConverter.convertValue(sourceObject, TypeDescriptor.forObject(sourceObject), TypeDescriptor.forObject(new ArrayList<BeanFactoryTypeConverterTests>()));
assertEquals(sourceObject, convertedCollection);
}