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
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
ConstructorDescriptionConstrainedExecutable
(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
Modifier and TypeMethodDescriptionboolean
Returns meta data for all parameters of the represented executable.Set<MetaConstraint<?>>
getParameterMetaData
(int parameterIndex) Constraint meta data for the specified parameter.int
hashCode()
boolean
Whether this executable has at least one cascaded parameter or at least one parameter with constraints or at least one cross-parameter constraint.boolean
Whether the represented executable is constrained or not.boolean
Whether this and the given other executable have the same parameter constraints.merge
(ConstrainedExecutable other) Creates a new constrained executable object by merging this and the given other executable.toString()
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 Details
-
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 Details
-
getParameterMetaData
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
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
-
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 interfaceConstrainedElement
- Overrides:
isConstrained
in classAbstractConstrainedElement
- 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.
-
getCallable
-
toString
- Overrides:
toString
in classAbstractConstrainedElement
-
isEquallyParameterConstrained
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
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:
hashCode
in classAbstractConstrainedElement
-
equals
- Overrides:
equals
in classAbstractConstrainedElement
-