// targetClass is the correct one
if ((sourceClass == null) || (sourceClass == targetClass)) {
return sourceValueModel;
}
final ConversionService conversionService = getConversionService();
ConversionExecutor convertTo = null;
ConversionExecutor convertFrom = null;
// Check for locally registered property converters
if (propertyConversionServices.containsKey(formProperty)) {
// TODO - extract ConfigurableConversionService interface...
final GenericConversionService propertyConversionService = (GenericConversionService) propertyConversionServices
.get(formProperty);
if (propertyConversionService != null) {
convertTo = propertyConversionService.getConversionExecutor(sourceClass, targetClass);
convertFrom = propertyConversionService.getConversionExecutor(targetClass, sourceClass);
}
}
// If we have nothing from the property level, then try the conversion
// service
if (convertTo == null) {
convertTo = conversionService.getConversionExecutor(sourceClass, targetClass);
}
Assert.notNull(convertTo, "conversionService returned null ConversionExecutor");
if (convertFrom == null) {
convertFrom = conversionService.getConversionExecutor(targetClass, sourceClass);
}
Assert.notNull(convertFrom, "conversionService returned null ConversionExecutor");
ValueModel convertingValueModel = preProcessNewConvertingValueModel(formProperty, targetClass,
new TypeConverter(sourceValueModel, convertTo, convertFrom));