org.hibernate.validator.internal.engine
Class ValidatorImpl

java.lang.Object
  extended by org.hibernate.validator.internal.engine.ValidatorImpl
All Implemented Interfaces:
javax.validation.Validator, MethodValidator

public class ValidatorImpl
extends Object
implements javax.validation.Validator, MethodValidator

The main Bean Validation class. This is the core processing class of Hibernate Validator.

Author:
Emmanuel Bernard, Hardy Ferentschik, Gunnar Morling, Kevin Pollet (C) 2011 SERLI

Constructor Summary
ValidatorImpl(javax.validation.ConstraintValidatorFactory constraintValidatorFactory, javax.validation.MessageInterpolator messageInterpolator, javax.validation.TraversableResolver traversableResolver, BeanMetaDataManager beanMetaDataManager, boolean failFast)
           
 
Method Summary
 javax.validation.metadata.BeanDescriptor getConstraintsForClass(Class<?> clazz)
           
 TypeDescriptor getConstraintsForType(Class<?> clazz)
          Returns a descriptor providing access to constraint-related meta data for the given type.
<T> T
unwrap(Class<T> type)
           
<T> Set<javax.validation.ConstraintViolation<T>>
validate(T object, Class<?>... groups)
           
<T> Set<MethodConstraintViolation<T>>
validateAllParameters(T object, Method method, Object[] parameterValues, Class<?>... groups)
          Validates all parameters of a given method.
<T> Set<MethodConstraintViolation<T>>
validateParameter(T object, Method method, Object parameterValue, int parameterIndex, Class<?>... groups)
          Validates a given parameter of a given method.
<T> Set<javax.validation.ConstraintViolation<T>>
validateProperty(T object, String propertyName, Class<?>... groups)
           
<T> Set<MethodConstraintViolation<T>>
validateReturnValue(T object, Method method, Object returnValue, Class<?>... groups)
          Validates the return value of a given method.
<T> Set<javax.validation.ConstraintViolation<T>>
validateValue(Class<T> beanType, String propertyName, Object value, Class<?>... groups)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ValidatorImpl

public ValidatorImpl(javax.validation.ConstraintValidatorFactory constraintValidatorFactory,
                     javax.validation.MessageInterpolator messageInterpolator,
                     javax.validation.TraversableResolver traversableResolver,
                     BeanMetaDataManager beanMetaDataManager,
                     boolean failFast)
Method Detail

validate

public final <T> Set<javax.validation.ConstraintViolation<T>> validate(T object,
                                                                       Class<?>... groups)
Specified by:
validate in interface javax.validation.Validator

validateProperty

public final <T> Set<javax.validation.ConstraintViolation<T>> validateProperty(T object,
                                                                               String propertyName,
                                                                               Class<?>... groups)
Specified by:
validateProperty in interface javax.validation.Validator

validateValue

public final <T> Set<javax.validation.ConstraintViolation<T>> validateValue(Class<T> beanType,
                                                                            String propertyName,
                                                                            Object value,
                                                                            Class<?>... groups)
Specified by:
validateValue in interface javax.validation.Validator

validateParameter

public final <T> Set<MethodConstraintViolation<T>> validateParameter(T object,
                                                                     Method method,
                                                                     Object parameterValue,
                                                                     int parameterIndex,
                                                                     Class<?>... groups)
Description copied from interface: MethodValidator
Validates a given parameter of a given method.

Specified by:
validateParameter in interface MethodValidator
Type Parameters:
T - The type hosting the invoked method.
Parameters:
object - The object on which the given method was invoked.
method - The invoked method for which the given parameter shall be validated.
parameterValue - The value provided by the caller for the given method.
parameterIndex - The index of the parameter to be validated within the given method's parameter array.
groups - A - potentially empty - number of validation groups for which the validation shall be performed. The @link Default group will be validated if no group is given.
Returns:
A set with the constraint violations caused by this validation. Will be empty, of no error occurs, but never null.

validateAllParameters

public final <T> Set<MethodConstraintViolation<T>> validateAllParameters(T object,
                                                                         Method method,
                                                                         Object[] parameterValues,
                                                                         Class<?>... groups)
Description copied from interface: MethodValidator
Validates all parameters of a given method.

Specified by:
validateAllParameters in interface MethodValidator
Type Parameters:
T - The type hosting the invoked method.
Parameters:
object - The object on which the given method was invoked.
method - The invoked method for which the given parameter shall be validated.
parameterValues - The values provided by the caller for the given method's parameters.
groups - A - potentially empty - number of validation groups for which the validation shall be performed. The @link Default group will be validated if no group is given.
Returns:
A set with the constraint violations caused by this validation. Will be empty, of no error occurs, but never null.

validateReturnValue

public <T> Set<MethodConstraintViolation<T>> validateReturnValue(T object,
                                                                 Method method,
                                                                 Object returnValue,
                                                                 Class<?>... groups)
Description copied from interface: MethodValidator
Validates the return value of a given method.

Specified by:
validateReturnValue in interface MethodValidator
Type Parameters:
T - The type hosting the invoked method.
Parameters:
object - The object on which the given method was invoked.
method - The invoked method for which the given return value shall be validated.
returnValue - The value returned by the invoked method.
groups - A - potentially empty - number of validation groups for which the validation shall be performed. The @link Default group will be validated if no group is given.
Returns:
A set with the constraint violations caused by this validation. Will be empty, of no error occurs, but never null.

getConstraintsForClass

public final javax.validation.metadata.BeanDescriptor getConstraintsForClass(Class<?> clazz)
Specified by:
getConstraintsForClass in interface javax.validation.Validator

getConstraintsForType

public final TypeDescriptor getConstraintsForType(Class<?> clazz)
Description copied from interface: MethodValidator
Returns a descriptor providing access to constraint-related meta data for the given type.

Specified by:
getConstraintsForType in interface MethodValidator
Parameters:
clazz - The type of interest.
Returns:
A descriptor for the given type, will never be null.

unwrap

public final <T> T unwrap(Class<T> type)
Specified by:
unwrap in interface javax.validation.Validator


Copyright © 2012 Oracle Corporation. All Rights Reserved.