private static void validate(Object o) {
Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
Set<ConstraintViolation<Object>> set = validator.validate(o);
for (ConstraintViolation<Object> constraintViolation : set) {
throw new IllegalArgumentException(constraintViolation.getMessage());
}
}