Top Description Methods
javax.validation.metadata

public Interface BeanDescriptor

extends ElementDescriptor
Imports
java.util.Set, javax.validation.Valid

Describes a constrained Java Bean and the constraints associated to it. All objects returned by the methods of this descriptor (and associated objects including ConstraintDescriptors) are immutable.
Authors
Emmanuel Bernard, Gunnar Morling

Method Summary

Modifier and TypeMethod and Description
public Set<ConstructorDescriptor>

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
getConstrainedConstructors
()

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

public Set<MethodDescriptor>

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
getConstrainedMethods
(MethodType
method type to consider
methodType
,
MethodType...
remaining optional method types to consider
methodTypes
)

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

public Set<PropertyDescriptor>

Returns:

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

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

public ConstructorDescriptor

Returns:

a constructor descriptor for the given constructor
getConstraintsForConstructor
(Class<?>...
the parameter types of the constructor
parameterTypes
)

Returns a constructor descriptor for the given constructor.

public MethodDescriptor

Returns:

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

Returns a method descriptor for the given method.

public PropertyDescriptor

Returns:

the property descriptor for a given property
getConstraintsForProperty
(String
property evaluated
propertyName
)

Returns the property descriptor for a given property.

public boolean

Returns:

true if the bean involves validation, false otherwise
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)
Inherited from javax.validation.metadata.ElementDescriptor:
findConstraintsgetConstraintDescriptorsgetElementClasshasConstraints

Method Detail

getConstrainedConstructorsback to summary
public Set<ConstructorDescriptor> 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

Since
1.1
getConstrainedMethodsback to summary
public Set<MethodDescriptor> getConstrainedMethods(MethodType methodType, MethodType... methodTypes)

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

Since
1.1
getConstrainedPropertiesback to summary
public Set<PropertyDescriptor> 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

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

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

Since
1.1
getConstraintsForMethodback to summary
public MethodDescriptor getConstraintsForMethod(String methodName, Class<?>... parameterTypes)

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

Exceptions
IllegalArgumentException:
if methodName is null
Since
1.1
getConstraintsForPropertyback to summary
public PropertyDescriptor getConstraintsForProperty(String propertyName)

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

Exceptions
IllegalArgumentException:
if propertyName is null
isBeanConstrainedback to summary
public boolean 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