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

public Class BeanDescriptorImpl

extends ElementDescriptorImpl
implements BeanDescriptor
Class Inheritance
All Implemented Interfaces
jakarta.validation.metadata.BeanDescriptor, jakarta.validation.metadata.ElementDescriptor
Static Imports
org.hibernate.validator.internal.util.CollectionHelper.newHashSet, .Contracts.assertNotNull, org.hibernate.validator.internal.util.logging.Messages.MESSAGES

Describes a validated bean.
Authors
Emmanuel Bernard, Hardy Ferentschik, Gunnar Morling

Field Summary

Modifier and TypeField and Description
private final Map<Signature, ConstructorDescriptor>
private final Map<Signature, ExecutableDescriptorImpl>
private final Map<String, PropertyDescriptor>

Constructor Summary

AccessConstructor and Description
public
BeanDescriptorImpl(Type beanClass, Set<ConstraintDescriptorImpl<?>> classLevelConstraints, Map<String, PropertyDescriptor> constrainedProperties, Map<Signature, ExecutableDescriptorImpl> constrainedMethods, Map<Signature, ConstructorDescriptor> constrainedConstructors, boolean defaultGroupSequenceRedefined, List<Class<?>> defaultGroupSequence)

Method Summary

Modifier and TypeMethod and Description
public Set<ConstructorDescriptor>
getConstrainedConstructors()

Implements jakarta.validation.metadata.BeanDescriptor.getConstrainedConstructors.

Returns a set with descriptors for the constrained constructors of the bean represented by this descriptor.
public Set<MethodDescriptor>
getConstrainedMethods(MethodType
method type to consider
methodType
,
MethodType...
remaining optional method types to consider
methodTypes
)

Implements jakarta.validation.metadata.BeanDescriptor.getConstrainedMethods.

Returns a set with descriptors for the constrained methods of the bean represented by this descriptor.
public final Set<PropertyDescriptor>
getConstrainedProperties()

Implements jakarta.validation.metadata.BeanDescriptor.getConstrainedProperties.

Returns a set of property descriptors having at least one constraint defined or marked as cascaded (Valid).
public ConstructorDescriptor
getConstraintsForConstructor(Class<?>...
the parameter types of the constructor
parameterTypes
)

Implements jakarta.validation.metadata.BeanDescriptor.getConstraintsForConstructor.

Returns a constructor descriptor for the given constructor.
public MethodDescriptor
getConstraintsForMethod(String
the name of the method
methodName
,
Class<?>...
the parameter types of the method
parameterTypes
)

Implements jakarta.validation.metadata.BeanDescriptor.getConstraintsForMethod.

Returns a method descriptor for the given method.
public final PropertyDescriptor
getConstraintsForProperty(String
property evaluated
propertyName
)

Implements jakarta.validation.metadata.BeanDescriptor.getConstraintsForProperty.

Returns the property descriptor for a given property.
public final boolean
isBeanConstrained()

Implements jakarta.validation.metadata.BeanDescriptor.isBeanConstrained.

Returns true if the bean involves validation:
  • a constraint is hosted on the bean itself
  • a constraint is hosted on one of the bean properties
  • or a bean property is marked for cascaded validation (Valid)
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from org.hibernate.validator.internal.metadata.descriptor.ElementDescriptorImpl:
findConstraintsgetConstraintDescriptorsgetElementClasshasConstraints

Field Detail

constrainedConstructorsback to summary
private final Map<Signature, ConstructorDescriptor> constrainedConstructors
Annotations
@Immutable
constrainedMethodsback to summary
private final Map<Signature, ExecutableDescriptorImpl> constrainedMethods
Annotations
@Immutable
constrainedPropertiesback to summary
private final Map<String, PropertyDescriptor> constrainedProperties
Annotations
@Immutable

Constructor Detail

BeanDescriptorImplback to summary
public BeanDescriptorImpl(Type beanClass, Set<ConstraintDescriptorImpl<?>> classLevelConstraints, Map<String, PropertyDescriptor> constrainedProperties, Map<Signature, ExecutableDescriptorImpl> constrainedMethods, Map<Signature, ConstructorDescriptor> constrainedConstructors, boolean defaultGroupSequenceRedefined, List<Class<?>> defaultGroupSequence)

Method Detail

getConstrainedConstructorsback to summary
public Set<ConstructorDescriptor> getConstrainedConstructors()

Implements jakarta.validation.metadata.BeanDescriptor.getConstrainedConstructors.

