简体   繁体   English

龙目岛是否支持非空验证?

[英]Does Lombok support not empty validation?

@NonNull only ensures not null, how to validate a collection that is not empty? @NonNull仅确保不为null,如何验证不为空的集合?

@AllArgsConstructor
public class Brand {
    @NonNull
    private String name;
    @NonNull
    // how to ensure not empty?
    private List<Product> products;
}

Lombok doesn't have that kind of annotation (see the full list of supported features). Lombok没有这种注释(请参阅支持的功能的完整列表 )。

You can use another library for that purpose. 您可以为此使用另一个库。 For example, Hibernate Validator supports annotations like @NotNull , @NotEmpty , @Size() among others. 例如, Hibernate验证支持像注解@NotNull@NotEmpty@Size()等等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM