org.hibernate.validator
Class ClassValidator<T>

java.lang.Object
  extended by org.hibernate.validator.ClassValidator<T>
All Implemented Interfaces:
Serializable

public class ClassValidator<T>
extends Object
implements Serializable

Engine that take a bean and check every expressed annotation restrictions

Author:
Gavin King, Emmanuel Bernard
See Also:
Serialized Form

Constructor Summary
  ClassValidator(Class<T> beanClass)
          create the validator engine for this bean type
  ClassValidator(Class<T> beanClass, ResourceBundle resourceBundle)
          create the validator engine for a particular bean class, using a resource bundle for message rendering on violation
protected ClassValidator(Class<T> beanClass, ResourceBundle resourceBundle, Map<XClass,ClassValidator> childClassValidators)
           
protected ClassValidator(XClass beanClass, ResourceBundle resourceBundle, Map<XClass,ClassValidator> childClassValidators)
           
 
Method Summary
 void apply(org.hibernate.mapping.PersistentClass persistentClass)
          apply the registred constraints rules on the hibernate metadata (to be applied on DB schema...)
 void assertValid(T bean)
           
 InvalidValue[] getInvalidValues(T bean)
          apply constraints on a bean instance and return all the failures.
protected  InvalidValue[] getInvalidValues(T bean, Set<Object> circularityState)
          apply constraints on a bean instance and return all the failures.
 InvalidValue[] getInvalidValues(T bean, String propertyName)
          Apply constraints of a particular property on a bean instance and return all the failures.
 InvalidValue[] getPotentialInvalidValues(String propertyName, Object value)
          Apply constraints of a particular property value of a bean type and return all the failures.
 String getPropertyName(XMember member)
           
 boolean hasValidationRules()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassValidator

public ClassValidator(Class<T> beanClass)
create the validator engine for this bean type


ClassValidator

public ClassValidator(Class<T> beanClass,
                      ResourceBundle resourceBundle)
create the validator engine for a particular bean class, using a resource bundle for message rendering on violation


ClassValidator

protected ClassValidator(Class<T> beanClass,
                         ResourceBundle resourceBundle,
                         Map<XClass,ClassValidator> childClassValidators)

ClassValidator

protected ClassValidator(XClass beanClass,
                         ResourceBundle resourceBundle,
                         Map<XClass,ClassValidator> childClassValidators)
Method Detail

hasValidationRules

public boolean hasValidationRules()

getInvalidValues

public InvalidValue[] getInvalidValues(T bean)
apply constraints on a bean instance and return all the failures. if bean is null, an empty array is returned


getInvalidValues

protected InvalidValue[] getInvalidValues(T bean,
                                          Set<Object> circularityState)
apply constraints on a bean instance and return all the failures. if bean is null, an empty array is returned


getInvalidValues

public InvalidValue[] getInvalidValues(T bean,
                                       String propertyName)
Apply constraints of a particular property on a bean instance and return all the failures. Note this is not recursive.


getPotentialInvalidValues

public InvalidValue[] getPotentialInvalidValues(String propertyName,
                                                Object value)
Apply constraints of a particular property value of a bean type and return all the failures. The InvalidValue objects returns return null for InvalidValue#getBean() and InvalidValue#getRootBean() Note this is not recursive.


getPropertyName

public String getPropertyName(XMember member)

apply

public void apply(org.hibernate.mapping.PersistentClass persistentClass)
apply the registred constraints rules on the hibernate metadata (to be applied on DB schema...)

Parameters:
persistentClass - hibernate metadata

assertValid

public void assertValid(T bean)