org.hibernate.validator.metadata
Class MethodMetaData

java.lang.Object
  extended by org.hibernate.validator.metadata.MethodMetaData
All Implemented Interfaces:
Iterable<MethodMetaConstraint<?>>

public class MethodMetaData
extends Object
implements Iterable<MethodMetaConstraint<?>>

Represents a method of a Java type and all its associated meta-data relevant in the context of bean validation, for instance the constraints at it's parameters or return value.

Author:
Gunnar Morling

Constructor Summary
MethodMetaData(Method method, List<MethodMetaConstraint<?>> constraints, boolean isCascading)
           
MethodMetaData(Method method, List<ParameterMetaData> parameterMetaData, List<MethodMetaConstraint<?>> returnValueConstraints, boolean isCascading)
          Creates a new method meta data object.
 
Method Summary
 boolean equals(Object obj)
          It is expected that there is exactly one instance of this type for a given method in a type system.
 List<ParameterMetaData> getAllParameterMetaData()
          Returns meta data for all parameters of the represented method.
 Method getMethod()
          The method represented by this meta data object.
 ParameterMetaData getParameterMetaData(int parameterIndex)
          Constraint meta data for the specified parameter.
 int hashCode()
          It is expected that there is exactly one instance of this type for a given method in a type system.
 boolean hasParameterConstraints()
          Whether this method has at least one cascaded parameter or at least one parameter with constraints.
 boolean isCascading()
          Whether cascading validation for the return value of the represented method shall be performed or not.
 boolean isConstrained()
          Whether the represented method is constrained or not.
 Iterator<MethodMetaConstraint<?>> iterator()
          An iterator with the return value constraints of the represented method.
 MethodMetaData merge(MethodMetaData otherMetaData)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MethodMetaData

public MethodMetaData(Method method,
                      List<MethodMetaConstraint<?>> constraints,
                      boolean isCascading)

MethodMetaData

public MethodMetaData(Method method,
                      List<ParameterMetaData> parameterMetaData,
                      List<MethodMetaConstraint<?>> returnValueConstraints,
                      boolean isCascading)
Creates a new method meta data object.

Parameters:
method - The method to represent.
parameterMetaData - A list with parameter meta data. The length must correspond with the number of parameters of the represented method. So this list may be empty returned (in case of a parameterless method), but never null.
returnValueConstraints - The return value constraints of the represented method, if any.
isCascading - Whether a cascaded validation of the represented method's return value shall be performed or not.
Method Detail

getMethod

public Method getMethod()
The method represented by this meta data object.

Returns:
The method represented by this meta data object.

getParameterMetaData

public ParameterMetaData getParameterMetaData(int parameterIndex)
Constraint meta data for the specified parameter.

Parameters:
parameterIndex - The index in this method's parameter array of the parameter of interest.
Returns:
Meta data for the specified parameter. Will never be null.
Throws:
IllegalArgumentException - In case this method doesn't have a parameter with the specified index.

getAllParameterMetaData

public List<ParameterMetaData> getAllParameterMetaData()
Returns meta data for all parameters of the represented method.

Returns:
A list with parameter meta data. The length corresponds to the number of parameters of the method represented by this meta data object, so an empty list may be returned (in case of a parameterless method), but never null.

iterator

public Iterator<MethodMetaConstraint<?>> iterator()
An iterator with the return value constraints of the represented method.

Specified by:
iterator in interface Iterable<MethodMetaConstraint<?>>

isCascading

public boolean isCascading()
Whether cascading validation for the return value of the represented method shall be performed or not.

Returns:
True, if cascading validation for the represented method's return value shall be performed, false otherwise.

isConstrained

public boolean isConstrained()
Whether the represented method is constrained or not. This is the case if it has at least one constrained parameter, at least one parameter marked for cascaded validation, at least one return value constraint or if the return value is marked for cascaded validation.

Returns:
True, if this method is constrained by any means, false otherwise.

hasParameterConstraints

public boolean hasParameterConstraints()
Whether this method has at least one cascaded parameter or at least one parameter with constraints.

Returns:
True, if this method has at least one cascading or constrained parameter, false otherwise.

merge

public MethodMetaData merge(MethodMetaData otherMetaData)

toString

public String toString()
Overrides:
toString in class Object

hashCode

public int hashCode()
It is expected that there is exactly one instance of this type for a given method in a type system. This method is therefore only based on the hash code defined by the represented Method.

Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
It is expected that there is exactly one instance of this type for a given method in a type system. This method is therefore only based on the equality as defined by the represented Method.

Overrides:
equals in class Object


Copyright © 2007-2011 Red Hat Middleware, LLC. All Rights Reserved