Collection<?> collection = (Collection<?>) target;
Object array = Array.newInstance(sourceClass.getComponentType(), collection.size());
int i = 0;
for (Object value : collection) {
if (value != null) {
ConversionExecutor converter;
if (elementConverter != null) {
converter = elementConverter;
} else {
converter = conversionService.getConversionExecutor(value.getClass(),
sourceClass.getComponentType());
}
value = converter.execute(value);
}
Array.set(array, i++, value);
}
return array;
}