
br.com.jhonsapp.bootstrap.test.validation.TestBeanValidation Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bootstrap-test Show documentation
Show all versions of bootstrap-test Show documentation
A complete architecture for creating and managing tests.
The newest version!
package br.com.jhonsapp.bootstrap.test.validation;
import java.util.Set;
import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
public class TestBeanValidation {
private Validator validator;
private void buildValidatorFactory() {
if(validator == null) {
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
this.validator = factory.getValidator();
}
}
private Set> getValidate( T object) {
buildValidatorFactory();
return validator.validate(object);
}
public boolean isValid(T object) {
return getValidate(object).isEmpty();
}
public boolean hasViolation(T object, int quantity) {
return getValidate(object).size() == quantity;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy