java - Is there any verification annotation to detect duplicate content in the list?
为情所困
为情所困 2017-05-17 10:03:54
0
2
573

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.

为情所困
为情所困

reply all (2)
漂亮男人

You can just inherit it yourselfjavax.validation.ConstraintValidator实现一个jsr-303的注解不就行了, 简单的Set 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

      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!