Class MetaDataBuilder
- java.lang.Object
-
- org.hibernate.validator.internal.metadata.aggregated.MetaDataBuilder
-
- Direct Known Subclasses:
ClassMetaData.Builder,ExecutableMetaData.Builder,ParameterMetaData.Builder,PropertyMetaData.Builder
public abstract class MetaDataBuilder extends Object
BuildsConstraintMetaDatainstances for theConstrainedElementobjects representing one method or property in a type's inheritance hierarchy.- Author:
- Gunnar Morling
-
-
Field Summary
Fields Modifier and Type Field Description protected ConstraintCreationContextconstraintCreationContext
-
Constructor Summary
Constructors Modifier Constructor Description protectedMetaDataBuilder(Class<?> beanClass, ConstraintCreationContext constraintCreationContext)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract booleanaccepts(ConstrainedElement constrainedElement)Whether this builder allows to add the given element or not.protected Set<MetaConstraint<?>>adaptConstraints(ConstrainedElement constrainedElement, Set<MetaConstraint<?>> constraints)Allows specific sub-classes to customize the retrieved constraints.protected Set<MetaConstraint<?>>adaptOriginsAndImplicitGroups(Set<MetaConstraint<?>> constraints)Adapts the given constraints to the given bean type.voidadd(ConstrainedElement constrainedElement)Adds the given element to this builder.abstract ConstraintMetaDatabuild()Creates a new, read-onlyConstraintMetaDataobject with all constraint information related to the method or property represented by this builder.protected Class<?>getBeanClass()Set<MetaConstraint<?>>getContainerElementConstraints()protected Set<MetaConstraint<?>>getDirectConstraints()protected booleanisCascading()
-
-
-
Field Detail
-
constraintCreationContext
protected final ConstraintCreationContext constraintCreationContext
-
-
Constructor Detail
-
MetaDataBuilder
protected MetaDataBuilder(Class<?> beanClass, ConstraintCreationContext constraintCreationContext)
-
-
Method Detail
-
accepts
public abstract boolean accepts(ConstrainedElement constrainedElement)
Whether this builder allows to add the given element or not. This is the case if the specified element relates to the same property or method with which this builder was instantiated.- Parameters:
constrainedElement- The element to check.- Returns:
trueif the given element can be added to this builder,falseotherwise.
-
add
public void add(ConstrainedElement constrainedElement)
Adds the given element to this builder. It must be checked withaccepts(ConstrainedElement)before, whether this is allowed or not.- Parameters:
constrainedElement- The element to add.
-
build
public abstract ConstraintMetaData build()
Creates a new, read-onlyConstraintMetaDataobject with all constraint information related to the method or property represented by this builder.- Returns:
- A
ConstraintMetaDataobject.
-
getDirectConstraints
protected Set<MetaConstraint<?>> getDirectConstraints()
-
getContainerElementConstraints
public Set<MetaConstraint<?>> getContainerElementConstraints()
-
isCascading
protected boolean isCascading()
-
getBeanClass
protected Class<?> getBeanClass()
-
adaptOriginsAndImplicitGroups
protected Set<MetaConstraint<?>> adaptOriginsAndImplicitGroups(Set<MetaConstraint<?>> constraints)
Adapts the given constraints to the given bean type. In case a constraint is defined locally at the bean class the original constraint will be returned without any modifications. If a constraint is defined in the hierarchy (interface or super class) a new constraint will be returned with an origin ofConstraintOrigin.DEFINED_IN_HIERARCHY. If a constraint is defined on an interface, the interface type will additionally be part of the constraint's groups (implicit grouping).- Parameters:
constraints- The constraints that shall be adapted. The constraints themselves will not be altered.- Returns:
- A constraint adapted to the given bean type.
-
adaptConstraints
protected Set<MetaConstraint<?>> adaptConstraints(ConstrainedElement constrainedElement, Set<MetaConstraint<?>> constraints)
Allows specific sub-classes to customize the retrieved constraints.
-
-