Skip to content

Ability to associate a Formatter with a class by using the @Formatted annotated [SPR-6013] #10682

@spring-projects-issues

Description

@spring-projects-issues

Keith Donald opened SPR-6013 and commented

As a developer, I would like to be able to conveniently associated a Formatter implementation with a particular object class by simply annotating that class.

Proposal: @Formatted

/**
 * A type that can be formatted as a String for display in a UI.
 * @author Keith Donald
 * @since 3.0
 */
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Formatted {
	
	/**
	 * The Formatter that handles the formatting.
	 */
	Class<?> value();
}
@Formatted(AddressFormatter.class)
public static class Address {
	private String street;
	private String city;
	private String state;
	private String zip;
	private String country;
}

Referenced from: commits 20f5f99, 2381452

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions