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, MessageInterpolator interpolator)
          create the validator engine for a particular bean class, using a custom message interpolator for message rendering on violation
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(Class<T> beanClass, ResourceBundle resourceBundle, MessageInterpolator interpolator, Map<org.hibernate.annotations.common.reflection.XClass,ClassValidator> childClassValidators, org.hibernate.annotations.common.reflection.ReflectionManager reflectionManager)
          Not a public API
 
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)
           
static org.hibernate.mapping.Property findPropertyByName(org.hibernate.mapping.PersistentClass associatedClass, String propertyName)
          Retrieve the property by path in a recursive way, including IndetifierProperty in the loop If propertyName is null or empty, the IdentifierProperty is returned
 InvalidValue[] getInvalidValues(T bean)
          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.
 boolean hasValidationRules()
           
 
Methods inherited from class java.lang.Object
equals, 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

public ClassValidator(Class<T> beanClass,
                      MessageInterpolator interpolator)
create the validator engine for a particular bean class, using a custom message interpolator for message rendering on violation


ClassValidator

public ClassValidator(Class<T> beanClass,
                      ResourceBundle resourceBundle,
                      MessageInterpolator interpolator,
                      Map<org.hibernate.annotations.common.reflection.XClass,ClassValidator> childClassValidators,
                      org.hibernate.annotations.common.reflection.ReflectionManager reflectionManager)
Not a public API

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

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.


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)

findPropertyByName

public static org.hibernate.mapping.Property findPropertyByName(org.hibernate.mapping.PersistentClass associatedClass,
                                                                String propertyName)
Retrieve the property by path in a recursive way, including IndetifierProperty in the loop If propertyName is null or empty, the IdentifierProperty is returned



Copyright © 2009. All Rights Reserved.