class Person{
//insert some validation annotation here to make sure that list CANNOT contain null entry
private List<String> addressList;
//rest of the code
}
我需要验证以确保addressList不能包含任何空值。
答案 0 :(得分:0)
您可以使用addressList的javax.validation.constraints.NotNull注释来设置限制,不应该为null。 请参阅https://docs.oracle.com/javaee/6/api/javax/validation/constraints/NotNull.html