春风项目四线(合箱线、总装线)
cl
2024-01-16 749044e9cd94ba864017e0eefb17469cd1f6770d
提交 | 用户 | 时间
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 }