org.hibernate.validator.metadata
Class BeanMetaDataImpl<T>

java.lang.Object
  extended by org.hibernate.validator.metadata.BeanMetaDataImpl<T>
All Implemented Interfaces:
BeanMetaData<T>

public final class BeanMetaDataImpl<T>
extends Object
implements BeanMetaData<T>

This class encapsulates all meta data needed for validation. Implementations of Validator interface can instantiate an instance of this class and delegate the metadata extraction to it.

Author:
Hardy Ferentschik

Constructor Summary
BeanMetaDataImpl(Class<T> beanClass, ConstraintHelper constraintHelper, BeanMetaDataCache beanMetaDataCache)
           
BeanMetaDataImpl(Class<T> beanClass, ConstraintHelper constraintHelper, List<Class<?>> defaultGroupSequence, Map<Class<?>,List<MetaConstraint<T,?>>> constraints, List<Member> cascadedMembers, AnnotationIgnores annotationIgnores, BeanMetaDataCache beanMetaDataCache)
           
 
Method Summary
 boolean defaultGroupSequenceIsRedefined()
           
 Class<T> getBeanClass()
           
 BeanDescriptor getBeanDescriptor()
           
 List<Member> getCascadedMembers()
           
 Set<PropertyDescriptor> getConstrainedProperties()
           
 List<Class<?>> getDefaultGroupSequence()
           
 List<MetaConstraint<T,? extends Annotation>> getMetaConstraintsAsList()
           
 Map<Class<?>,List<MetaConstraint<T,? extends Annotation>>> getMetaConstraintsAsMap()
           
 PropertyDescriptor getPropertyDescriptor(String property)
          Return PropertyDescriptor for the given property.
 boolean isPropertyPresent(String name)
          return true if the property exists on the object even if the property does not host any constraint nor is cascaded
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BeanMetaDataImpl

public BeanMetaDataImpl(Class<T> beanClass,
                        ConstraintHelper constraintHelper,
                        BeanMetaDataCache beanMetaDataCache)

BeanMetaDataImpl

public BeanMetaDataImpl(Class<T> beanClass,
                        ConstraintHelper constraintHelper,
                        List<Class<?>> defaultGroupSequence,
                        Map<Class<?>,List<MetaConstraint<T,?>>> constraints,
                        List<Member> cascadedMembers,
                        AnnotationIgnores annotationIgnores,
                        BeanMetaDataCache beanMetaDataCache)
Method Detail

getBeanClass

public Class<T> getBeanClass()
Specified by:
getBeanClass in interface BeanMetaData<T>
Returns:
the class of the bean.

getBeanDescriptor

public BeanDescriptor getBeanDescriptor()
Specified by:
getBeanDescriptor in interface BeanMetaData<T>
Returns:
an instance of ElementDescriptor describing the bean this meta data applies for.

getCascadedMembers

public List<Member> getCascadedMembers()
Specified by:
getCascadedMembers in interface BeanMetaData<T>
Returns:
A list of all cascaded methods and fields (methods/fields annotated with @Valid).

getMetaConstraintsAsMap

public Map<Class<?>,List<MetaConstraint<T,? extends Annotation>>> getMetaConstraintsAsMap()
Specified by:
getMetaConstraintsAsMap in interface BeanMetaData<T>
Returns:
A map of MetaConstraint instances encapsulating the information of all the constraints defined on the bean mapped to the class in which the constraints is defined.

getMetaConstraintsAsList

public List<MetaConstraint<T,? extends Annotation>> getMetaConstraintsAsList()
Specified by:
getMetaConstraintsAsList in interface BeanMetaData<T>
Returns:
A list of MetaConstraint instances encapsulating the information of all the constraints defined on the bean.

getPropertyDescriptor

public PropertyDescriptor getPropertyDescriptor(String property)
Description copied from interface: BeanMetaData
Return PropertyDescriptor for the given property.

Specified by:
getPropertyDescriptor in interface BeanMetaData<T>
Parameters:
property - the property for which to retrieve the descriptor.
Returns:
Returns the PropertyDescriptor for the given property or null in case the property does not have a descriptor.

isPropertyPresent

public boolean isPropertyPresent(String name)
Description copied from interface: BeanMetaData
return true if the property exists on the object even if the property does not host any constraint nor is cascaded

Specified by:
isPropertyPresent in interface BeanMetaData<T>

getDefaultGroupSequence

public List<Class<?>> getDefaultGroupSequence()
Specified by:
getDefaultGroupSequence in interface BeanMetaData<T>
Returns:
A map mapping defined group sequences to a list of groups.

defaultGroupSequenceIsRedefined

public boolean defaultGroupSequenceIsRedefined()
Specified by:
defaultGroupSequenceIsRedefined in interface BeanMetaData<T>
Returns:
true if the entity redefines the default group sequence, false otherwise.

getConstrainedProperties

public Set<PropertyDescriptor> getConstrainedProperties()
Specified by:
getConstrainedProperties in interface BeanMetaData<T>
Returns:
the property descriptors having at least one constraint defined or which are marked as cascaded (@Valid).

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2007-2010 Red Hat Middleware, LLC. All Rights Reserved