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

public Class ValidatorFactoryImpl

extends Object
implements HibernateValidatorFactory
Class Inheritance
All Implemented Interfaces
org.hibernate.validator.HibernateValidatorFactory, jakarta.validation.ValidatorFactory, java.lang.AutoCloseable
Static Imports
org.hibernate.validator.internal.engine.ValidatorFactoryConfigurationHelper.determineAllowMultipleCascadedValidationOnReturnValues, .ValidatorFactoryConfigurationHelper.determineAllowOverridingMethodAlterParameterConstraint, .ValidatorFactoryConfigurationHelper.determineAllowParallelMethodsDefineParameterConstraints, .ValidatorFactoryConfigurationHelper.determineBeanMetaDataClassNormalizer, .ValidatorFactoryConfigurationHelper.determineConstraintMappings, .ValidatorFactoryConfigurationHelper.determineConstraintValidatorPayload, .ValidatorFactoryConfigurationHelper.determineConstraintExpressionLanguageFeatureLevel, .ValidatorFactoryConfigurationHelper.determineCustomViolationExpressionLanguageFeatureLevel, .ValidatorFactoryConfigurationHelper.determineExternalClassLoader, .ValidatorFactoryConfigurationHelper.determineFailFast, .ValidatorFactoryConfigurationHelper.determineScriptEvaluatorFactory, .ValidatorFactoryConfigurationHelper.determineServiceLoadedConstraintMappings, .ValidatorFactoryConfigurationHelper.determineTemporalValidationTolerance, .ValidatorFactoryConfigurationHelper.determineTraversableResolverResultCacheEnabled, .ValidatorFactoryConfigurationHelper.logValidatorFactoryScopedConfiguration, .ValidatorFactoryConfigurationHelper.determineShowValidatedValuesInTraceLogs, .ValidatorFactoryConfigurationHelper.registerCustomConstraintValidators, org.hibernate.validator.internal.util.CollectionHelper.newArrayList

Factory returning initialized Validator instances. This is the Hibernate Validator default implementation of the ValidatorFactory interface.
Authors
Emmanuel Bernard, Hardy Ferentschik, Gunnar Morling, Kevin Pollet <[email protected]> (C) 2011 SERLI, Chris Beckey <[email protected]>, Guillaume Smet, Marko Bekhta

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final BeanMetaDataClassNormalizer
private final ConcurrentMap<ValidatorFactoryImpl.BeanMetaDataManagerKey, BeanMetaDataManager>
beanMetaDataManagers

Prior to the introduction of ParameterNameProvider all the bean meta data was static and could be cached for all created Validators.

private final ConstraintCreationContext
constraintCreationContext

The constraint creation context containing all the helpers necessary to the constraint creation.

private final Set<DefaultConstraintMapping>
constraintMappings

Programmatic constraints passed via the Hibernate Validator specific API.

private final ExecutableHelper
executableHelper

Used for discovering overridden methods.

private final JavaBeanHelper
private static final Log
private final MethodValidationConfiguration
methodValidationConfiguration

Hibernate Validator specific flags to relax constraints on parameters.

private final ValidationOrderGenerator
private final ValidatorFactoryScopedContext
validatorFactoryScopedContext

Context containing all ValidatorFactory level helpers and configuration properties.

private final XmlMetaDataProvider
xmlMetaDataProvider

Metadata provider for XML configuration.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private List<MetaDataProvider>
public void
close()

Implements jakarta.validation.ValidatorFactory.close.

Closes the ValidatorFactory instance.
pack-priv Validator
createValidator(ConstraintValidatorFactory constraintValidatorFactory, ConstraintCreationContext constraintCreationContext, ValidatorFactoryScopedContext validatorFactoryScopedContext, MethodValidationConfiguration methodValidationConfiguration)

public ClockProvider
getClockProvider()

Implements jakarta.validation.ValidatorFactory.getClockProvider.

Returns the ClockProvider instance configured at initialization time for the ValidatorFactory.
pack-priv ConstraintCreationContext
public ConstraintValidatorFactory
getConstraintValidatorFactory()

Implements jakarta.validation.ValidatorFactory.getConstraintValidatorFactory.

Returns the ConstraintValidatorFactory instance configured at initialization time for the ValidatorFactory.
public ExecutableParameterNameProvider
public GetterPropertySelectionStrategy
getGetterPropertySelectionStrategy()

Implements org.hibernate.validator.HibernateValidatorFactory.getGetterPropertySelectionStrategy.

Returns the getter property selection strategy defining the rules determining if a method is a getter or not.
public MessageInterpolator
getMessageInterpolator()

Implements jakarta.validation.ValidatorFactory.getMessageInterpolator.

Returns the MessageInterpolator instance configured at initialization time for the ValidatorFactory.
pack-priv MethodValidationConfiguration
public ParameterNameProvider
getParameterNameProvider()

Implements jakarta.validation.ValidatorFactory.getParameterNameProvider.

Returns the ParameterNameProvider instance configured at initialization time for the ValidatorFactory.
public PropertyNodeNameProvider
getPropertyNodeNameProvider()

Implements org.hibernate.validator.HibernateValidatorFactory.getPropertyNodeNameProvider.

Returns the property node name provider used to resolve the name of a property node when creating the property path.
public ScriptEvaluatorFactory
getScriptEvaluatorFactory()

Implements org.hibernate.validator.HibernateValidatorFactory.getScriptEvaluatorFactory.

Returns the factory responsible for creating ScriptEvaluators used to evaluate script expressions of ScriptAssert and ParameterScriptAssert constraints.
public Duration
getTemporalValidationTolerance()

Implements org.hibernate.validator.HibernateValidatorFactory.getTemporalValidationTolerance.

Returns the temporal validation tolerance i.e. the acceptable margin of error when comparing date/time in temporal constraints.
public TraversableResolver
getTraversableResolver()

Implements jakarta.validation.ValidatorFactory.getTraversableResolver.

Returns the TraversableResolver instance configured at initialization time for the ValidatorFactory.
public Validator
getValidator()

Implements jakarta.validation.ValidatorFactory.getValidator.

Returns an initialized Validator instance using the factory defaults for message interpolator, traversable resolver and constraint validator factory.
public ValidatorFactoryScopedContext
public boolean
public boolean
public <T> T
unwrap(Class<T>
the class of the object to be returned
type
)

Implements jakarta.validation.ValidatorFactory.unwrap.

Returns an instance of the specified type allowing access to provider-specific APIs.
public HibernateValidatorContext
usingContext()

Implements org.hibernate.validator.HibernateValidatorFactory.usingContext.

Returns a context for validator configuration via options from the Bean Validation API as well as specific ones from Hibernate Validator.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

beanMetadataClassNormalizerback to summary
private final BeanMetaDataClassNormalizer beanMetadataClassNormalizer
beanMetaDataManagersback to summary
private final ConcurrentMap<ValidatorFactoryImpl.BeanMetaDataManagerKey, BeanMetaDataManager> beanMetaDataManagers

Prior to the introduction of ParameterNameProvider all the bean meta data was static and could be cached for all created Validators. ParameterNameProvider makes parts of the meta data and Bean Validation element descriptors dynamic, since depending of the used provider different parameter names could be used. To still have the metadata static we create a BeanMetaDataManager per parameter name provider. See also HV-659.

Annotations
@ThreadSafe
constraintCreationContextback to summary
private final ConstraintCreationContext constraintCreationContext

The constraint creation context containing all the helpers necessary to the constraint creation.

constraintMappingsback to summary
private final Set<DefaultConstraintMapping> constraintMappings

Programmatic constraints passed via the Hibernate Validator specific API. Empty if there are no programmatic constraints

Annotations
@Immutable
executableHelperback to summary
private final ExecutableHelper executableHelper

Used for discovering overridden methods. Thread-safe.

javaBeanHelperback to summary
private final JavaBeanHelper javaBeanHelper
LOGback to summary
private static final Log LOG
methodValidationConfigurationback to summary
private final MethodValidationConfiguration methodValidationConfiguration

Hibernate Validator specific flags to relax constraints on parameters.

validationOrderGeneratorback to summary
private final ValidationOrderGenerator validationOrderGenerator
validatorFactoryScopedContextback to summary
private final ValidatorFactoryScopedContext validatorFactoryScopedContext

Context containing all ValidatorFactory level helpers and configuration properties.

xmlMetaDataProviderback to summary
private final XmlMetaDataProvider xmlMetaDataProvider

Metadata provider for XML configuration.

Constructor Detail

ValidatorFactoryImplback to summary
public ValidatorFactoryImpl(ConfigurationState configurationState)

Method Detail

buildMetaDataProvidersback to summary
private List<MetaDataProvider> buildMetaDataProviders()
closeback to summary
public void close()

Implements jakarta.validation.ValidatorFactory.close.

Doc from jakarta.validation.ValidatorFactory.close.

Closes the ValidatorFactory instance. After the ValidatorFactory instance is closed, calling the following methods is not allowed:

  • methods of this ValidatorFactory instance
  • methods of Validator instances created by this ValidatorFactory
Annotations
@Override
createValidatorback to summary
pack-priv Validator createValidator(ConstraintValidatorFactory constraintValidatorFactory, ConstraintCreationContext constraintCreationContext, ValidatorFactoryScopedContext validatorFactoryScopedContext, MethodValidationConfiguration methodValidationConfiguration)
getClockProviderback to summary
public ClockProvider getClockProvider()

Implements jakarta.validation.ValidatorFactory.getClockProvider.

Doc from jakarta.validation.ValidatorFactory.getClockProvider.

Returns the ClockProvider instance configured at initialization time for the ValidatorFactory. This is the instance used by #getValidator().

Returns:ClockProvider

ClockProvider instance

Annotations
@Override
getConstraintCreationContextback to summary
pack-priv ConstraintCreationContext getConstraintCreationContext()
getConstraintValidatorFactoryback to summary
public ConstraintValidatorFactory getConstraintValidatorFactory()

Implements jakarta.validation.ValidatorFactory.getConstraintValidatorFactory.

Doc from jakarta.validation.ValidatorFactory.getConstraintValidatorFactory.

Returns the ConstraintValidatorFactory instance configured at initialization time for the ValidatorFactory. This is the instance used by getValidator().

Returns:ConstraintValidatorFactory

ConstraintValidatorFactory instance

Annotations
@Override
getExecutableParameterNameProviderback to summary
public ExecutableParameterNameProvider getExecutableParameterNameProvider()
getGetterPropertySelectionStrategyback to summary
public GetterPropertySelectionStrategy getGetterPropertySelectionStrategy()

Implements org.hibernate.validator.HibernateValidatorFactory.getGetterPropertySelectionStrategy.

Doc from org.hibernate.validator.HibernateValidatorFactory.getGetterPropertySelectionStrategy.

Returns the getter property selection strategy defining the rules determining if a method is a getter or not.

Returns:GetterPropertySelectionStrategy

the getter property selection strategy of the current ValidatorFactory

Annotations
@Override
getMessageInterpolatorback to summary
public MessageInterpolator getMessageInterpolator()

Implements jakarta.validation.ValidatorFactory.getMessageInterpolator.

Doc from jakarta.validation.ValidatorFactory.getMessageInterpolator.

Returns the MessageInterpolator instance configured at initialization time for the ValidatorFactory. This is the instance used by getValidator().

Returns:MessageInterpolator

MessageInterpolator instance

Annotations
@Override
getMethodValidationConfigurationback to summary
pack-priv MethodValidationConfiguration getMethodValidationConfiguration()
getParameterNameProviderback to summary
public ParameterNameProvider getParameterNameProvider()

Implements jakarta.validation.ValidatorFactory.getParameterNameProvider.

Doc from jakarta.validation.ValidatorFactory.getParameterNameProvider.

Returns the ParameterNameProvider instance configured at initialization time for the ValidatorFactory. This is the instance used by #getValidator().

Returns:ParameterNameProvider

ParameterNameProvider instance

Annotations
@Override
getPropertyNodeNameProviderback to summary
public PropertyNodeNameProvider getPropertyNodeNameProvider()

Implements org.hibernate.validator.HibernateValidatorFactory.getPropertyNodeNameProvider.

Doc from org.hibernate.validator.HibernateValidatorFactory.getPropertyNodeNameProvider.

Returns the property node name provider used to resolve the name of a property node when creating the property path.

Returns:PropertyNodeNameProvider

the property node name provider of the current ValidatorFactory

Annotations
@Override
getScriptEvaluatorFactoryback to summary
public ScriptEvaluatorFactory getScriptEvaluatorFactory()

Implements org.hibernate.validator.HibernateValidatorFactory.getScriptEvaluatorFactory.

Doc from org.hibernate.validator.HibernateValidatorFactory.getScriptEvaluatorFactory.

Returns the factory responsible for creating ScriptEvaluators used to evaluate script expressions of ScriptAssert and ParameterScriptAssert constraints.

Returns:ScriptEvaluatorFactory

a ScriptEvaluatorFactory instance

Annotations
@Override
getTemporalValidationToleranceback to summary
public Duration getTemporalValidationTolerance()

Implements org.hibernate.validator.HibernateValidatorFactory.getTemporalValidationTolerance.

Doc from org.hibernate.validator.HibernateValidatorFactory.getTemporalValidationTolerance.

Returns the temporal validation tolerance i.e. the acceptable margin of error when comparing date/time in temporal constraints.

Returns:Duration

the tolerance

Annotations
@Override
getTraversableResolverback to summary
public TraversableResolver getTraversableResolver()

Implements jakarta.validation.ValidatorFactory.getTraversableResolver.

Doc from jakarta.validation.ValidatorFactory.getTraversableResolver.

Returns the TraversableResolver instance configured at initialization time for the ValidatorFactory. This is the instance used by getValidator().

Returns:TraversableResolver

TraversableResolver instance

Annotations
@Override
getValidatorback to summary
public Validator getValidator()

Implements jakarta.validation.ValidatorFactory.getValidator.

Doc from jakarta.validation.ValidatorFactory.getValidator.

Returns an initialized Validator instance using the factory defaults for message interpolator, traversable resolver and constraint validator factory.

Validator instances can be pooled and shared by the implementation.

Returns:Validator

an initialized Validator instance

Annotations
@Override
getValidatorFactoryScopedContextback to summary
public ValidatorFactoryScopedContext getValidatorFactoryScopedContext()
isFailFastback to summary
public boolean isFailFast()
isTraversableResolverResultCacheEnabledback to summary
public boolean isTraversableResolverResultCacheEnabled()
unwrapback to summary
public <T> T unwrap(Class<T> type)

Implements jakarta.validation.ValidatorFactory.unwrap.

Doc from jakarta.validation.ValidatorFactory.unwrap.

Returns an instance of the specified type allowing access to provider-specific APIs. If the Jakarta Bean Validation provider implementation does not support the specified class, a ValidationException is thrown.

Parameters
<T>
the type of the object to be returned
type:Class<T>

the class of the object to be returned

Returns:T

an instance of the specified class

Annotations
@Override
usingContextback to summary
public HibernateValidatorContext usingContext()

Implements org.hibernate.validator.HibernateValidatorFactory.usingContext.

Doc from org.hibernate.validator.HibernateValidatorFactory.usingContext.

Returns a context for validator configuration via options from the Bean Validation API as well as specific ones from Hibernate Validator.

Returns:HibernateValidatorContext

A context for validator configuration.

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

private Class ValidatorFactoryImpl.BeanMetaDataManagerKey

extends Object
Class Inheritance
  • java.lang.Object
  • org.hibernate.validator.internal.engine.ValidatorFactoryImpl.BeanMetaDataManagerKey

Field Summary

Modifier and TypeField and Description
private final int
private final MethodValidationConfiguration
private final ExecutableParameterNameProvider
private final ValueExtractorManager

Constructor Summary

AccessConstructor and Description
public
BeanMetaDataManagerKey(ExecutableParameterNameProvider parameterNameProvider, ValueExtractorManager valueExtractorManager, MethodValidationConfiguration methodValidationConfiguration)

Method Summary

Modifier and TypeMethod and Description
private static int
buildHashCode(ExecutableParameterNameProvider parameterNameProvider, ValueExtractorManager valueExtractorManager, MethodValidationConfiguration methodValidationConfiguration)

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

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.
public String
toString()

Overrides java.lang.Object.toString.

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

Field Detail

hashCodeback to summary
private final int hashCode
methodValidationConfigurationback to summary
private final MethodValidationConfiguration methodValidationConfiguration
parameterNameProviderback to summary
private final ExecutableParameterNameProvider parameterNameProvider
valueExtractorManagerback to summary
private final ValueExtractorManager valueExtractorManager

Constructor Detail

BeanMetaDataManagerKeyback to summary
public BeanMetaDataManagerKey(ExecutableParameterNameProvider parameterNameProvider, ValueExtractorManager valueExtractorManager, MethodValidationConfiguration methodValidationConfiguration)

Method Detail

buildHashCodeback to summary
private static int buildHashCode(ExecutableParameterNameProvider parameterNameProvider, ValueExtractorManager valueExtractorManager, MethodValidationConfiguration methodValidationConfiguration)
equalsback to summary
public boolean equals(Object obj)

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
obj: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
toStringback to summary
public 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