Class BeanMetaDataImpl<T>
- java.lang.Object
-
- 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 ofValidatorinterface can instantiate an instance of this class and delegate the metadata extraction to it.- Author:
- Hardy Ferentschik, Gunnar Morling, Kevin Pollet <kevin.pollet@serli.com> (C) 2011 SERLI, Chris Beckey <cbeckey@paypal.com>, Guillaume Smet, Marko Bekhta
-
-
Constructor Summary
Constructors Constructor Description BeanMetaDataImpl(Class<T> beanClass, List<Class<?>> defaultGroupSequence, DefaultGroupSequenceProvider<? super T> defaultGroupSequenceProvider, Set<ConstraintMetaData> constraintMetaDataSet, ValidationOrderGenerator validationOrderGenerator)Creates a newBeanMetaDataImpl
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Class<T>getBeanClass()BeanDescriptorgetBeanDescriptor()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.Iterator<Sequence>getDefaultValidationSequence(T beanState)Returns an iterator over the default validation group sequence as configured through@GroupSequence/@DefaultGroupSequenceProvider.Set<MetaConstraint<?>>getDirectMetaConstraints()Set<MetaConstraint<?>>getMetaConstraints()Optional<ExecutableMetaData>getMetaDataFor(Executable executable)Returns the constraint-related metadata for the given executable of the class represented by this bean metadata.PropertyMetaDatagetMetaDataFor(String propertyName)Returns constraint-related meta data for the given property of this bean.booleanhasCascadables()Returnstrueif this validatable has at least one cascadable element,falseotherwise.booleanhasConstraints()Returnstrueif the bean class for this bean meta data has any constraints at all,falseotherwise.booleanisDefaultGroupSequenceRedefined()StringtoString()
-
-
-
Constructor Detail
-
BeanMetaDataImpl
public BeanMetaDataImpl(Class<T> beanClass, List<Class<?>> defaultGroupSequence, DefaultGroupSequenceProvider<? super T> defaultGroupSequenceProvider, Set<ConstraintMetaData> constraintMetaDataSet, ValidationOrderGenerator validationOrderGenerator)
Creates a newBeanMetaDataImpl- 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:
getBeanClassin interfaceBeanMetaData<T>- Returns:
- the class of the bean.
-
hasConstraints
public boolean hasConstraints()
Description copied from interface:BeanMetaDataReturnstrueif the bean class for this bean meta data has any constraints at all,falseotherwise.- Specified by:
hasConstraintsin interfaceBeanMetaData<T>- Returns:
trueif the bean class for this bean meta data has any constraints at all,falseotherwise.
-
getBeanDescriptor
public BeanDescriptor getBeanDescriptor()
- Specified by:
getBeanDescriptorin interfaceBeanMetaData<T>- Returns:
- an instance of
ElementDescriptordescribing the bean this meta data applies for.
-
getCascadables
public Set<Cascadable> getCascadables()
Description copied from interface:ValidatableReturns the cascaded elements of this validatable, e.g. the properties of a bean or the parameters of a method annotated with@Valid.- Specified by:
getCascadablesin interfaceValidatable- Returns:
- The cascaded elements of this validatable.
-
hasCascadables
public boolean hasCascadables()
Description copied from interface:ValidatableReturnstrueif this validatable has at least one cascadable element,falseotherwise.- Specified by:
hasCascadablesin interfaceValidatable
-
getMetaDataFor
public PropertyMetaData getMetaDataFor(String propertyName)
Description copied from interface:BeanMetaDataReturns constraint-related meta data for the given property of this bean.- Specified by:
getMetaDataForin interfaceBeanMetaData<T>- Parameters:
propertyName- The property name.- Returns:
- Constraint-related meta data.
-
getMetaConstraints
public Set<MetaConstraint<?>> getMetaConstraints()
- Specified by:
getMetaConstraintsin interfaceBeanMetaData<T>- Returns:
- A set of
MetaConstraintinstances 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:
getDirectMetaConstraintsin interfaceBeanMetaData<T>- Returns:
- A set of
MetaConstraintinstances 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 Optional<ExecutableMetaData> getMetaDataFor(Executable executable)
Description copied from interface:BeanMetaDataReturns the constraint-related metadata for the given executable of the class represented by this bean metadata.- Specified by:
getMetaDataForin interfaceBeanMetaData<T>- Parameters:
executable- The executable of interest.- Returns:
- 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.
-
getDefaultGroupSequence
public List<Class<?>> getDefaultGroupSequence(T beanState)
Description copied from interface:BeanMetaDataGet 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:
getDefaultGroupSequencein interfaceBeanMetaData<T>- Parameters:
beanState- the bean state.- Returns:
- a list of classes representing the default group sequence.
-
getDefaultValidationSequence
public Iterator<Sequence> getDefaultValidationSequence(T beanState)
Description copied from interface:BeanMetaDataReturns 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,ValidationOrder.DEFAULT_SEQUENCEwill be returned.- Specified by:
getDefaultValidationSequencein interfaceBeanMetaData<T>
-
isDefaultGroupSequenceRedefined
public boolean isDefaultGroupSequenceRedefined()
- Specified by:
isDefaultGroupSequenceRedefinedin interfaceBeanMetaData<T>- Returns:
trueif the entity redefines the default group sequence,falseotherwise.
-
getClassHierarchy
public List<Class<? super T>> getClassHierarchy()
- Specified by:
getClassHierarchyin interfaceBeanMetaData<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.
-
-