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

public abstract Class MetaDataBuilder

extends Object
Class Inheritance
Known Direct Subclasses
org.hibernate.validator.internal.metadata.aggregated.ParameterMetaData.Builder, org.hibernate.validator.internal.metadata.aggregated.PropertyMetaData.Builder, org.hibernate.validator.internal.metadata.aggregated.ClassMetaData.Builder, org.hibernate.validator.internal.metadata.aggregated.ExecutableMetaData.Builder
Static Imports
org.hibernate.validator.internal.util.CollectionHelper.newHashSet

Builds ConstraintMetaData instances for the ConstrainedElement objects representing one method or property in a type's inheritance hierarchy.
Author
Gunnar Morling

Field Summary

Modifier and TypeField and Description
private final Class<?>
protected final ConstraintCreationContext
private final Set<MetaConstraint<?>>
private final Set<MetaConstraint<?>>
private boolean

Constructor Summary

AccessConstructor and Description
protected
MetaDataBuilder(Class<?> beanClass, ConstraintCreationContext constraintCreationContext)

Method Summary

Modifier and TypeMethod and Description
public abstract boolean

Returns:

true if the given element can be added to this builder, false otherwise.
accepts
(ConstrainedElement
The element to check.
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.

private <A extends Annotation> MetaConstraint<A>
protected Set<MetaConstraint<?>>

Returns:

A constraint adapted to the given bean type.
adaptOriginsAndImplicitGroups
(Set<MetaConstraint<?>>
The constraints that shall be adapted. The constraints themselves will not be altered.
constraints
)

Adapts the given constraints to the given bean type.

public void
add(ConstrainedElement
The element to add.
constrainedElement
)

Adds the given element to this builder.

public abstract ConstraintMetaData

Returns:

A ConstraintMetaData object.
build
()

Creates a new, read-only ConstraintMetaData object with all constraint information related to the method or property represented by this builder.

private ConstraintOrigin

Returns:

Returns ConstraintOrigin.DEFINED_LOCALLY if the constraint was defined on the root bean, ConstraintOrigin.DEFINED_IN_HIERARCHY otherwise.
definedIn
(Class<?>
The root class. That is the class for which we currently create a BeanMetaData
rootClass
,
Class<?>
The class on which the current constraint is defined on
hierarchyClass
)

protected Class<?>
public Set<MetaConstraint<?>>
protected Set<MetaConstraint<?>>
protected boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

beanClassback to summary
private final Class<?> beanClass
constraintCreationContextback to summary
protected final ConstraintCreationContext constraintCreationContext
containerElementsConstraintsback to summary
private final Set<MetaConstraint<?>> containerElementsConstraints
directConstraintsback to summary
private final Set<MetaConstraint<?>> directConstraints
isCascadingback to summary
private boolean isCascading

Constructor Detail

MetaDataBuilderback to summary
protected MetaDataBuilder(Class<?> beanClass, ConstraintCreationContext constraintCreationContext)

Method Detail

acceptsback to summary
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:ConstrainedElement

The element to check.

Returns:boolean

true if the given element can be added to this builder, false otherwise.

adaptConstraintsback to summary
protected Set<MetaConstraint<?>> adaptConstraints(ConstrainedElement constrainedElement, Set<MetaConstraint<?>> constraints)

Allows specific sub-classes to customize the retrieved constraints.

adaptOriginAndImplicitGroupback to summary
private <A extends Annotation> MetaConstraint<A> adaptOriginAndImplicitGroup(MetaConstraint<A> constraint)
adaptOriginsAndImplicitGroupsback to summary
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 of org.hibernate.validator.internal.metadata.core.ConstraintOrigin#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:Set<MetaConstraint<?>>

The constraints that shall be adapted. The constraints themselves will not be altered.

Returns:Set<MetaConstraint<?>>

A constraint adapted to the given bean type.

addback to summary
public void add(ConstrainedElement constrainedElement)

Adds the given element to this builder. It must be checked with accepts(ConstrainedElement) before, whether this is allowed or not.

Parameters
constrainedElement:ConstrainedElement

The element to add.

buildback to summary
public abstract ConstraintMetaData build()

Creates a new, read-only ConstraintMetaData object with all constraint information related to the method or property represented by this builder.

Returns:ConstraintMetaData

A ConstraintMetaData object.

definedInback to summary
private ConstraintOrigin definedIn(Class<?> rootClass, Class<?> hierarchyClass)
Parameters
rootClass:Class<?>

The root class. That is the class for which we currently create a BeanMetaData

hierarchyClass:Class<?>

The class on which the current constraint is defined on

Returns:ConstraintOrigin

Returns ConstraintOrigin.DEFINED_LOCALLY if the constraint was defined on the root bean, ConstraintOrigin.DEFINED_IN_HIERARCHY otherwise.

getBeanClassback to summary
protected Class<?> getBeanClass()
getContainerElementConstraintsback to summary
public Set<MetaConstraint<?>> getContainerElementConstraints()
getDirectConstraintsback to summary
protected Set<MetaConstraint<?>> getDirectConstraints()
isCascadingback to summary
protected boolean isCascading()