Skip to content

TypeConverterDelegate contains commented out code [SPR-8463] #13109

@spring-projects-issues

Description

@spring-projects-issues

!!Use pwebb rather than philw opened SPR-8463 and commented

As of 3.1M2 the class org.springframework.beans.TypeConverterDelegate has the following method:

/**
 * Find a default editor for the given type.
 * @param requiredType the type to find an editor for
 * @param descriptor the JavaBeans descriptor for the property
 * @return the corresponding editor, or <code>null</code> if none
 */
protected PropertyEditor findDefaultEditor(Class requiredType, TypeDescriptor typeDescriptor) {
     PropertyEditor editor = null;
     //if (typeDescriptor instanceof PropertyTypeDescriptor) {
          //PropertyDescriptor pd = ((PropertyTypeDescriptor) typeDescriptor).getPropertyDescriptor();
          //editor = pd.createPropertyEditor(this.targetObject);
     //}
     if (editor == null && requiredType != null) {
          // No custom editor -> check BeanWrapperImpl's default editors.
          editor = this.propertyEditorRegistry.getDefaultEditor(requiredType);
          if (editor == null && !String.class.equals(requiredType)) {
               // No BeanWrapper default editor -> check standard JavaBean editor.
               editor = BeanUtils.findEditorByConvention(requiredType);
          }
     }
     return editor;
}

I have a class that needs to perform an identical lookup, so I have been paying close attention to this method:

https://github.com/philwebb/springfaces/blob/master/springfaces-mvc/src/main/java/org/springframework/springfaces/mvc/bind/ReverseDataBinder.java#L213

As the PropertyTypeDescriptor class has now been removed could the commented out lines be removed all together? Looking at the code I was not entirely sure if they had been commented out as a temporary measure, or if the change is intended to be permanent.

Would it also be possible to have this method exposed as a static utility somewhere so that it can be reused?

Something like:

  /**
 * Find a default editor for the given type.
 * @param requiredType the type to find an editor for
 * @param descriptor the JavaBeans descriptor for the property
 * @return the corresponding editor, or <code>null</code> if none
 */
protected PropertyEditor findDefaultEditor(Class<?> requiredType, TypeDescriptor typeDescriptor) {
     return findDefaultEditor(requiredType, typeDescriptor, this.propertyEditorRegistry);
}
/**
 * Find a default editor for the given type.
 * @param requiredType the type to find an editor for
 * @param descriptor the JavaBeans descriptor for the property
 * @return the corresponding editor, or <code>null</code> if none
 */
public static PropertyEditor findDefaultEditor(Class<?> requiredType,
          TypeDescriptor typeDescriptor,
          PropertyEditorRegistrySupport propertyEditorRegistry) {
     PropertyEditor editor = null;
     if (requiredType != null) {
          // check BeanWrapperImpl's default editors.
          editor = propertyEditorRegistry.getDefaultEditor(requiredType);
          if (editor == null && !String.class.equals(requiredType)) {
               // No BeanWrapper default editor -> check standard JavaBean editor.
               editor = BeanUtils.findEditorByConvention(requiredType);
          }
     }
     return editor;
}

Affects: 3.1 M2

Issue Links:

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions