春风项目四线(合箱线、总装线)
懒羊羊
2024-01-16 f1d9df303a33ef98066e4bf044b1114e1f3f629d
提交 | 用户 | 时间
fd2207 1 package com.jcdm.common.utils.bean;
2
3 import java.util.Set;
4 import javax.validation.ConstraintViolation;
5 import javax.validation.ConstraintViolationException;
6 import javax.validation.Validator;
7
8 /**
9  * bean对象属性验证
10  * 
11  * @author jc
12  */
13 public class BeanValidators
14 {
15     public static void validateWithException(Validator validator, Object object, Class<?>... groups)
16             throws ConstraintViolationException
17     {
18         Set<ConstraintViolation<Object>> constraintViolations = validator.validate(object, groups);
19         if (!constraintViolations.isEmpty())
20         {
21             throw new ConstraintViolationException(constraintViolations);
22         }
23     }
24 }