final class MapToMapConverter extends java.lang.Object implements ConditionalGenericConverter
First, creates a new Map of the requested targetType with a size equal to the size of the source Map. Then copies each element in the source map to the target map. Will perform a conversion from the source maps's parameterized K,V types to the target map's parameterized types K,V if necessary.
Modifier and Type | Class and Description |
---|---|
private static class |
MapToMapConverter.MapEntry |
GenericConverter.ConvertiblePair
Modifier and Type | Field and Description |
---|---|
private ConversionService |
conversionService |
Constructor and Description |
---|
MapToMapConverter(ConversionService conversionService) |
Modifier and Type | Method and Description |
---|---|
private boolean |
canConvertKey(TypeDescriptor sourceType,
TypeDescriptor targetType) |
private boolean |
canConvertValue(TypeDescriptor sourceType,
TypeDescriptor targetType) |
java.lang.Object |
convert(java.lang.Object source,
TypeDescriptor sourceType,
TypeDescriptor targetType)
Convert the source object to the targetType described by the
TypeDescriptor . |
private java.lang.Object |
convertKey(java.lang.Object sourceKey,
TypeDescriptor sourceType,
TypeDescriptor targetType) |
private java.lang.Object |
convertValue(java.lang.Object sourceValue,
TypeDescriptor sourceType,
TypeDescriptor targetType) |
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 MapToMapConverter(ConversionService conversionService)
public java.util.Set<GenericConverter.ConvertiblePair> getConvertibleTypes()
GenericConverter
Each 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 GenericConverter
public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType)
ConditionalConverter
sourceType
to targetType
currently under
consideration be selected?matches
in interface ConditionalConverter
sourceType
- the type descriptor of the field we are converting fromtargetType
- the type descriptor of the field we are converting to@Nullable public java.lang.Object convert(@Nullable java.lang.Object source, TypeDescriptor sourceType, TypeDescriptor targetType)
GenericConverter
TypeDescriptor
.convert
in interface GenericConverter
source
- 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 toprivate boolean canConvertKey(TypeDescriptor sourceType, TypeDescriptor targetType)
private boolean canConvertValue(TypeDescriptor sourceType, TypeDescriptor targetType)
@Nullable private java.lang.Object convertKey(java.lang.Object sourceKey, TypeDescriptor sourceType, @Nullable TypeDescriptor targetType)
@Nullable private java.lang.Object convertValue(java.lang.Object sourceValue, TypeDescriptor sourceType, @Nullable TypeDescriptor targetType)