Top Description Inners Fields Constructors Methods
org.hibernate.validator.internal.metadata.aggregated

public final Class BeanMetaDataImpl<T>

extends Object
implements BeanMetaData<T>
Class Inheritance
All Implemented Interfaces
org.hibernate.validator.internal.metadata.aggregated.BeanMetaData, org.hibernate.validator.internal.metadata.facets.Validatable
Static Imports
org.hibernate.validator.internal.util.CollectionHelper.newHashMap, .CollectionHelper.newHashSet

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.
Authors
Hardy Ferentschik, Gunnar Morling, Kevin Pollet <[email protected]> (C) 2011 SERLI, Chris Beckey <[email protected]>, Guillaume Smet, Marko Bekhta

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
BeanMetaDataImpl.DefaultGroupSequenceContext<T>

Tuple for returning default group sequence, provider and validation order at once.

Field Summary

Modifier and TypeField and Description
private final Set<MetaConstraint<?>>
allMetaConstraints

Set of all constraints for this bean type (defined on any implemented interfaces or super types)

private final Class<T>
beanClass

The root bean class for this meta data.

private volatile BeanDescriptor
beanDescriptor

The bean descriptor for this bean.

private final Set<Cascadable>
cascadedProperties

The cascaded properties of this bean.

private final List<Class<? super T>>
classHierarchyWithoutInterfaces

The class hierarchy for this class starting with the class itself going up the inheritance chain.

private static final List<Class<?>>
DEFAULT_GROUP_SEQUENCE

Represents the "sequence" of just Default.class.

private final List<Class<?>>
defaultGroupSequence

The default groups sequence for this bean class.

private final DefaultGroupSequenceProvider<? super T>
defaultGroupSequenceProvider

The default group sequence provider.

private final boolean
defaultGroupSequenceRedefined

{code true} if the default group sequence is redefined, either via a group sequence redefinition or a group sequence provider.

private final Set<MetaConstraint<?>>
directMetaConstraints

Set of all constraints which are directly defined on the bean or any of the directly implemented interfaces

private final Map<Signature, ExecutableMetaData>
executableMetaDataMap

Contains constrained related meta data for all the constrained methods and constructors of the type represented by this bean meta data.

private final boolean
hasConstraints

Whether there are any constraints or cascades at all.

private static final Log
private final Map<String, PropertyMetaData>
propertyMetaDataMap

Property meta data keyed against the property name

private final List<Class<?>>
resolvedDefaultGroupSequence

The resolved default group sequence.

private final Set<Signature>
unconstrainedExecutables

The set of unconstrained executables of the bean.

private final ValidationOrder
private final ValidationOrderGenerator

Constructor Summary

AccessConstructor and Description
public
BeanMetaDataImpl(Class<T>
The Java type represented by this meta data object.
beanClass
,
List<Class<?>>
The default group sequence.
defaultGroupSequence
,
DefaultGroupSequenceProvider<? super T>
The default group sequence provider if set.
defaultGroupSequenceProvider
,
Set<ConstraintMetaData>
All constraint meta data relating to the represented type.
constraintMetaDataSet
,
ValidationOrderGenerator validationOrderGenerator)

Creates a new BeanMetaDataImpl

Method Summary

Modifier and TypeMethod and Description
private Map<Signature, ExecutableMetaData>
bySignature(Set<ExecutableMetaData> executables)

Builds up the method meta data for this type; each meta-data entry will be stored under the signature of the represented method and all the methods it overrides.

private static BeanDescriptor
createBeanDescriptor(Class<?> beanClass, Set<MetaConstraint<?>> allMetaConstraints, Map<String, PropertyMetaData> propertyMetaDataMap, Map<Signature, ExecutableMetaData> executableMetaDataMap, boolean defaultGroupSequenceRedefined, List<Class<?>> resolvedDefaultGroupSequence)

public Class<T>
public BeanDescriptor
public Set<Cascadable>
getCascadables()

Implements org.hibernate.validator.internal.metadata.facets.Validatable.getCascadables.

Returns the cascaded elements of this validatable, e.g. the properties of a bean or the parameters of a method annotated with @Valid.
public List<Class<? super T>>
private static Set<ConstraintDescriptorImpl<?>>
private static Map<Signature, ConstructorDescriptor>
getConstrainedConstructorsAsDescriptors(Map<Signature, ExecutableMetaData> executableMetaDataMap, boolean defaultGroupSequenceIsRedefined, List<Class<?>> resolvedDefaultGroupSequence)

private static Map<Signature, ExecutableDescriptorImpl>
getConstrainedMethodsAsDescriptors(Map<Signature, ExecutableMetaData> executableMetaDataMap, boolean defaultGroupSequenceIsRedefined, List<Class<?>> resolvedDefaultGroupSequence)

private static Map<String, PropertyDescriptor>
getConstrainedPropertiesAsDescriptors(Map<String, PropertyMetaData> propertyMetaDataMap, boolean defaultGroupSequenceIsRedefined, List<Class<?>> resolvedDefaultGroupSequence)

public List<Class<?>>
getDefaultGroupSequence(T
the bean state.
beanState
)

Implements org.hibernate.validator.internal.metadata.aggregated.BeanMetaData.getDefaultGroupSequence.

Get the composition of the default group sequence.
private static <T> BeanMetaDataImpl.DefaultGroupSequenceContext<T>
getDefaultGroupSequenceData(Class<?> beanClass, List<Class<?>> defaultGroupSequence, DefaultGroupSequenceProvider<? super T> defaultGroupSequenceProvider, ValidationOrderGenerator validationOrderGenerator)

public Iterator<Sequence>
getDefaultValidationSequence(T beanState)

Implements org.hibernate.validator.internal.metadata.aggregated.BeanMetaData.getDefaultValidationSequence.

Returns an iterator over the default validation group sequence as configured through @GroupSequence/@DefaultGroupSequenceProvider.
private Set<MetaConstraint<?>>
public Set<MetaConstraint<?>>
public Set<MetaConstraint<?>>
public PropertyMetaData
getMetaDataFor(String
The property name.
propertyName
)

Implements org.hibernate.validator.internal.metadata.aggregated.BeanMetaData.getMetaDataFor.

Returns constraint-related meta data for the given property of this bean.
public Optional<ExecutableMetaData>
getMetaDataFor(Executable
The executable of interest.
executable
)

Implements org.hibernate.validator.internal.metadata.aggregated.BeanMetaData.getMetaDataFor.

Returns the constraint-related metadata for the given executable of the class represented by this bean metadata.
private static List<Class<?>>
getValidDefaultGroupSequence(Class<?> beanClass, List<Class<?>> groupSequence)

public boolean
hasCascadables()

Implements org.hibernate.validator.internal.metadata.facets.Validatable.hasCascadables.

Returns true if this validatable has at least one cascadable element, false otherwise.
public boolean
hasConstraints()

Implements org.hibernate.validator.internal.metadata.aggregated.BeanMetaData.hasConstraints.

Returns true if the bean class for this bean meta data has any constraints at all, false otherwise.
private boolean
public boolean
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

allMetaConstraintsback to summary
private final Set<MetaConstraint<?>> allMetaConstraints

Set of all constraints for this bean type (defined on any implemented interfaces or super types)

Annotations
@Immutable
beanClassback to summary
private final Class<T> beanClass

The root bean class for this meta data.

beanDescriptorback to summary
private volatile BeanDescriptor beanDescriptor

The bean descriptor for this bean. Lazily created.

cascadedPropertiesback to summary
private final Set<Cascadable> cascadedProperties

The cascaded properties of this bean.

Annotations
@Immutable
classHierarchyWithoutInterfacesback to summary
private final List<Class<? super T>> classHierarchyWithoutInterfaces

The class hierarchy for this class starting with the class itself going up the inheritance chain. Interfaces are not included.

Annotations
@Immutable
DEFAULT_GROUP_SEQUENCEback to summary
private static final List<Class<?>> DEFAULT_GROUP_SEQUENCE

Represents the "sequence" of just Default.class.

defaultGroupSequenceback to summary
private final List<Class<?>> defaultGroupSequence

The default groups sequence for this bean class.

Annotations
@Immutable
defaultGroupSequenceProviderback to summary
private final DefaultGroupSequenceProvider<? super T> defaultGroupSequenceProvider

The default group sequence provider.

See Also
org.hibernate.validator.group.GroupSequenceProvider, DefaultGroupSequenceProvider
defaultGroupSequenceRedefinedback to summary
private final boolean defaultGroupSequenceRedefined

{code true} if the default group sequence is redefined, either via a group sequence redefinition or a group sequence provider.

directMetaConstraintsback to summary
private final Set<MetaConstraint<?>> directMetaConstraints

Set of all constraints which are directly defined on the bean or any of the directly implemented interfaces

Annotations
@Immutable
executableMetaDataMapback to summary
private final Map<Signature, ExecutableMetaData> executableMetaDataMap

Contains constrained related meta data for all the constrained methods and constructors of the type represented by this bean meta data. Keyed by executable, values are an aggregated view on each executable together with all the executables from the inheritance hierarchy with the same signature.

An entry will be stored once under the signature of the represented method and all the methods it overrides (there will only be more than one entry in case of generics in the parameters, e.g. in case of a super-type method foo(T) and an overriding sub-type method foo(String) two entries for the same executable meta-data will be stored).

Annotations
@Immutable
hasConstraintsback to summary
private final boolean hasConstraints

Whether there are any constraints or cascades at all.

LOGback to summary
private static final Log LOG
propertyMetaDataMapback to summary
private final Map<String, PropertyMetaData> propertyMetaDataMap

Property meta data keyed against the property name

Annotations
@Immutable
resolvedDefaultGroupSequenceback to summary
private final List<Class<?>> resolvedDefaultGroupSequence

The resolved default group sequence.

unconstrainedExecutablesback to summary
private final Set<Signature> unconstrainedExecutables

The set of unconstrained executables of the bean. It contains all the relevant signatures, following the same rules as executableMetaDataMap.

Annotations
@Immutable
validationOrderback to summary
private final ValidationOrder validationOrder
validationOrderGeneratorback to summary
private final ValidationOrderGenerator validationOrderGenerator

Constructor Detail

BeanMetaDataImplback to summary
public BeanMetaDataImpl(Class<T> beanClass, List<Class<?>> defaultGroupSequence, DefaultGroupSequenceProvider<? super T> defaultGroupSequenceProvider, Set<ConstraintMetaData> constraintMetaDataSet, ValidationOrderGenerator validationOrderGenerator)

Creates a new BeanMetaDataImpl

Parameters
beanClass:Class<T>

The Java type represented by this meta data object.

defaultGroupSequence:List<Class<?>>

The default group sequence.

defaultGroupSequenceProvider:DefaultGroupSequenceProvider<? super T>

The default group sequence provider if set.

constraintMetaDataSet:Set<ConstraintMetaData>

All constraint meta data relating to the represented type.

Method Detail

bySignatureback to summary
private Map<Signature, ExecutableMetaData> bySignature(Set<ExecutableMetaData> executables)

Builds up the method meta data for this type; each meta-data entry will be stored under the signature of the represented method and all the methods it overrides.

createBeanDescriptorback to summary
private static BeanDescriptor createBeanDescriptor(Class<?> beanClass, Set<MetaConstraint<?>> allMetaConstraints, Map<String, PropertyMetaData> propertyMetaDataMap, Map<Signature, ExecutableMetaData> executableMetaDataMap, boolean defaultGroupSequenceRedefined, List<Class<?>> resolvedDefaultGroupSequence)
getBeanClassback to summary
public Class<T> getBeanClass()

Implements org.hibernate.validator.internal.metadata.aggregated.BeanMetaData.getBeanClass.

Returns:Class<T>

Doc from org.hibernate.validator.internal.metadata.aggregated.BeanMetaData.getBeanClass.

the class of the bean.

Annotations
@Override
getBeanDescriptorback to summary
public BeanDescriptor getBeanDescriptor()

Implements org.hibernate.validator.internal.metadata.aggregated.BeanMetaData.getBeanDescriptor.

Returns:BeanDescriptor

Doc from org.hibernate.validator.internal.metadata.aggregated.BeanMetaData.getBeanDescriptor.

