javax.validation.ConstraintViolationException wraps a set of constraint violations, currently in the following form:
As the exception's constructors have a parameter of the same type, instantiating it is not as easy as expected:
This problem can be solved by changing the collection type to
The exception then would read as follows:
This makes the exception easier to use for producers, while maintaining simplicity for clients (since getConstraintViolations() still returns a Set<ConstraintViolation<?>>, clients don't have to do deal with the bound wildcard expression).