polish
This commit is contained in:
parent
a0cab10ccc
commit
3e4810f670
|
|
@ -57,7 +57,7 @@ class CollectionToArray extends AbstractCollectionConverter {
|
||||||
|
|
||||||
private ConversionExecutor getElementConverter(Collection<?> source) {
|
private ConversionExecutor getElementConverter(Collection<?> source) {
|
||||||
ConversionExecutor elementConverter = getElementConverter();
|
ConversionExecutor elementConverter = getElementConverter();
|
||||||
if (elementConverter == NoOpConversionExecutor.INSTANCE && !source.isEmpty()) {
|
if (elementConverter == NoOpConversionExecutor.INSTANCE) {
|
||||||
Iterator<?> it = source.iterator();
|
Iterator<?> it = source.iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
Object value = it.next();
|
Object value = it.next();
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ class CollectionToCollection extends AbstractCollectionConverter {
|
||||||
|
|
||||||
private ConversionExecutor getElementConverter(Collection<?> source) {
|
private ConversionExecutor getElementConverter(Collection<?> source) {
|
||||||
ConversionExecutor elementConverter = getElementConverter();
|
ConversionExecutor elementConverter = getElementConverter();
|
||||||
if (elementConverter == NoOpConversionExecutor.INSTANCE && !source.isEmpty() && getTargetElementType() != null) {
|
if (elementConverter == NoOpConversionExecutor.INSTANCE && getTargetElementType() != null) {
|
||||||
Iterator<?> it = source.iterator();
|
Iterator<?> it = source.iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
Object value = it.next();
|
Object value = it.next();
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package org.springframework.core.convert.service;
|
package org.springframework.core.convert.service;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
@ -70,6 +71,15 @@ public class CollectionToCollectionTests {
|
||||||
assertEquals(null, result.get(3));
|
assertEquals(null, result.get(3));
|
||||||
assertEquals(new Integer(3), result.get(4));
|
assertEquals(new Integer(3), result.get(4));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCollectionToCollectionConversionNoGenericInfoSourceEmpty() throws Exception {
|
||||||
|
DefaultConversionService service = new DefaultConversionService();
|
||||||
|
CollectionToCollection c = new CollectionToCollection(TypeDescriptor.valueOf(Collection.class),
|
||||||
|
new TypeDescriptor(getClass().getField("integerTarget")), service);
|
||||||
|
List result = (List) c.execute(bindTarget);
|
||||||
|
assertTrue(result.isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public Collection<String> bindTarget = new ArrayList<String>();
|
public Collection<String> bindTarget = new ArrayList<String>();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue