A certain interface requires the caller to pass a list. A certain string attribute in the object in the list cannot be repeated. Is there such an annotation to quickly determine whether there is duplicate data?
I searched for hibernate verification and found no such thing. How do you generally deal with this problem? If such judgment tests are required in many places, how to write public wheels. Thanks.
You can just inherit it yourself
javax.validation.ConstraintValidator
实现一个jsr-303
的注解不就行了, 简单的Set<String> set = new HashSet<>(list);
看list.size == set.size()
Define an annotation to convert the list into a set. If the zise of the set is smaller than the list, it means there is duplication