Top Description Inners Fields Constructors Methods
org.hibernate.validator.internal.engine.validationcontext

pack-priv abstract Class AbstractValidationContext<T>

extends Object
implements BaseBeanValidationContext<T>
Class Inheritance
All Implemented Interfaces
org.hibernate.validator.internal.engine.validationcontext.BaseBeanValidationContext, org.hibernate.validator.internal.engine.validationcontext.ValidationContext
Known Direct Subclasses
org.hibernate.validator.internal.engine.validationcontext.BeanValidationContext, org.hibernate.validator.internal.engine.validationcontext.ParameterExecutableValidationContext, org.hibernate.validator.internal.engine.validationcontext.PropertyValidationContext, org.hibernate.validator.internal.engine.validationcontext.ReturnValueExecutableValidationContext
Imports
java.lang.invoke.MethodHandles, java.util.Collections, .HashSet, .IdentityHashMap, .Iterator, .Map, .Set, jakarta.validation.ConstraintValidatorFactory, .ConstraintViolation, .Path, .TraversableResolver, .ValidationException, .Validator, jakarta.validation.metadata.ConstraintDescriptor, org.hibernate.validator.constraintvalidation.HibernateConstraintValidatorInitializationContext, org.hibernate.validator.internal.engine.MessageInterpolatorContext, org.hibernate.validator.internal.engine.constraintvalidation.ConstraintValidatorContextImpl, .ConstraintValidatorManager, .ConstraintViolationCreationContext, org.hibernate.validator.internal.engine.path.PathImpl, org.hibernate.validator.internal.engine.valuecontext.ValueContext, org.hibernate.validator.internal.metadata.aggregated.BeanMetaData, org.hibernate.validator.internal.metadata.core.MetaConstraint, org.hibernate.validator.internal.metadata.descriptor.ConstraintDescriptorImpl, org.hibernate.validator.internal.util.logging.Log, .LoggerFactory, org.hibernate.validator.internal.util.stereotypes.Lazy, org.hibernate.validator.messageinterpolation.ExpressionLanguageFeatureLevel

Context object keeping track of all required data for a validation call.

We use this object to collect all failing constraints, but also to have access to resources like constraint validator factory, message interpolator, traversable resolver, etc.

Authors
Hardy Ferentschik, Emmanuel Bernard, Gunnar Morling, Guillaume Smet, Marko Bekhta

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class

Field Summary

Modifier and TypeField and Description
private final ConstraintValidatorFactory
constraintValidatorFactory

The constraint factory which should be used in this context.

private final HibernateConstraintValidatorInitializationContext
constraintValidatorInitializationContext

The constraint validator initialization context.

private final ConstraintValidatorManager
constraintValidatorManager

Caches and manages life cycle of constraint validator instances.

private final boolean
disableAlreadyValidatedBeanTracking

Indicates if the tracking of already validated bean should be disabled.

private Set<ConstraintViolation<T>>
failingConstraintViolations

Contains all failing constraints so far.

private static final Log
private Set<AbstractValidationContext.BeanGroupProcessedUnit>
processedGroupUnits

The set of already processed groups per bean (BeanGroupProcessedUnit).

private Map<Object, Set<PathImpl>>
processedPathsPerBean

Maps an object to a list of paths in which it has been validated.

private Set<AbstractValidationContext.BeanPathMetaConstraintProcessedUnit>
processedPathUnits

The set of already processed meta constraints per bean - path (BeanPathMetaConstraintProcessedUnit).

private final T
rootBean

The root bean of the validation.

private final Class<T>
rootBeanClass

The root bean class of the validation.

private final BeanMetaData<T>
rootBeanMetaData

The metadata of the root bean.

private final TraversableResolver
traversableResolver

Allows a JPA provider to decide whether a property should be validated.

protected final ValidatorScopedContext
validatorScopedContext

Context containing all Validator level helpers and configuration properties.

Constructor Summary

