For explicit groups I mean
{code:java} @Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER}) @Retention(RUNTIME) @Documented @Repeatable(NotNullOnChange.List.class) @ReportAsSingleViolation @Constraint(validatedBy = {}) @NotNull @ConstraintGroup({Create.class, Modify.class}) @interface NotNullOnChange {
String message() default "{javax.validation.constraints.NotNull.message}"; Class<?>[] groups() default {}; Class<? extends Payload>[] payload() default {}; @Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER}) @Retention(RUNTIME) @Documented @interface List { NotNullOnChange[] value(); } } {code}
This annotation group has explicit group(Create.class, Modify.class), when using this constraint, there is no need to specify the groups attribute,if this annotation used in alot of place, this is a huge convenience to prevent mistakes.
I wrote a demo project for this Full propose here https://github.com/wenerme/hv-annotation-with-group |
|