@Test public void validator() { Person person = new Person(); person.setName("zhangsan"); try { ParamValidator.validator(person); }catch (Exception e){ System.out.println(e.fillInStackTrace()); } try { System.out.println(new Person().getName()); ParamValidator.validator(new Person()); }catch (Exception e){ System.out.println(e.fillInStackTrace()); } }
public static <T> void validator(T obj) throws ValidatorException { Validator validator = factory.getValidator(); Set<ConstraintViolation<T>> constraintViolations = validator .validate(obj); Iterator<ConstraintViolation<T>> it = constraintViolations .iterator(); while (it.hasNext()) { ConstraintViolation<T> e = it.next(); throw new ValidatorException(e.getMessage()); } }
ParamValidator { public static <T> void validator(T obj) throws ValidatorException { Validator validator = factory.getValidator(); Set<ConstraintViolation<T>> constraintViolations = validator .validate(obj); Iterator<ConstraintViolation<T>> it = constraintViolations .iterator(); while (it.hasNext()) { ConstraintViolation<T> e = it.next(); throw new ValidatorException(e.getMessage()); } } }
ParamValidator { public static <T> void validator(T obj) throws ValidatorException { Validator validator = factory.getValidator(); Set<ConstraintViolation<T>> constraintViolations = validator .validate(obj); Iterator<ConstraintViolation<T>> it = constraintViolations .iterator(); while (it.hasNext()) { ConstraintViolation<T> e = it.next(); throw new ValidatorException(e.getMessage()); } }  }
ParamValidator { public static <T> void validator(T obj) throws ValidatorException { Validator validator = factory.getValidator(); Set<ConstraintViolation<T>> constraintViolations = validator .validate(obj); Iterator<ConstraintViolation<T>> it = constraintViolations .iterator(); while (it.hasNext()) { ConstraintViolation<T> e = it.next(); throw new ValidatorException(e.getMessage()); } }  static void validator(T obj); }
ParamValidator { public static <T> void validator(T obj) throws ValidatorException { Validator validator = factory.getValidator(); Set<ConstraintViolation<T>> constraintViolations = validator .validate(obj); Iterator<ConstraintViolation<T>> it = constraintViolations .iterator(); while (it.hasNext()) { ConstraintViolation<T> e = it.next(); throw new ValidatorException(e.getMessage()); } }  static void validator(T obj);  }