AccessConstructor and Description
protected
AbstractValidationContext(ConstraintValidatorManager constraintValidatorManager, ConstraintValidatorFactory constraintValidatorFactory, ValidatorScopedContext validatorScopedContext, TraversableResolver traversableResolver, HibernateConstraintValidatorInitializationContext constraintValidatorInitializationContext, T rootBean, Class<T> rootBeanClass, BeanMetaData<T> rootBeanMetaData, boolean disableAlreadyValidatedBeanTracking)

Method Summary

Modifier and TypeMethod and Description
public void
public ConstraintValidatorContextImpl
protected abstract ConstraintViolation<T>
createConstraintViolation(String messageTemplate, String interpolatedMessage, Path propertyPath, ConstraintDescriptor<?> constraintDescriptor, ValueContext<?, ?> valueContext, ConstraintViolationCreationContext constraintViolationCreationContext)

public ConstraintValidatorFactory
public HibernateConstraintValidatorInitializationContext
public ConstraintValidatorManager
public Set<ConstraintViolation<T>>
private Set<ConstraintViolation<T>>
private Set<AbstractValidationContext.BeanGroupProcessedUnit>
private Map<Object, Set<PathImpl>>
private Set<AbstractValidationContext.BeanPathMetaConstraintProcessedUnit>
public T
public Class<T>
public BeanMetaData<T>
public TraversableResolver
public boolean
private String
interpolate(String messageTemplate, ExpressionLanguageFeatureLevel expressionLanguageFeatureLevel, boolean customViolation, Object validatedValue, ConstraintDescriptor<?> descriptor, Path path, Map<String, Object> messageParameters, Map<String, Object> expressionVariables)

private boolean
private boolean
public boolean
public boolean
public boolean
private boolean
public void
public void
private void
private void
public abstract String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

constraintValidatorFactoryback to summary
private final ConstraintValidatorFactory constraintValidatorFactory

The constraint factory which should be used in this context.

constraintValidatorInitializationContextback to summary
private final HibernateConstraintValidatorInitializationContext constraintValidatorInitializationContext

The constraint validator initialization context.

constraintValidatorManagerback to summary
private final ConstraintValidatorManager constraintValidatorManager

Caches and manages life cycle of constraint validator instances.

disableAlreadyValidatedBeanTrackingback to summary
private final boolean disableAlreadyValidatedBeanTracking

Indicates if the tracking of already validated bean should be disabled.

failingConstraintViolationsback to summary
private Set<ConstraintViolation<T>> failingConstraintViolations

Contains all failing constraints so far.

Annotations
@Lazy
LOGback to summary
private static final Log LOG
processedGroupUnitsback to summary
private Set<AbstractValidationContext.BeanGroupProcessedUnit> processedGroupUnits

The set of already processed groups per bean (BeanGroupProcessedUnit).

Annotations
@Lazy
processedPathsPerBeanback to summary
private Map<Object, Set<PathImpl>> processedPathsPerBean

Maps an object to a list of paths in which it has been validated. The objects are the bean instances.

Annotations
@Lazy
processedPathUnitsback to summary
private Set<AbstractValidationContext.BeanPathMetaConstraintProcessedUnit> processedPathUnits

The set of already processed meta constraints per bean - path (BeanPathMetaConstraintProcessedUnit).

Annotations
@Lazy
rootBeanback to summary
private final T rootBean

The root bean of the validation.

rootBeanClassback to summary
private final Class<T> rootBeanClass

The root bean class of the validation.

rootBeanMetaDataback to summary
private final BeanMetaData<T> rootBeanMetaData

The metadata of the root bean.

traversableResolverback to summary
private final TraversableResolver traversableResolver

Allows a JPA provider to decide whether a property should be validated.

validatorScopedContextback to summary
protected final ValidatorScopedContext validatorScopedContext

Context containing all Validator level helpers and configuration properties.

Constructor Detail

AbstractValidationContextback to summary
protected AbstractValidationContext(ConstraintValidatorManager constraintValidatorManager, ConstraintValidatorFactory constraintValidatorFactory, ValidatorScopedContext validatorScopedContext, TraversableResolver traversableResolver, HibernateConstraintValidatorInitializationContext constraintValidatorInitializationContext, T rootBean, Class<T> rootBeanClass, BeanMetaData<T> rootBeanMetaData, boolean disableAlreadyValidatedBeanTracking)

Method Detail

addConstraintFailureback to summary
public void addConstraintFailure(ValueContext<?, ?> valueContext, ConstraintViolationCreationContext constraintViolationCreationContext, ConstraintDescriptor<?> descriptor)

Implements org.hibernate.validator.internal.engine.validationcontext.ValidationContext.addConstraintFailure.

Annotations
@Override
createConstraintValidatorContextForback to summary
public ConstraintValidatorContextImpl createConstraintValidatorContextFor(ConstraintDescriptorImpl<?> constraintDescriptor, PathImpl path)

Implements org.hibernate.validator.internal.engine.validationcontext.ValidationContext.createConstraintValidatorContextFor.

Annotations
@Override
createConstraintViolationback to summary
protected abstract ConstraintViolation<T> createConstraintViolation(String messageTemplate, String interpolatedMessage, Path propertyPath, ConstraintDescriptor<?> constraintDescriptor, ValueContext<?, ?> valueContext, ConstraintViolationCreationContext constraintViolationCreationContext)
getConstraintValidatorFactoryback to summary
public ConstraintValidatorFactory getConstraintValidatorFactory()

Implements org.hibernate.validator.internal.engine.validationcontext.ValidationContext.getConstraintValidatorFactory.

Annotations
@Override
getConstraintValidatorInitializationContextback to summary
public HibernateConstraintValidatorInitializationContext getConstraintValidatorInitializationContext()

Implements org.hibernate.validator.internal.engine.validationcontext.ValidationContext.getConstraintValidatorInitializationContext.

Annotations
@Override
getConstraintValidatorManagerback to summary
public ConstraintValidatorManager getConstraintValidatorManager()

Implements org.hibernate.validator.internal.engine.validationcontext.ValidationContext.getConstraintValidatorManager.

Annotations
@Override
getFailingConstraintsback to summary
public Set<ConstraintViolation<T>> getFailingConstraints()

Implements org.hibernate.validator.internal.engine.validationcontext.ValidationContext.getFailingConstraints.

Annotations
@Override
getInitializedFailingConstraintViolationsback to summary
private Set<ConstraintViolation<T>> getInitializedFailingConstraintViolations()
getInitializedProcessedGroupUnitsback to summary
private Set<AbstractValidationContext.BeanGroupProcessedUnit> getInitializedProcessedGroupUnits()
getInitializedProcessedPathsPerBeanback to summary
private Map<Object, Set<PathImpl>> getInitializedProcessedPathsPerBean()
getInitializedProcessedPathUnitsback to summary
private Set<AbstractValidationContext.BeanPathMetaConstraintProcessedUnit> getInitializedProcessedPathUnits()
getRootBeanback to summary
public T getRootBean()

Implements org.hibernate.validator.internal.engine.validationcontext.BaseBeanValidationContext.getRootBean.

Annotations
@Override
getRootBeanClassback to summary
public Class<T> getRootBeanClass()

Implements org.hibernate.validator.internal.engine.validationcontext.BaseBeanValidationContext.getRootBeanClass.

Annotations
@Override
getRootBeanMetaDataback to summary
public BeanMetaData<T> getRootBeanMetaData()

Implements org.hibernate.validator.internal.engine.validationcontext.BaseBeanValidationContext.getRootBeanMetaData.

Annotations
@Override
getTraversableResolverback to summary
public TraversableResolver getTraversableResolver()

Implements org.hibernate.validator.internal.engine.validationcontext.BaseBeanValidationContext.getTraversableResolver.

Annotations
@Override
hasMetaConstraintBeenProcessedback to summary
public boolean hasMetaConstraintBeenProcessed(Object bean, Path path, MetaConstraint<?> metaConstraint)

Implements org.hibernate.validator.internal.engine.validationcontext.BaseBeanValidationContext.hasMetaConstraintBeenProcessed.

