Package org.dellroad.stuff.validation
Annotation Interface Sorted
@Documented
@Constraint(validatedBy=SortedValidator.class)
@Target({METHOD,FIELD,ANNOTATION_TYPE})
@Retention(RUNTIME)
public @interface Sorted
Validation constraint that checks elements are sorted.
Applies to non-primitive arrays, collections and maps; for maps, the keys are examined.
If any element is null, it is skipped.
-
Optional Element Summary
Modifier and TypeOptional ElementDescriptionClass<? extends Comparator>
Specifies aComparator
to use.Class<?>[]
Class<? extends jakarta.validation.Payload>[]
boolean
Configures whether the sorting should be strict, i.e., whether adjacent equal elements should be disallowed.
-
Element Details
-
message
String message- Default:
- "Collection is not sorted"
-
groups
Class<?>[] groups- Default:
- {}
-
payload
Class<? extends jakarta.validation.Payload>[] payload- Default:
- {}
-
comparator
Class<? extends Comparator> comparatorSpecifies aComparator
to use. If none is specified, the natural sort ordering is used. The class must have a default constructor.- Returns:
- comparator class
- Default:
- java.util.Comparator.class
-
strict
boolean strictConfigures whether the sorting should be strict, i.e., whether adjacent equal elements should be disallowed.- Returns:
- true to disallow equal elements
- Default:
- true
-