Annotations in Java use constants as parameters. You cannot change them dynamically.
Compilation constants can only be primitives and strings. Check out this link.
IF you want to configure it, you can declare them as static final.
Example:
private static final int MIN_RANGE = 1; private static final int MAX_RANGE = 100;
and then assign in annotations.
@Range(min=MIN_RANGE,max=MAX_RANGE) private String amount;
The value of the annotation attribute must be a constant expression.
source share