org.springframework.core.convert.support
Class MapToMapConverter
java.lang.Object
org.springframework.core.convert.support.MapToMapConverter
- All Implemented Interfaces:
- ConditionalGenericConverter, GenericConverter
final class MapToMapConverter
- extends java.lang.Object
- implements ConditionalGenericConverter
Converts a Map to another Map.
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.
- Since:
- 3.0
- Author:
- Keith Donald
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
conversionService
private final ConversionService conversionService
MapToMapConverter
public MapToMapConverter(ConversionService conversionService)
getConvertibleTypes
public java.util.Set<GenericConverter.ConvertiblePair> getConvertibleTypes()
- Description copied from interface:
GenericConverter
- Return the source and target types which this converter can convert between.
Each entry is a convertible source-to-target type pair.
- Specified by:
getConvertibleTypes
in interface GenericConverter
matches
public boolean matches(TypeDescriptor sourceType,
TypeDescriptor targetType)
- Description copied from interface:
ConditionalGenericConverter
- Should the converter from
sourceType
to targetType
currently under consideration be selected?
- Specified by:
matches
in interface ConditionalGenericConverter
- Parameters:
sourceType
- the type descriptor of the field we are converting fromtargetType
- the type descriptor of the field we are converting to
- Returns:
- true if conversion should be performed, false otherwise
convert
public java.lang.Object convert(java.lang.Object source,
TypeDescriptor sourceType,
TypeDescriptor targetType)
- Description copied from interface:
GenericConverter
- Convert the source to the targetType described by the TypeDescriptor.
- Specified by:
convert
in interface GenericConverter
- Parameters:
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 to
- Returns:
- the converted object
canConvertKey
private boolean canConvertKey(TypeDescriptor sourceType,
TypeDescriptor targetType)
canConvertValue
private boolean canConvertValue(TypeDescriptor sourceType,
TypeDescriptor targetType)
convertKey
private java.lang.Object convertKey(java.lang.Object sourceKey,
TypeDescriptor sourceType,
TypeDescriptor targetType)
convertValue
private java.lang.Object convertValue(java.lang.Object sourceValue,
TypeDescriptor sourceType,
TypeDescriptor targetType)