an instance of ElementDescriptor describing the bean this meta data applies for.

Annotations
@Override
getCascadablesback to summary
public Set<Cascadable> getCascadables()

Implements org.hibernate.validator.internal.metadata.facets.Validatable.getCascadables.

Doc from org.hibernate.validator.internal.metadata.facets.Validatable.getCascadables.

Returns the cascaded elements of this validatable, e.g. the properties of a bean or the parameters of a method annotated with @Valid.

Returns:Set<Cascadable>

The cascaded elements of this validatable.

Annotations
@Override
getClassHierarchyback to summary
public List<Class<? super T>> getClassHierarchy()

Implements org.hibernate.validator.internal.metadata.aggregated.BeanMetaData.getClassHierarchy.

Returns:List<Class<? super T>>

Doc from org.hibernate.validator.internal.metadata.aggregated.BeanMetaData.getClassHierarchy.

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.

Annotations
@Override
getClassLevelConstraintsAsDescriptorsback to summary
private static Set<ConstraintDescriptorImpl<?>> getClassLevelConstraintsAsDescriptors(Set<MetaConstraint<?>> constraints)
getConstrainedConstructorsAsDescriptorsback to summary
private static Map<Signature, ConstructorDescriptor> getConstrainedConstructorsAsDescriptors(Map<Signature, ExecutableMetaData> executableMetaDataMap, boolean defaultGroupSequenceIsRedefined, List<Class<?>> resolvedDefaultGroupSequence)
getConstrainedMethodsAsDescriptorsback to summary
private static Map<Signature, ExecutableDescriptorImpl> getConstrainedMethodsAsDescriptors(Map<Signature, ExecutableMetaData> executableMetaDataMap, boolean defaultGroupSequenceIsRedefined, List<Class<?>> resolvedDefaultGroupSequence)
getConstrainedPropertiesAsDescriptorsback to summary
private static Map<String, PropertyDescriptor> getConstrainedPropertiesAsDescriptors(Map<String, PropertyMetaData> propertyMetaDataMap, boolean defaultGroupSequenceIsRedefined, List<Class<?>> resolvedDefaultGroupSequence)
getDefaultGroupSequenceback to summary
public List<Class<?>> getDefaultGroupSequence(T beanState)

Implements org.hibernate.validator.internal.metadata.aggregated.BeanMetaData.getDefaultGroupSequence.

Doc from org.hibernate.validator.internal.metadata.aggregated.BeanMetaData.getDefaultGroupSequence.

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.

Parameters
beanState:T

the bean state.

Returns:List<Class<?>>

a list of classes representing the default group sequence.

Annotations
@Override
getDefaultGroupSequenceDataback to summary
private static <T> BeanMetaDataImpl.DefaultGroupSequenceContext<T> getDefaultGroupSequenceData(Class<?> beanClass, List<Class<?>> defaultGroupSequence, DefaultGroupSequenceProvider<? super T> defaultGroupSequenceProvider, ValidationOrderGenerator validationOrderGenerator)
getDefaultValidationSequenceback to summary
public Iterator<Sequence> getDefaultValidationSequence(T beanState)

Implements org.hibernate.validator.internal.metadata.aggregated.BeanMetaData.getDefaultValidationSequence.

Doc from org.hibernate.validator.internal.metadata.aggregated.BeanMetaData.getDefaultValidationSequence.

Returns an iterator over the default validation group sequence as configured through @GroupSequence/@DefaultGroupSequenceProvider. If this bean type does not re-declare the default validation group sequence, org.hibernate.validator.internal.engine.groups.ValidationOrder#DEFAULT_SEQUENCE will be returned.

Annotations
@Override
getDirectConstraintsback to summary
private Set<MetaConstraint<?>> getDirectConstraints()
getDirectMetaConstraintsback to summary
public Set<MetaConstraint<?>> getDirectMetaConstraints()

Implements org.hibernate.validator.internal.metadata.aggregated.BeanMetaData.getDirectMetaConstraints.

Returns:Set<MetaConstraint<?>>

Doc from org.hibernate.validator.internal.metadata.aggregated.BeanMetaData.getDirectMetaConstraints.

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

