I am working on develop a custom Validation Annotation , and the annotation need to be repeatable.
"Min.List" can meet the needs , and i did the same thing on my own annotation .
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Constraint(validatedBy = ComboValidator.class)
public @interface Combo {
String dependField();
String controlledField();
Class<? extends Releation> relation() default BaseReleation.class;
String message() default "{combo validation}";
Class<?>[] groups() default { };
Class<? extends Payload>[] payload() default {};
/**
* Defines several {@link Combo} annotations on the same element.
*
* @see Combo
*/
@Target({ ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
@Documented
@interface List {
Combo[] value();
}
}
It works.
In my mind, the validator will create different instance for differnt type which need to be validated. So inside the validator,i can get the data from the annotation and store it on type level field. But under the repeatable annotaion circumstances, i notice there is more than one instance created.
So my question is how does the @interface List means and works ?