Class BeanDescriptorImpl

java.lang.Object
org.hibernate.validator.internal.metadata.descriptor.ElementDescriptorImpl
org.hibernate.validator.internal.metadata.descriptor.BeanDescriptorImpl
All Implemented Interfaces:
BeanDescriptor, ElementDescriptor, Serializable

public class BeanDescriptorImpl extends ElementDescriptorImpl implements BeanDescriptor
Describes a validated bean.
Author:
Emmanuel Bernard, Hardy Ferentschik, Gunnar Morling
See Also:
  • Constructor Details

  • Method Details

    • isBeanConstrained

      public final boolean isBeanConstrained()
      Description copied from interface: BeanDescriptor
      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.

      Specified by:
      isBeanConstrained in interface BeanDescriptor
      Returns:
      true if the bean involves validation, false otherwise
    • getConstraintsForProperty

      public final PropertyDescriptor getConstraintsForProperty(String propertyName)
      Description copied from interface: BeanDescriptor
      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 BeanDescriptor.getConstrainedProperties()) Properties of super types are considered.

      Specified by:
      getConstraintsForProperty in interface BeanDescriptor
      Parameters:
      propertyName - property evaluated
      Returns:
      the property descriptor for a given property
    • getConstrainedProperties

      public final Set<PropertyDescriptor> getConstrainedProperties()
      Description copied from interface: BeanDescriptor
      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.

      Specified by:
      getConstrainedProperties in interface BeanDescriptor
      Returns:
      the set of PropertyDescriptors for the constraint properties; if there are no constraint properties, the empty set is returned
    • getConstraintsForConstructor

      public ConstructorDescriptor getConstraintsForConstructor(Class<?>... parameterTypes)
      Description copied from interface: BeanDescriptor
      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.

      Specified by:
      getConstraintsForConstructor in interface BeanDescriptor
      Parameters:
      parameterTypes - the parameter types of the constructor
      Returns:
      a constructor descriptor for the given constructor
    • getConstrainedConstructors

      public Set<ConstructorDescriptor> getConstrainedConstructors()
      Description copied from interface: BeanDescriptor
      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.

      Specified by:
      getConstrainedConstructors in interface BeanDescriptor
      Returns:
      a set with descriptors for the constrained constructor of this bean; will be empty if this bean has no constrained constructor but never null
    • getConstrainedMethods

      public Set<MethodDescriptor> getConstrainedMethods(MethodType methodType, MethodType... methodTypes)
      Description copied from interface: BeanDescriptor
      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.

      Specified by:
      getConstrainedMethods in interface BeanDescriptor
      Parameters:
      methodType - method type to consider
      methodTypes - remaining optional method types to consider
      Returns:
      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
    • getConstraintsForMethod

      public MethodDescriptor getConstraintsForMethod(String methodName, Class<?>... parameterTypes)
      Description copied from interface: BeanDescriptor
      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.

      Specified by:
      getConstraintsForMethod in interface BeanDescriptor
      Parameters:
      methodName - the name of the method
      parameterTypes - the parameter types of the method
      Returns:
      a method descriptor for the given method
    • toString

      public String toString()
      Overrides:
      toString in class Object