Annotations
@Override
getMetaConstraintsback to summary
public Set<MetaConstraint<?>> getMetaConstraints()

Implements org.hibernate.validator.internal.metadata.aggregated.BeanMetaData.getMetaConstraints.

Returns:Set<MetaConstraint<?>>

Doc from org.hibernate.validator.internal.metadata.aggregated.BeanMetaData.getMetaConstraints.

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

Annotations
@Override
getMetaDataForback to summary
public PropertyMetaData getMetaDataFor(String propertyName)

Implements org.hibernate.validator.internal.metadata.aggregated.BeanMetaData.getMetaDataFor.

Doc from org.hibernate.validator.internal.metadata.aggregated.BeanMetaData.getMetaDataFor.

Returns constraint-related meta data for the given property of this bean.

Parameters
propertyName:String

The property name.

Returns:PropertyMetaData

Constraint-related meta data.

Annotations
@Override
getMetaDataForback to summary
public Optional<ExecutableMetaData> getMetaDataFor(Executable executable)

Implements org.hibernate.validator.internal.metadata.aggregated.BeanMetaData.getMetaDataFor.

Doc from org.hibernate.validator.internal.metadata.aggregated.BeanMetaData.getMetaDataFor.

Returns the constraint-related metadata for the given executable of the class represented by this bean metadata.

Parameters
executable:Executable

The executable of interest.

Returns:Optional<ExecutableMetaData>

An optional either containing an aggregated view on the constraint related metadata from the given method and all the methods from super-types which it overrides or implements or being empty if the method is not constrained at all.

Annotations
@Override
getValidDefaultGroupSequenceback to summary
private static List<Class<?>> getValidDefaultGroupSequence(Class<?> beanClass, List<Class<?>> groupSequence)
hasCascadablesback to summary
public boolean hasCascadables()

Implements org.hibernate.validator.internal.metadata.facets.Validatable.hasCascadables.

Doc from org.hibernate.validator.internal.metadata.facets.Validatable.hasCascadables.

Returns true if this validatable has at least one cascadable element, false otherwise.

Annotations
@Override
hasConstraintsback to summary
public boolean hasConstraints()

Implements org.hibernate.validator.internal.metadata.aggregated.BeanMetaData.hasConstraints.

Doc from org.hibernate.validator.internal.metadata.aggregated.BeanMetaData.hasConstraints.

Returns true if the bean class for this bean meta data has any constraints at all, false otherwise.

Returns:boolean

true if the bean class for this bean meta data has any constraints at all, false otherwise.

Annotations
@Override
hasDefaultGroupSequenceProviderback to summary
private boolean hasDefaultGroupSequenceProvider()
isDefaultGroupSequenceRedefinedback to summary
public boolean isDefaultGroupSequenceRedefined()

Implements org.hibernate.validator.internal.metadata.aggregated.BeanMetaData.isDefaultGroupSequenceRedefined.

Returns:boolean

Doc from org.hibernate.validator.internal.metadata.aggregated.BeanMetaData.isDefaultGroupSequenceRedefined.

true if the entity redefines the default group sequence, false otherwise.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
org.hibernate.validator.internal.metadata.aggregated back to summary

private Class BeanMetaDataImpl.DefaultGroupSequenceContext<T>

extends Object
Class Inheritance
  • java.lang.Object
  • org.hibernate.validator.internal.metadata.aggregated.BeanMetaDataImpl.DefaultGroupSequenceContext

Tuple for returning default group sequence, provider and validation order at once.

Field Summary

Modifier and TypeField and Description
pack-priv List<Class<?>>
pack-priv DefaultGroupSequenceProvider<? super T>
pack-priv ValidationOrder

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

defaultGroupSequenceback to summary
pack-priv List<Class<?>> defaultGroupSequence
defaultGroupSequenceProviderback to summary
pack-priv DefaultGroupSequenceProvider<? super T> defaultGroupSequenceProvider
validationOrderback to summary
pack-priv ValidationOrder validationOrder

Constructor Detail

DefaultGroupSequenceContextback to summary
private DefaultGroupSequenceContext()