use of org.springframework.core.convert.support.ConvertingPropertyEditorAdapter in project spring-framework by spring-projects.
the class AbstractPropertyBindingResult method findEditor.
/**
* This implementation exposes a PropertyEditor adapter for a Formatter,
* if applicable.
*/
@Override
public PropertyEditor findEditor(String field, Class<?> valueType) {
Class<?> valueTypeForLookup = valueType;
if (valueTypeForLookup == null) {
valueTypeForLookup = getFieldType(field);
}
PropertyEditor editor = super.findEditor(field, valueTypeForLookup);
if (editor == null && this.conversionService != null) {
TypeDescriptor td = null;
if (field != null) {
TypeDescriptor ptd = getPropertyAccessor().getPropertyTypeDescriptor(fixedField(field));
if (valueType == null || valueType.isAssignableFrom(ptd.getType())) {
td = ptd;
}
}
if (td == null) {
td = TypeDescriptor.valueOf(valueTypeForLookup);
}
if (this.conversionService.canConvert(TypeDescriptor.valueOf(String.class), td)) {
editor = new ConvertingPropertyEditorAdapter(this.conversionService, td);
}
}
return editor;
}
Aggregations