org.hibernate.validator.internal.metadata.raw
Class ConstrainedMethod

java.lang.Object
  extended by org.hibernate.validator.internal.metadata.raw.AbstractConstrainedElement
      extended by org.hibernate.validator.internal.metadata.raw.ConstrainedMethod
All Implemented Interfaces:
Iterable<MetaConstraint<?>>, ConstrainedElement

public class ConstrainedMethod
extends AbstractConstrainedElement

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

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.hibernate.validator.internal.metadata.raw.ConstrainedElement
ConstrainedElement.ConstrainedElementKind
 
Constructor Summary
ConstrainedMethod(ConfigurationSource source, MethodConstraintLocation location, List<ConstrainedParameter> parameterMetaData, Set<MetaConstraint<?>> returnValueConstraints, boolean isCascading)
          Creates a new method meta data object.
ConstrainedMethod(ConfigurationSource source, MethodConstraintLocation location, Set<MetaConstraint<?>> returnValueConstraints, boolean isCascading)
          Creates a new method meta data object for a parameter-less method.
 
Method Summary
 List<ConstrainedParameter> getAllParameterMetaData()
          Returns meta data for all parameters of the represented method.
 MethodConstraintLocation getLocation()
          Returns the location of this constrained element.
 ConstrainedParameter getParameterMetaData(int parameterIndex)
          Constraint meta data for the specified parameter.
 boolean hasParameterConstraints()
          Whether this method has at least one cascaded parameter or at least one parameter with constraints.
 boolean isConstrained()
          Whether the represented method is constrained or not.
 boolean isGetterMethod()
          Whether the represented method is a JavaBeans getter method or not.
 String toString()
           
 
Methods inherited from class org.hibernate.validator.internal.metadata.raw.AbstractConstrainedElement
equals, getConstraints, getKind, getSource, hashCode, isCascading, iterator
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConstrainedMethod

public ConstrainedMethod(ConfigurationSource source,
                         MethodConstraintLocation location,
                         Set<MetaConstraint<?>> returnValueConstraints,
                         boolean isCascading)
Creates a new method meta data object for a parameter-less method.

Parameters:
source - The source of meta data.
location - The location of the represented method.
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.

ConstrainedMethod

public ConstrainedMethod(ConfigurationSource source,
                         MethodConstraintLocation location,
                         List<ConstrainedParameter> parameterMetaData,
                         Set<MetaConstraint<?>> returnValueConstraints,
                         boolean isCascading)
Creates a new method meta data object.

Parameters:
source - The source of meta data.
location - The location of the represented method.
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 (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

getLocation

public MethodConstraintLocation getLocation()
Description copied from interface: ConstrainedElement
Returns the location of this constrained element.

Specified by:
getLocation in interface ConstrainedElement
Overrides:
getLocation in class AbstractConstrainedElement
Returns:
The location of this constrained element.

getParameterMetaData

public ConstrainedParameter 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<ConstrainedParameter> 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.

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.

Specified by:
isConstrained in interface ConstrainedElement
Overrides:
isConstrained in class AbstractConstrainedElement
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.

isGetterMethod

public boolean isGetterMethod()
Whether the represented method is a JavaBeans getter method or not.

Returns:
True, if this method is a getter method, false otherwise.

toString

public String toString()
Overrides:
toString in class AbstractConstrainedElement


Copyright © 2012 Oracle Corporation. All Rights Reserved.