Annotation Interface IntRange


An expression with this type evaluates to an integral value (byte, short, char, int, or long) in the given range. The bounds are inclusive. For example, the following declaration allows the 12 values 0, 1, ..., 11:
@IntRange(from=0, to=11) int month;

If only one of the to and from fields is set, then the other will default to the max/min value of the type of the variable that is annotated. (In other words, the defaults Long.MIN_VALUE and Long.MAX_VALUE are used only for long; appropriate values are used for other types.)

See the Checker Framework Manual:
Constant Value Checker
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    long
    Largest value in the range, inclusive.
    long
    Largest value in the range, inclusive.
  • Element Details

    • from

      long from
      Largest value in the range, inclusive.
      Returns:
      the largest value in the range, inclusive
      Default:
      -9223372036854775808L
    • to

      long to
      Largest value in the range, inclusive.
      Returns:
      the largest value in the range, inclusive
      Default:
      9223372036854775807L