final class CollectionToArrayConverter extends java.lang.Object implements ConditionalGenericConverter
First, creates a new array of the requested targetType with a length equal to the size of the source Collection. Then sets each collection element into the array. Will perform an element conversion from the collection's parameterized type to the array's component type if necessary.
GenericConverter.ConvertiblePair| Modifier and Type | Field and Description |
|---|---|
private ConversionService |
conversionService |
| Constructor and Description |
|---|
CollectionToArrayConverter(ConversionService conversionService) |
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
convert(java.lang.Object source,
TypeDescriptor sourceType,
TypeDescriptor targetType)
Convert the source object to the targetType described by the
TypeDescriptor. |
java.util.Set<GenericConverter.ConvertiblePair> |
getConvertibleTypes()
Return the source and target types that this converter can convert between.
|
boolean |
matches(TypeDescriptor sourceType,
TypeDescriptor targetType)
Should the conversion from
sourceType to targetType currently under
consideration be selected? |
private final ConversionService conversionService
public CollectionToArrayConverter(ConversionService conversionService)
public java.util.Set<GenericConverter.ConvertiblePair> getConvertibleTypes()
GenericConverterEach entry is a convertible source-to-target type pair.
For conditional converters this method may return
null to indicate all source-to-target pairs should be considered.
getConvertibleTypes in interface GenericConverterpublic boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType)
ConditionalConvertersourceType to targetType currently under
consideration be selected?matches in interface ConditionalConvertersourceType - the type descriptor of the field we are converting fromtargetType - the type descriptor of the field we are converting topublic java.lang.Object convert(java.lang.Object source,
TypeDescriptor sourceType,
TypeDescriptor targetType)
GenericConverterTypeDescriptor.convert in interface GenericConvertersource - the source object to convert (may be null)sourceType - the type descriptor of the field we are converting fromtargetType - the type descriptor of the field we are converting to