Java Code Examples for org.springframework.format.support.FormatterPropertyEditorAdapter#getFieldType()

The following examples show how to use org.springframework.format.support.FormatterPropertyEditorAdapter#getFieldType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DataBinder.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Add a custom formatter for the field type specified in {@link Formatter} class,
 * applying it to the specified fields only, if any, or otherwise to all fields.
 * <p>Registers a corresponding {@link PropertyEditor} adapter underneath the covers.
 * @param formatter the formatter to add, generically declared for a specific type
 * @param fields the fields to apply the formatter to, or none if to be applied to all
 * @since 4.2
 * @see #registerCustomEditor(Class, String, PropertyEditor)
 */
public void addCustomFormatter(Formatter<?> formatter, String... fields) {
	FormatterPropertyEditorAdapter adapter = new FormatterPropertyEditorAdapter(formatter);
	Class<?> fieldType = adapter.getFieldType();
	if (ObjectUtils.isEmpty(fields)) {
		getPropertyEditorRegistry().registerCustomEditor(fieldType, adapter);
	}
	else {
		for (String field : fields) {
			getPropertyEditorRegistry().registerCustomEditor(fieldType, field, adapter);
		}
	}
}
 
Example 2
Source File: DataBinder.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Add a custom formatter for the field type specified in {@link Formatter} class,
 * applying it to the specified fields only, if any, or otherwise to all fields.
 * <p>Registers a corresponding {@link PropertyEditor} adapter underneath the covers.
 * @param formatter the formatter to add, generically declared for a specific type
 * @param fields the fields to apply the formatter to, or none if to be applied to all
 * @since 4.2
 * @see #registerCustomEditor(Class, String, PropertyEditor)
 */
public void addCustomFormatter(Formatter<?> formatter, String... fields) {
	FormatterPropertyEditorAdapter adapter = new FormatterPropertyEditorAdapter(formatter);
	Class<?> fieldType = adapter.getFieldType();
	if (ObjectUtils.isEmpty(fields)) {
		getPropertyEditorRegistry().registerCustomEditor(fieldType, adapter);
	}
	else {
		for (String field : fields) {
			getPropertyEditorRegistry().registerCustomEditor(fieldType, field, adapter);
		}
	}
}
 
Example 3
Source File: DataBinder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Add a custom formatter for the field type specified in {@link Formatter} class,
 * applying it to the specified fields only, if any, or otherwise to all fields.
 * <p>Registers a corresponding {@link PropertyEditor} adapter underneath the covers.
 * @param formatter the formatter to add, generically declared for a specific type
 * @param fields the fields to apply the formatter to, or none if to be applied to all
 * @since 4.2
 * @see #registerCustomEditor(Class, String, PropertyEditor)
 */
public void addCustomFormatter(Formatter<?> formatter, String... fields) {
	FormatterPropertyEditorAdapter adapter = new FormatterPropertyEditorAdapter(formatter);
	Class<?> fieldType = adapter.getFieldType();
	if (ObjectUtils.isEmpty(fields)) {
		getPropertyEditorRegistry().registerCustomEditor(fieldType, adapter);
	}
	else {
		for (String field : fields) {
			getPropertyEditorRegistry().registerCustomEditor(fieldType, field, adapter);
		}
	}
}
 
Example 4
Source File: DataBinder.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Add a custom formatter for the field type specified in {@link Formatter} class,
 * applying it to the specified fields only, if any, or otherwise to all fields.
 * <p>Registers a corresponding {@link PropertyEditor} adapter underneath the covers.
 * @param formatter the formatter to add, generically declared for a specific type
 * @param fields the fields to apply the formatter to, or none if to be applied to all
 * @since 4.2
 * @see #registerCustomEditor(Class, String, PropertyEditor)
 */
public void addCustomFormatter(Formatter<?> formatter, String... fields) {
	FormatterPropertyEditorAdapter adapter = new FormatterPropertyEditorAdapter(formatter);
	Class<?> fieldType = adapter.getFieldType();
	if (ObjectUtils.isEmpty(fields)) {
		getPropertyEditorRegistry().registerCustomEditor(fieldType, adapter);
	}
	else {
		for (String field : fields) {
			getPropertyEditorRegistry().registerCustomEditor(fieldType, field, adapter);
		}
	}
}