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

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

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, Gunnar Morling, Kevin Pollet (C) 2011 SERLI

Nested Class Summary
static class BeanMetaDataImpl.BeanMetaDataBuilder<T>
           
 
Constructor Summary
BeanMetaDataImpl(Class<T> beanClass, List<Class<?>> defaultGroupSequence, DefaultGroupSequenceProvider<? super T> defaultGroupSequenceProvider, Set<ConstraintMetaData> constraintMetaDataSet)
          Creates a new BeanMetaDataImpl
 
Method Summary
 boolean defaultGroupSequenceIsRedefined()
           
 Class<T> getBeanClass()
           
 BeanDescriptor getBeanDescriptor()
           
 Set<Cascadable> getCascadables()
          Returns the cascaded elements of this validatable, e.g.
 List<Class<? super T>> getClassHierarchy()
           
 List<Class<?>> getDefaultGroupSequence(T beanState)
          Get the composition of the default group sequence.
 Set<MetaConstraint<?>> getDirectMetaConstraints()
           
 Set<MetaConstraint<?>> getMetaConstraints()
           
 ExecutableMetaData getMetaDataFor(ExecutableElement executable)
          Returns the constraint-related meta data for the given method of the class represented by this bean meta data.
 PropertyMetaData getMetaDataFor(String propertyName)
          Returns constraint-related meta data for the given property of this bean.
 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,
                        List<Class<?>> defaultGroupSequence,
                        DefaultGroupSequenceProvider<? super T> defaultGroupSequenceProvider,
                        Set<ConstraintMetaData> constraintMetaDataSet)
Creates a new BeanMetaDataImpl

Parameters:
beanClass - The Java type represented by this meta data object.
defaultGroupSequence - The default group sequence.
defaultGroupSequenceProvider - The default group sequence provider if set.
constraintMetaDataSet - All constraint meta data relating to the represented type.
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.

getCascadables

public Set<Cascadable> getCascadables()
Description copied from interface: Validatable
Returns the cascaded elements of this validatable, e.g. the properties of a bean or the parameters of a method annotated with @Valid.

Specified by:
getCascadables in interface Validatable
Returns:
The cascaded elements of this validatable.

getMetaDataFor

public PropertyMetaData getMetaDataFor(String propertyName)
Description copied from interface: BeanMetaData
Returns constraint-related meta data for the given property of this bean.

Specified by:
getMetaDataFor in interface BeanMetaData<T>
Parameters:
propertyName - The property name.
Returns:
Constraint-related meta data or null if no property with the given name exists.

getMetaConstraints

public Set<MetaConstraint<?>> getMetaConstraints()
Specified by:
getMetaConstraints in interface BeanMetaData<T>
Returns:
A set of MetaConstraint instances encapsulating the information of all the constraints defined on the bean. This collection includes constraints from super classes as well

getDirectMetaConstraints

public Set<MetaConstraint<?>> getDirectMetaConstraints()
Specified by:
getDirectMetaConstraints in interface BeanMetaData<T>
Returns:
A set of MetaConstraint instances encapsulating the information of all the constraints defined on the bean directly (including constraints defined on implemented interfaces). It does not contain constraints from super classes or interfaces implemented by super classes

getMetaDataFor

public ExecutableMetaData getMetaDataFor(ExecutableElement executable)
Description copied from interface: BeanMetaData
Returns the constraint-related meta data for the given method of the class represented by this bean meta data.

Specified by:
getMetaDataFor in interface BeanMetaData<T>
Parameters:
executable - The method of interest.
Returns:
An aggregated view on the constraint related meta data from the given method all the methods from super-types which it overrides or implements.

getDefaultGroupSequence

public List<Class<?>> getDefaultGroupSequence(T beanState)
Description copied from interface: BeanMetaData
Get the composition of the default group sequence.

If the bean state is given in parameter and the bean metadata has a default group sequence provider then the dynamic default group sequence composition is returned. In the other cases the default group sequence redefinition specified by BV is used.

Specified by:
getDefaultGroupSequence in interface BeanMetaData<T>
Parameters:
beanState - the bean state.
Returns:
a list of classes representing the default group sequence.

defaultGroupSequenceIsRedefined

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

getClassHierarchy

public List<Class<? super T>> getClassHierarchy()
Specified by:
getClassHierarchy in interface BeanMetaData<T>
Returns:
Returns a list of classes representing the class hierarchy for the entity. The list start with the element itself and goes up the hierarchy chain. Interfaces are not included.

toString

public String toString()
Overrides:
toString in class Object


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