This problem comes from the typing of the constructor of javax.validation.ConstraintViolationException
. It accepts Set<ConstraintViolation<?>>
as argument.
While it's very easy to get a set of ConstraintViolation<X> where X is a concrete type, it seems impossible to get a set of "ConstraintViolation<?>" from any well-typed API. And it is not possible to convert the former to the latter without using some convoluted casts. (Casting to Set<? extends ConstraintViolation<?>>
and then to Set<ConstraintViolation<?>>
.)
So do you guys think the API is wrong or I am wrong (and why)?