Class ConstrainedExecutable
- java.lang.Object
-
- org.hibernate.validator.internal.metadata.raw.AbstractConstrainedElement
-
- 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 its parameters or return value.- Author:
- Gunnar Morling, Guillaume Smet
-
-
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
cascadingMetaDataBuilder, constraints, source, typeArgumentConstraints
-
-
Constructor Summary
Constructors Constructor Description ConstrainedExecutable(ConfigurationSource source, Callable callable, List<ConstrainedParameter> parameterMetaData, Set<MetaConstraint<?>> crossParameterConstraints, Set<MetaConstraint<?>> returnValueConstraints, Set<MetaConstraint<?>> typeArgumentConstraints, CascadingMetaDataBuilder cascadingMetaDataBuilder)Creates a new executable meta data object.ConstrainedExecutable(ConfigurationSource source, Callable callable, Set<MetaConstraint<?>> returnValueConstraints, Set<MetaConstraint<?>> typeArgumentConstraints, CascadingMetaDataBuilder cascadingMetaDataBuilder)Creates a new executable meta data object for a parameter-less executable.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)List<ConstrainedParameter>getAllParameterMetaData()Returns meta data for all parameters of the represented executable.CallablegetCallable()Set<MetaConstraint<?>>getCrossParameterConstraints()ConstrainedParametergetParameterMetaData(int parameterIndex)Constraint meta data for the specified parameter.inthashCode()booleanhasParameterConstraints()Whether this executable has at least one cascaded parameter or at least one parameter with constraints or at least one cross-parameter constraint.booleanisConstrained()Whether the represented executable is constrained or not.booleanisEquallyParameterConstrained(ConstrainedExecutable other)Whether this and the given other executable have the same parameter constraints.ConstrainedExecutablemerge(ConstrainedExecutable other)Creates a new constrained executable object by merging this and the given other executable.StringtoString()-
Methods inherited from class org.hibernate.validator.internal.metadata.raw.AbstractConstrainedElement
getCascadingMetaDataBuilder, getConstraints, getKind, getSource, getTypeArgumentConstraints, iterator
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
ConstrainedExecutable
public ConstrainedExecutable(ConfigurationSource source, Callable callable, Set<MetaConstraint<?>> returnValueConstraints, Set<MetaConstraint<?>> typeArgumentConstraints, CascadingMetaDataBuilder cascadingMetaDataBuilder)
Creates a new executable meta data object for a parameter-less executable.- Parameters:
source- The source of meta data.callable- The represented executable.returnValueConstraints- Type arguments constraints, if any.typeArgumentConstraints- The type argument constraints on the return value of the represented executable, if any.cascadingMetaDataBuilder- The cascaded validation metadata for this element and its container elements.
-
ConstrainedExecutable
public ConstrainedExecutable(ConfigurationSource source, Callable callable, List<ConstrainedParameter> parameterMetaData, Set<MetaConstraint<?>> crossParameterConstraints, Set<MetaConstraint<?>> returnValueConstraints, Set<MetaConstraint<?>> typeArgumentConstraints, CascadingMetaDataBuilder cascadingMetaDataBuilder)
Creates a new executable meta data object.- Parameters:
source- The source of meta data.callable- 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 nevernull.crossParameterConstraints- the cross parameter constraintsreturnValueConstraints- The return value constraints of the represented executable, if any.typeArgumentConstraints- The type argument constraints on the return value of the represented executable, if any.cascadingMetaDataBuilder- The cascaded validation metadata for this element and its container elements.
-
-
Method Detail
-
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:
isConstrainedin interfaceConstrainedElement- Overrides:
isConstrainedin classAbstractConstrainedElement- Returns:
Trueif this executable is constrained by any means,falseotherwise.
-
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,falseotherwise.
-
getCallable
public Callable getCallable()
-
toString
public String toString()
- Overrides:
toStringin classAbstractConstrainedElement
-
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.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classAbstractConstrainedElement
-
equals
public boolean equals(Object obj)
- Overrides:
equalsin classAbstractConstrainedElement
-
-