public <T>List<String> validateBean(T bean,String errIfBeanNull){
  List<String> errors=new ArrayList<String>();
  if (bean == null) {
    errors.add(errIfBeanNull);
    return errors;
  }
  Set<ConstraintViolation<T>> violations=validator.validate(bean);
  for (  ConstraintViolation<T> violation : violations) {
    errors.add(violation.getMessage());
  }
  return errors;
}

public < T > List < String > validateBean ( T bean , String errIfBeanNull ) { List < String > errors = new ArrayList < String > ( ) ; if ( bean == null ) { errors . add ( errIfBeanNull ) ; return errors ; } Set < ConstraintViolation < T > > violations = validator . validate ( bean ) ; for ( ConstraintViolation < T > violation : violations ) { errors . add ( violation . getMessage ( ) ) ; } return errors ; }
validate the bean is not null ; then validate its fields
