Szukałem na @org.hibernate.validator.constaints.NotEmpty
adnotacji:Co ta zagnieżdżona adnotacja robi/dopuszcza?
@Documented
@Constraint(validatedBy = { })
@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER })
@Retention(RUNTIME)
@ReportAsSingleViolation
@NotNull
@Size(min = 1)
public @interface NotEmpty {
String message() default "{org.hibernate.validator.constraints.NotEmpty.message}";
Class<?>[] groups() default { };
Class<? extends Payload>[] payload() default { };
/**
* Defines several {@code @NotEmpty} annotations on the same element.
*/
@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER })
@Retention(RUNTIME)
@Documented
public @interface List {
NotEmpty[] value();
}
}
Jestem zdezorientowany przez ostatnią część:
/**
* Defines several {@code @NotEmpty} annotations on the same element.
*/
@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER })
@Retention(RUNTIME)
@Documented
public @interface List {
NotEmpty[] value();
}
nie jestem pewien, jak to działa, ani w jaki sposób z niego korzystać. Z mojego rozumienia, wszystko pod Java 8 nie pozwala na wielokrotne adnotacje na tym samym elemencie.
Czy ktoś może wyjaśnić?
Jest to podobnie jak zagnieżdżona klasa statyczna lub interfejs zagnieżdżony. Użyj go przez '@ NotEmpty.List'. –