protected ResponseBuilder createBadRequestResponse(Set<ConstraintViolation<?>> violations) {
        final Map<String, String> responseObj = violations.stream()
                .collect(Collectors.toMap(v -> v.getPropertyPath().toString(), ConstraintViolation::getMessage));

        return Response.status(Response.Status.BAD_REQUEST)
                           .entity(responseObj);
    }
protected ResponseBuilder createBadRequestResponse ( Set < ConstraintViolation < ? > > violations ) { final Map < String , String > responseObj = violations . stream ( ) . collect ( Collectors . toMap ( v -> v . getPropertyPath ( ) . toString ( ) , ConstraintViolation :: getMessage ) ) ; return Response . status ( Response . Status . BAD_REQUEST ) . entity ( responseObj ) ; }
Helper function to create a 400 Bad Request response, containing a JSON map giving details about the violations

@param violations set of occurred constraint violations
@return 400 Bad Request response, containing details on the constraint violations