Doc from jakarta.validation.metadata.BeanDescriptor.getConstrainedConstructors.

Returns a set with descriptors for the constrained constructors of the bean represented by this descriptor.

Constrained constructors have at least one parameter or return value constraint or at least one parameter or return value marked for cascaded validation.

Returns:Set<ConstructorDescriptor>

a set with descriptors for the constrained constructor of this bean; will be empty if this bean has no constrained constructor but never null

Annotations
@Override
getConstrainedMethodsback to summary
public Set<MethodDescriptor> getConstrainedMethods(MethodType methodType, MethodType... methodTypes)

Implements jakarta.validation.metadata.BeanDescriptor.getConstrainedMethods.

Doc from jakarta.validation.metadata.BeanDescriptor.getConstrainedMethods.

Returns a set with descriptors for the constrained methods of the bean represented by this descriptor.

Constrained methods have at least one parameter or return value constraint or at least one parameter or return value marked for cascaded validation. Methods of super types are considered.

Only methods matching the given method type(s) are considered.

Parameters
methodType:MethodType

method type to consider

methodTypes:MethodType[]

remaining optional method types to consider

Returns:Set<MethodDescriptor>

a set with descriptors for the constrained methods of this bean; will be empty if this bean has no constrained methods of the considered method type(s) but never null

Annotations
@Override
getConstrainedPropertiesback to summary
public final Set<PropertyDescriptor> getConstrainedProperties()

Implements jakarta.validation.metadata.BeanDescriptor.getConstrainedProperties.

Doc from jakarta.validation.metadata.BeanDescriptor.getConstrainedProperties.

Returns a set of property descriptors having at least one constraint defined or marked as cascaded (Valid).

If no property matches, an empty set is returned. Properties of super types are considered.

Returns:Set<PropertyDescriptor>

the set of PropertyDescriptors for the constraint properties; if there are no constraint properties, the empty set is returned

Annotations
@Override
getConstraintsForConstructorback to summary
public ConstructorDescriptor getConstraintsForConstructor(Class<?>... parameterTypes)

Implements jakarta.validation.metadata.BeanDescriptor.getConstraintsForConstructor.

Doc from jakarta.validation.metadata.BeanDescriptor.getConstraintsForConstructor.

Returns a constructor descriptor for the given constructor.

Returns null if no constructor with the given parameter types exists or the specified constructor neither has parameter or return value constraints nor a parameter or return value marked for cascaded validation.

Parameters
parameterTypes:Class<?>[]

the parameter types of the constructor

Returns:ConstructorDescriptor

a constructor descriptor for the given constructor

Annotations
@Override
getConstraintsForMethodback to summary
public MethodDescriptor getConstraintsForMethod(String methodName, Class<?>... parameterTypes)

Implements jakarta.validation.metadata.BeanDescriptor.getConstraintsForMethod.

Doc from jakarta.validation.metadata.BeanDescriptor.getConstraintsForMethod.

Returns a method descriptor for the given method.

Returns null if no method with the given name and parameter types exists or the specified method neither has parameter or return value constraints nor a parameter or return value marked for cascaded validation. Methods of super types are considered.

Parameters
methodName:String

the name of the method

parameterTypes:Class<?>[]

the parameter types of the method

Returns:MethodDescriptor

a method descriptor for the given method

Annotations
@Override
getConstraintsForPropertyback to summary
public final PropertyDescriptor getConstraintsForProperty(String propertyName)

Implements jakarta.validation.metadata.BeanDescriptor.getConstraintsForProperty.

Doc from jakarta.validation.metadata.BeanDescriptor.getConstraintsForProperty.

Returns the property descriptor for a given property.

Returns null if the property does not exist or has no constraint nor is marked as cascaded (see getConstrainedProperties()) Properties of super types are considered.

Parameters
propertyName:String

property evaluated

Returns:PropertyDescriptor

the property descriptor for a given property

Annotations
@Override
isBeanConstrainedback to summary
public final boolean isBeanConstrained()

Implements jakarta.validation.metadata.BeanDescriptor.isBeanConstrained.

Doc from jakarta.validation.metadata.BeanDescriptor.isBeanConstrained.

Returns true if the bean involves validation:

  • a constraint is hosted on the bean itself
  • a constraint is hosted on one of the bean properties
  • or a bean property is marked for cascaded validation (Valid)

Constrained methods and constructors are ignored.

Returns:boolean

true if the bean involves validation, 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