Search in sources :

Example 1 with PropertyEditorRegistry

use of cn.taketoday.beans.PropertyEditorRegistry in project today-infrastructure by TAKETODAY.

the class ArgumentConvertingMethodInvoker method registerCustomEditor.

/**
 * Register the given custom property editor for all properties of the given type.
 * <p>Typically used in conjunction with the default
 * {@link cn.taketoday.beans.SimpleTypeConverter}; will work with any
 * TypeConverter that implements the PropertyEditorRegistry interface as well.
 *
 * @param requiredType type of the property
 * @param propertyEditor editor to register
 * @see #setTypeConverter
 * @see cn.taketoday.beans.PropertyEditorRegistry#registerCustomEditor
 */
public void registerCustomEditor(Class<?> requiredType, PropertyEditor propertyEditor) {
    TypeConverter converter = getTypeConverter();
    if (!(converter instanceof PropertyEditorRegistry)) {
        throw new IllegalStateException("TypeConverter does not implement PropertyEditorRegistry interface: " + converter);
    }
    ((PropertyEditorRegistry) converter).registerCustomEditor(requiredType, propertyEditor);
}
Also used : SimpleTypeConverter(cn.taketoday.beans.SimpleTypeConverter) TypeConverter(cn.taketoday.beans.TypeConverter) PropertyEditorRegistry(cn.taketoday.beans.PropertyEditorRegistry)

Example 2 with PropertyEditorRegistry

use of cn.taketoday.beans.PropertyEditorRegistry in project today-framework by TAKETODAY.

the class ArgumentConvertingMethodInvoker method registerCustomEditor.

/**
 * Register the given custom property editor for all properties of the given type.
 * <p>Typically used in conjunction with the default
 * {@link cn.taketoday.beans.SimpleTypeConverter}; will work with any
 * TypeConverter that implements the PropertyEditorRegistry interface as well.
 *
 * @param requiredType type of the property
 * @param propertyEditor editor to register
 * @see #setTypeConverter
 * @see cn.taketoday.beans.PropertyEditorRegistry#registerCustomEditor
 */
public void registerCustomEditor(Class<?> requiredType, PropertyEditor propertyEditor) {
    TypeConverter converter = getTypeConverter();
    if (!(converter instanceof PropertyEditorRegistry)) {
        throw new IllegalStateException("TypeConverter does not implement PropertyEditorRegistry interface: " + converter);
    }
    ((PropertyEditorRegistry) converter).registerCustomEditor(requiredType, propertyEditor);
}
Also used : SimpleTypeConverter(cn.taketoday.beans.SimpleTypeConverter) TypeConverter(cn.taketoday.beans.TypeConverter) PropertyEditorRegistry(cn.taketoday.beans.PropertyEditorRegistry)

Aggregations

PropertyEditorRegistry (cn.taketoday.beans.PropertyEditorRegistry)2 SimpleTypeConverter (cn.taketoday.beans.SimpleTypeConverter)2 TypeConverter (cn.taketoday.beans.TypeConverter)2