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中不能包含任何空值。
您可以使用javax.validation.constraints.NotNull标注为AddressList中把限制这个不能为空。请参阅https://docs.oracle.com/javaee/6/api/javax/validation/constraints/NotNull.html