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.
漂亮男人2017-05-17 10:05:54
You can just inherit it yourselfjavax.validation.ConstraintValidator
实现一个jsr-303
的注解不就行了, 简单的Set<String> set = new HashSet<>(list);
看list.size == set.size()
巴扎黑2017-05-17 10:05:54
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