Top Description Inners Fields Constructors Methods
org.hibernate.validator.internal.metadata.descriptor

public Class ConstraintDescriptorImpl<T extends java.lang.annotation.Annotation>

extends Object
implements ConstraintDescriptor<T extends Annotation>, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, jakarta.validation.metadata.ConstraintDescriptor
Static Imports
org.hibernate.validator.internal.util.CollectionHelper.newHashMap, .CollectionHelper.newHashSet, .CollectionHelper.newLinkedHashSet

Describes a single constraint (including its composing constraints).
Authors
Emmanuel Bernard, Hardy Ferentschik, Federico Mancini, Dag Hovland, Guillaume Smet

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
ConstraintDescriptorImpl.ClassIndexWrapper

A wrapper class to keep track for which composing constraints (class and index) a given attribute override applies to.

private static enum
public static enum
ConstraintDescriptorImpl.ConstraintType

The type of a constraint.

Field Summary

Modifier and TypeField and Description
private final ConstraintAnnotationDescriptor<T>
annotationDescriptor

The annotation descriptor - accessing the annotation information has a cost so we do it only once.

private final Set<ConstraintDescriptorImpl<?>>
composingConstraints

The composing constraints for this constraint.

private final CompositionType
compositionType

Type indicating how composing constraints should be combined.

private final ConstraintLocation.ConstraintLocationKind
constraintLocationKind

Describes on which level (TYPE, METHOD, FIELD...) the constraint was defined on.

private final ConstraintDescriptorImpl.ConstraintType
constraintType

The type of this constraint.

private final List<Class<? extends ConstraintValidator<T, ?>>>
constraintValidatorClasses

The set of classes implementing the validation for this constraint.

private final ConstraintOrigin
definedOn

The origin of the constraint.

private final Set<Class<?>>
groups

The groups for which to apply this constraint.

private final int
private final boolean
isReportAsSingleInvalidConstraint

Flag indicating if in case of a composing constraint a single error or multiple errors should be raised.

private static final Log
private final transient List<ConstraintValidatorDescriptor<T>>
matchingConstraintValidatorDescriptors

This field is transient as the implementations of ConstraintValidatorDescriptor might not be serializable.

private static final List<String>
NON_COMPOSING_CONSTRAINT_ANNOTATIONS

A list of annotations which can be ignored when investigating for composing constraints.

private static final int
private final Set<Class<? extends Payload>>
payloads

The specified payload of the constraint.

private static final long
private final ConstraintTarget
validationAppliesTo

The target of the constraint.

private final ValidateUnwrappedValue
valueUnwrapping

The unwrapping behavior defined on the constraint.

Constructor Summary

AccessConstructor and Description
public
ConstraintDescriptorImpl(ConstraintHelper constraintHelper, Constrainable constrainable, ConstraintAnnotationDescriptor<T> annotationDescriptor, ConstraintLocation.ConstraintLocationKind constraintLocationKind, Class<?> implicitGroup, ConstraintOrigin definedOn, ConstraintDescriptorImpl.ConstraintType externalConstraintType)

public
ConstraintDescriptorImpl(ConstraintHelper constraintHelper, Constrainable constrainable, ConstraintAnnotationDescriptor<T> annotationDescriptor, ConstraintLocation.ConstraintLocationKind constraintLocationKind)

public

Method Summary

Modifier and TypeMethod and Description
private void
private static Set<Class<?>>
buildGroupSet(ConstraintAnnotationDescriptor<?> annotationDescriptor, Class<?> implicitGroup)

private static Set<Class<? extends Payload>>
private <U extends Annotation> ConstraintDescriptorImpl<U>
createComposingConstraintDescriptor(ConstraintHelper constraintHelper, Constrainable constrainable, Map<ConstraintDescriptorImpl.ClassIndexWrapper, Map<String, Object>> overrideParameters, int index, U constraintAnnotation, ConstraintDescriptorImpl.ConstraintType constraintType)

private ConstraintDescriptorImpl.ConstraintType

Returns:

The type of this constraint
determineConstraintType
(Class<? extends Annotation> constraintAnnotationType, Constrainable
The annotated member
constrainable
,
boolean
Whether the constraint has at least one generic validator or not
hasGenericValidators
,
boolean
Whether the constraint has a cross-parameter validator
hasCrossParameterValidator
,
ConstraintDescriptorImpl.ConstraintType
constraint type as derived from external context, e.g. for constraints declared in XML via <return-value/gt;
externalConstraintType
)

Determines the type of this constraint.

private static ConstraintTarget
private static ValidateUnwrappedValue
determineValueUnwrapping(Set<Class<? extends Payload>> payloads, Constrainable constrainable, Class<? extends Annotation> annotationType)

private void
ensureAttributeIsOverridable(Method m, OverridesAttribute overridesAttribute, String overridesAttributeName)

public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public T
getAnnotation()

Implements jakarta.validation.metadata.ConstraintDescriptor.getAnnotation.

Returns the annotation describing the constraint declaration.
public ConstraintAnnotationDescriptor<T>
public Class<T>
public Map<String, Object>
getAttributes()

Implements jakarta.validation.metadata.ConstraintDescriptor.getAttributes.

Returns a map containing the annotation attribute names as keys and the annotation attribute values as value.
public Set<ConstraintDescriptorImpl<?>>
public Set<ConstraintDescriptor<?>>
getComposingConstraints()

Implements jakarta.validation.metadata.ConstraintDescriptor.getComposingConstraints.

Return a set of composing ConstraintDescriptors where each descriptor describes a composing constraint.
public CompositionType

Returns:

the compositionType
getCompositionType
()

public ConstraintLocation.ConstraintLocationKind
public ConstraintDescriptorImpl.ConstraintType
public List<Class<? extends ConstraintValidator<T, ?>>>
getConstraintValidatorClasses()

Implements jakarta.validation.metadata.ConstraintDescriptor.getConstraintValidatorClasses.

List of the constraint validation implementation classes.
public ConstraintOrigin
public Set<Class<?>>
getGroups()

Implements jakarta.validation.metadata.ConstraintDescriptor.getGroups.

The set of groups the constraint is applied on.
public List<ConstraintValidatorDescriptor<T>>

Returns:

The constraint validator descriptors applying to type of this constraint.
getMatchingConstraintValidatorDescriptors
()

Return all constraint validator descriptors (either generic or cross-parameter) which are registered for the constraint of this descriptor.

public String
public Set<Class<? extends Payload>>
getPayload()

Implements jakarta.validation.metadata.ConstraintDescriptor.getPayload.

The set of payload the constraint hosts.
public ConstraintTarget
getValidationAppliesTo()

Implements jakarta.validation.metadata.ConstraintDescriptor.getValidationAppliesTo.

The ConstraintTarget value of validationAppliesTo if the constraint hosts it or null otherwise.
public ValidateUnwrappedValue
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
public boolean
private Set<ConstraintDescriptorImpl<?>>
private CompositionType
private Map<ConstraintDescriptorImpl.ClassIndexWrapper, Map<String, Object>>
private static <P> P
run(PrivilegedAction<P> action)

Runs the given privileged action, using a privileged block if required.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public <U> U
unwrap(Class<U>
the class of the object to be returned
type
)

Implements jakarta.validation.metadata.ConstraintDescriptor.unwrap.

Returns an instance of the specified type allowing access to provider-specific APIs.
private void
validateComposingConstraintTypes()

Asserts that this constraint and all its composing constraints share the same constraint type (generic or cross-parameter).

private void
validateCrossParameterConstraintType(Constrainable constrainable, boolean hasCrossParameterValidator)

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait