javax.validation.metadata
Interface ElementDescriptor

All Known Subinterfaces:
BeanDescriptor, ConstructorDescriptor, MethodDescriptor, ParameterDescriptor, PropertyDescriptor, ReturnValueDescriptor

public interface ElementDescriptor

Describes a validated element (class, property, method etc.).

Author:
Emmanuel Bernard, Hardy Ferentschik, Gunnar Morling

Nested Class Summary
static interface ElementDescriptor.ConstraintFinder
          Declare restrictions on retrieved constraints.
static class ElementDescriptor.Kind
          The kind of an ElementDescriptor.
 
Method Summary
<T extends ElementDescriptor>
T
as(Class<T> descriptorType)
          Narrows the type of this descriptor down to the given type.
 ElementDescriptor.ConstraintFinder findConstraints()
          Find constraints and potentially restricts them to certain criteria.
 Set<ConstraintDescriptor<?>> getConstraintDescriptors()
          Return all constraint descriptors for this element in the class hierarchy or an empty Set if none are present.
 Class<?> getElementClass()
           
 ElementDescriptor.Kind getKind()
          Returns the kind of this descriptor.
 boolean hasConstraints()
           
 

Method Detail

hasConstraints

boolean hasConstraints()
Returns:
Return true if at least one constraint declaration is present for this element in the class hierarchy, false otherwise.

getElementClass

Class<?> getElementClass()
Returns:
Statically defined returned type.

getConstraintDescriptors

Set<ConstraintDescriptor<?>> getConstraintDescriptors()
Return all constraint descriptors for this element in the class hierarchy or an empty Set if none are present.

Returns:
Set of constraint descriptors for this element

findConstraints

ElementDescriptor.ConstraintFinder findConstraints()
Find constraints and potentially restricts them to certain criteria.

Returns:
ConstraintFinder object.

getKind

ElementDescriptor.Kind getKind()
Returns the kind of this descriptor.

Returns:
The kind of this descriptor.

as

<T extends ElementDescriptor> T as(Class<T> descriptorType)
Narrows the type of this descriptor down to the given type. The type should be checked before by calling getKind().

Type Parameters:
T - The type to narrow down to.
Parameters:
descriptorType - Class object representing the descriptor type to narrow down to.
Returns:
This descriptor narrowed down to the given type.
Throws:
ClassCastException - If this descriptor is not assignable to the type T.


Copyright © 2007-2012. All Rights Reserved.