Annotations
@Override
interpolateback to summary
private String interpolate(String messageTemplate, ExpressionLanguageFeatureLevel expressionLanguageFeatureLevel, boolean customViolation, Object validatedValue, ConstraintDescriptor<?> descriptor, Path path, Map<String, Object> messageParameters, Map<String, Object> expressionVariables)
isAlreadyValidatedForCurrentGroupback to summary
private boolean isAlreadyValidatedForCurrentGroup(Object value, Class<?> group)
isAlreadyValidatedForPathback to summary
private boolean isAlreadyValidatedForPath(Object value, PathImpl path)
isBeanAlreadyValidatedback to summary
public boolean isBeanAlreadyValidated(Object value, Class<?> group, PathImpl path)

Implements org.hibernate.validator.internal.engine.validationcontext.BaseBeanValidationContext.isBeanAlreadyValidated.

Annotations
@Override
isFailFastModeEnabledback to summary
public boolean isFailFastModeEnabled()

Implements org.hibernate.validator.internal.engine.validationcontext.ValidationContext.isFailFastModeEnabled.

Annotations
@Override
isShowValidatedValuesInTraceLogsback to summary
public boolean isShowValidatedValuesInTraceLogs()

Implements org.hibernate.validator.internal.engine.validationcontext.ValidationContext.isShowValidatedValuesInTraceLogs.

Annotations
@Override
isSubPathOfback to summary
private boolean isSubPathOf(Path p1, Path p2)
markConstraintProcessedback to summary
public void markConstraintProcessed(Object bean, Path path, MetaConstraint<?> metaConstraint)

Implements org.hibernate.validator.internal.engine.validationcontext.BaseBeanValidationContext.markConstraintProcessed.

Annotations
@Override
markCurrentBeanAsProcessedback to summary
public void markCurrentBeanAsProcessed(ValueContext<?, ?> valueContext)

Implements org.hibernate.validator.internal.engine.validationcontext.BaseBeanValidationContext.markCurrentBeanAsProcessed.

Annotations
@Override
markCurrentBeanAsProcessedForCurrentGroupback to summary
private void markCurrentBeanAsProcessedForCurrentGroup(Object bean, Class<?> group)
markCurrentBeanAsProcessedForCurrentPathback to summary
private void markCurrentBeanAsProcessedForCurrentPath(Object bean, PathImpl path)
toStringback to summary
public abstract String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
org.hibernate.validator.internal.engine.validationcontext back to summary

private final Class AbstractValidationContext.BeanGroupProcessedUnit

extends Object
Class Inheritance
  • java.lang.Object
  • org.hibernate.validator.internal.engine.validationcontext.AbstractValidationContext.BeanGroupProcessedUnit

Field Summary

Modifier and TypeField and Description
private Object
private Class<?>
private int

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private int
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 int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

beanback to summary
private Object bean
groupback to summary
private Class<?> group
hashCodeback to summary
private int hashCode

Constructor Detail

BeanGroupProcessedUnitback to summary
pack-priv BeanGroupProcessedUnit(Object bean, Class<?> group)

Method Detail

createHashCodeback to summary
private int createHashCode()
equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
org.hibernate.validator.internal.engine.validationcontext back to summary

private final Class AbstractValidationContext.BeanPathMetaConstraintProcessedUnit

extends Object
Class Inheritance
  • java.lang.Object
  • org.hibernate.validator.internal.engine.validationcontext.AbstractValidationContext.BeanPathMetaConstraintProcessedUnit

Field Summary

Modifier and TypeField and Description
private Object
private int
private MetaConstraint<?>
private Path

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private int
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 int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

beanback to summary
private Object bean
hashCodeback to summary
private int hashCode
metaConstraintback to summary
private MetaConstraint<?> metaConstraint
pathback to summary
private Path path

Constructor Detail

BeanPathMetaConstraintProcessedUnitback to summary
pack-priv BeanPathMetaConstraintProcessedUnit(Object bean, Path path, MetaConstraint<?> metaConstraint)

Method Detail

createHashCodeback to summary
private int createHashCode()
equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override