javax.validation.metadata
Interface BeanDescriptor

All Superinterfaces:
ElementDescriptor

public interface BeanDescriptor
extends ElementDescriptor

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.

Author:
Emmanuel Bernard, Gunnar Morling

Nested Class Summary
 
Nested classes/interfaces inherited from interface javax.validation.metadata.ElementDescriptor
ElementDescriptor.ConstraintFinder, ElementDescriptor.Kind
 
Method Summary
 Set<ConstructorDescriptor> getConstrainedConstructors()
          Returns a set with descriptors for the constrained constructors of the type represented by this descriptor.
 Set<MethodDescriptor> getConstrainedMethods()
          Returns a set with descriptors for the constrained methods of the type represented by this descriptor.
 Set<PropertyDescriptor> getConstrainedProperties()
          Returns a set of property descriptors having at least one constraint defined or marked as cascaded (@Valid).
 ConstructorDescriptor getConstraintsForConstructor(Class<?>... parameterTypes)
          Returns a constructor descriptor for the given constructor.
 MethodDescriptor getConstraintsForMethod(String methodName, Class<?>... parameterTypes)
          Returns a method descriptor for the given method.
 PropertyDescriptor getConstraintsForProperty(String propertyName)
          Return the property descriptor for a given property.
 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 a bean property is marked for cascaded validation (@Valid) a constraint is hosted on the return value or a method parameter of one of the bean's methods or the return value or a method parameter of one of the bean's methods is marked for cascaded validation (@Valid)
 
Methods inherited from interface javax.validation.metadata.ElementDescriptor
as, findConstraints, getConstraintDescriptors, getElementClass, getKind, hasConstraints
 

Method Detail

isBeanConstrained

boolean isBeanConstrained()
Returns true if the bean involves validation:

Returns:
true if the bean involves validation, false otherwise.

getConstraintsForProperty

PropertyDescriptor getConstraintsForProperty(String propertyName)
Return the property descriptor for a given property. Return null if the property does not exist or has no constraint nor is marked as cascaded (see getConstrainedProperties() )

Parameters:
propertyName - property evaluated
Returns:
the property descriptor for a given property.
Throws:
IllegalArgumentException - if propertyName is null

getConstrainedProperties

Set<PropertyDescriptor> getConstrainedProperties()
Returns a set of property descriptors having at least one constraint defined or marked as cascaded (@Valid). If not property matches, an empty set is returned.

Returns:
Returns the set of PropertyDescriptors for the constraint properties. If there are no constraint properties the empty set is returned

getConstraintsForMethod

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.

Parameters:
methodName - The name of the method.
parameterTypes - The parameter types of the method.
Returns:
A method descriptor for the given method.
Throws:
IllegalArgumentException - if methodName is null

getConstrainedMethods

Set<MethodDescriptor> getConstrainedMethods()
Returns a set with descriptors for the constrained methods of the type represented by this descriptor. Constrained are all those methods which have at least one parameter or return value constraint or at least one parameter or return value marked for cascaded validation.

Returns:
A set with descriptors for the constrained methods of this type. Will be empty if this type has no constrained methods but never null.

getConstraintsForConstructor

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 - The parameter types of the constructor.
Returns:
A constructor descriptor for the given constructor.

getConstrainedConstructors

Set<ConstructorDescriptor> getConstrainedConstructors()
Returns a set with descriptors for the constrained constructors of the type represented by this descriptor. Constrained are all those constructors which have at least one parameter or return value constraint or at least one parameter or return value marked for cascaded validation.

Returns:
A set with descriptors for the constrained constructor of this type. Will be empty if this type has no constrained constructor but never null.


Copyright © 2007-2012. All Rights Reserved.