@Documented @Constraint(validatedBy={}) @Target(value={METHOD,FIELD,ANNOTATION_TYPE,CONSTRUCTOR,PARAMETER,TYPE_USE}) @Retention(value=RUNTIME) @Repeatable(value=UniqueElements.List.class) public @interface UniqueElements
Collection
is unique, i.e. that we can't find 2 equal elements in
the collection.
For instance, this can be useful with JAX-RS, which always deserializes collections to a list. Thus, duplicates would implicitly and silently be removed when converting it to a set. This constraint allows you to check for duplicates in the list and to raise an error instead.
Copyright © 2019 JBoss by Red Hat. All rights reserved.