Is there a way to pass a variable from a property file to a class annotation?
@MaxPeriod(firstDateField = "startDateFrom", secondDateField = "startDateTo", maxPeriod = "${variable.from.property:31}")
public class ProcessReportFilter {
private LocalDate startDateFrom;
private LocalDate startDateTo;
}
upd: annotation is used in the request object at bean validation
@Target({ElementType.TYPE})
@Retention(RUNTIME)
@Constraint(validatedBy = MaxPeriodValidator.class)
@Repeatable(MaxPeriod.List.class)
public @interface MaxPeriod {
String message() default "Period between {firstDateField} and {secondDateField} must not exceed {maxPeriod} day(-s)";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
String firstDateField();
String secondDateField();
long maxPeriod();
@Target({ElementType.TYPE})
@Retention(RUNTIME)
@interface List {
MaxPeriod[] value();
}
}