Annotation Interface RangeConstraint


@Retention(RUNTIME) @Target({METHOD,TYPE_USE}) public @interface RangeConstraint
Constrains an element's numeric value to within a certain range.

May be used to annotate any field with a numeric type, such as int, long and double.

Notice that constraints given by the Java type take precedence over this annotation. So, even though it wouldn't be an error to annotate a int field with @RangeConstraint(max = 10_000_000_000D) , the maximum value the field could take would still be restricted by int's maximum value of 2_147_483_647.

Note: to constrain the size of the numeric values in a List<?> or Optional<?>, annotate the type parameter as follows: List<@RangeConstraint Integer> or Optional<@RangeConstraint Integer>.

  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    double
     
    double
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double
     
    static final double
     
  • Field Details

  • Element Details

    • min

      double min
      Returns:
      minimum allowed magnitude for the annotated element.
      Default:
      -1.7976931348623157E308
    • max

      double max
      Returns:
      maximum allowed magnitude for the annotated element.
      Default:
      1.7976931348623157E308