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

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

public class ConstrainedExecutable
extends AbstractConstrainedElement

Represents a method or constructor 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
 
Field Summary
 
Fields inherited from class org.hibernate.validator.internal.metadata.raw.AbstractConstrainedElement
constraints, groupConversions, isCascading, location, source
 
Constructor Summary
ConstrainedExecutable(ConfigurationSource source, ExecutableConstraintLocation location, List<ConstrainedParameter> parameterMetaData, Set<MetaConstraint<?>> crossParameterConstraints, Set<MetaConstraint<?>> returnValueConstraints, Map<Class<?>,Class<?>> groupConversions, boolean isCascading)
          Creates a new executable meta data object.
ConstrainedExecutable(ConfigurationSource source, ExecutableConstraintLocation location, Set<MetaConstraint<?>> returnValueConstraints, boolean isCascading)
          Creates a new executable meta data object for a parameter-less executable.
 
Method Summary
 List<ConstrainedParameter> getAllParameterMetaData()
          Returns meta data for all parameters of the represented executable.
 Set<MetaConstraint<?>> getCrossParameterConstraints()
           
 ExecutableConstraintLocation getLocation()
          Returns the location of this constrained element.
 ConstrainedParameter getParameterMetaData(int parameterIndex)
          Constraint meta data for the specified parameter.
 boolean hasParameterConstraints()
          Whether this executable has at least one cascaded parameter or at least one parameter with constraints or at least one cross-parameter constraint.
 boolean isConstrained()
          Whether the represented executable is constrained or not.
 boolean isEquallyParameterConstrained(ConstrainedExecutable other)
          Whether this and the given other executable have the same parameter constraints.
 boolean isGetterMethod()
          Whether the represented executable is a JavaBeans getter executable or not.
 ConstrainedExecutable merge(ConstrainedExecutable other)
          Creates a new constrained executable object by merging this and the given other executable.
 String toString()
           
 
Methods inherited from class org.hibernate.validator.internal.metadata.raw.AbstractConstrainedElement
equals, getConstraints, getGroupConversions, getKind, hashCode, isCascading, iterator
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConstrainedExecutable

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

Parameters:
source - The source of meta data.
location - The location of the represented executable.
returnValueConstraints - The return value constraints of the represented executable, if any.
isCascading - Whether a cascaded validation of the represented executable's return value shall be performed or not.

ConstrainedExecutable

public ConstrainedExecutable(ConfigurationSource source,
                             ExecutableConstraintLocation location,
                             List<ConstrainedParameter> parameterMetaData,
                             Set<MetaConstraint<?>> crossParameterConstraints,
                             Set<MetaConstraint<?>> returnValueConstraints,
                             Map<Class<?>,Class<?>> groupConversions,
                             boolean isCascading)
Creates a new executable meta data object.

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

getLocation

public ExecutableConstraintLocation 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 executable's parameter array of the parameter of interest.
Returns:
Meta data for the specified parameter. Will never be null.
Throws:
IllegalArgumentException - In case this executable doesn't have a parameter with the specified index.

getAllParameterMetaData

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

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

getCrossParameterConstraints

public Set<MetaConstraint<?>> getCrossParameterConstraints()

isConstrained

public boolean isConstrained()
Whether the represented executable 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 cross-parameter constraint, 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 executable is constrained by any means, false otherwise.

hasParameterConstraints

public boolean hasParameterConstraints()
Whether this executable has at least one cascaded parameter or at least one parameter with constraints or at least one cross-parameter constraint.

Returns:
True, if this executable is parameter-constrained by any means, false otherwise.

isGetterMethod

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

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

toString

public String toString()
Overrides:
toString in class AbstractConstrainedElement

isEquallyParameterConstrained

public boolean isEquallyParameterConstrained(ConstrainedExecutable other)
Whether this and the given other executable have the same parameter constraints.

Parameters:
other - The other executable to check.
Returns:
True if this and the other executable have the same parameter constraints (including cross- parameter constraints and parameter cascades), false otherwise.

merge

public ConstrainedExecutable merge(ConstrainedExecutable other)
Creates a new constrained executable object by merging this and the given other executable. Both executables must have the same location, i.e. represent the same executable on the same type.

Parameters:
other - The executable to merge.
Returns:
A merged executable.


Copyright © 2007-2013 Red Hat, Inc. All Rights Reserved