Browse Source

Improve @⁠NumberFormat Javadoc

See gh-35742
pull/35814/head
Sam Brannen 2 months ago
parent
commit
ae804cb2d0
  1. 34
      spring-context/src/main/java/org/springframework/format/annotation/NumberFormat.java

34
spring-context/src/main/java/org/springframework/format/annotation/NumberFormat.java

@ -25,18 +25,18 @@ import java.lang.annotation.Target;
/** /**
* Declares that a field or method parameter should be formatted as a number. * Declares that a field or method parameter should be formatted as a number.
* *
* <p>Supports formatting by style or custom pattern string. Can be applied * <p>Supports formatting by style or custom pattern string. Can be applied to
* to any JDK {@code Number} type such as {@code Double} and {@code Long}. * any JDK {@code Number} types such as {@code Double} and {@code Long}.
* *
* <p>For style-based formatting, set the {@link #style} attribute to be the * <p>For style-based formatting, set the {@link #style} attribute to the desired
* desired {@link Style}. For custom formatting, set the {@link #pattern} * {@link Style}. For custom formatting, set the {@link #pattern} attribute to the
* attribute to be the number pattern, such as {@code #, ###.##}. * desired number pattern, such as {@code "#,###.##"}.
* *
* <p>Each attribute is mutually exclusive, so only set one attribute per * <p>Each attribute is mutually exclusive, so only set one attribute per
* annotation instance (the one most convenient one for your formatting needs). * annotation (the one most convenient for your formatting needs). When the
* When the {@link #pattern} attribute is specified, it takes precedence over * {@link #pattern} attribute is specified, it takes precedence over the
* the {@link #style} attribute. When no annotation attributes are specified, * {@link #style} attribute. When no annotation attributes are specified, the
* the default format applied is style-based for either number or currency, * default format applied is style-based for either number or currency,
* depending on the annotated field or method parameter type. * depending on the annotated field or method parameter type.
* *
* @author Keith Donald * @author Keith Donald
@ -50,19 +50,21 @@ import java.lang.annotation.Target;
public @interface NumberFormat { public @interface NumberFormat {
/** /**
* The style pattern to use to format the field. * The style pattern to use to format the field or method parameter.
* <p>Defaults to {@link Style#DEFAULT} for general-purpose number formatting * <p>Defaults to {@link Style#DEFAULT} for general-purpose number formatting
* for most annotated types, except for money types which default to currency * for most annotated types, except for money types which default to currency
* formatting. Set this attribute when you wish to format your field in * formatting.
* accordance with a common style other than the default style. * <p>Set this attribute when you wish to format your field or method parameter
* in accordance with a common style other than the default style.
*/ */
Style style() default Style.DEFAULT; Style style() default Style.DEFAULT;
/** /**
* The custom pattern to use to format the field. * The custom pattern to use to format the field or method parameter.
* <p>Defaults to empty String, indicating no custom pattern String has been specified. * <p>Defaults to an empty String, indicating no custom pattern has been
* Set this attribute when you wish to format your field in accordance with a * specified.
* custom number pattern not represented by a style. * <p>Set this attribute when you wish to format your field or method parameter
* in accordance with a custom number pattern not represented by a style.
*/ */
String pattern() default ""; String pattern() default "";

Loading…
Cancel
Save