Annotation Type Range


  • @Documented
    @Retention(CLASS)
    @Target(TYPE_USE)
    public @interface Range
    An annotation which allows to specify for integral type (byte, char, short, int, long) an allowed values range. Applying this annotation to other types is not correct.

    Example:

    public @Range(from = 0, to = Integer.MAX_VALUE) int length() {
       return this.length; // returns a non-negative integer
     }
    Since:
    17.0.0
    • Required Element Summary

      Required Elements 
      Modifier and Type Required Element Description
      long from  
      long to  
    • Element Detail

      • from

        long from
        Returns:
        minimal allowed value (inclusive)
      • to

        long to
        Returns:
        maximal allowed value (inclusive)