Package jakarta.validation
Interface ValidatorFactory
- All Superinterfaces:
AutoCloseable
Factory returning initialized
Validator instances.
Implementations are thread-safe and instances are typically cached and reused.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes theValidatorFactoryinstance.Returns theClockProviderinstance configured at initialization time for theValidatorFactory.Returns theConstraintValidatorFactoryinstance configured at initialization time for theValidatorFactory.Returns theMessageInterpolatorinstance configured at initialization time for theValidatorFactory.Returns theParameterNameProviderinstance configured at initialization time for theValidatorFactory.Returns theTraversableResolverinstance configured at initialization time for theValidatorFactory.Returns an initializedValidatorinstance using the factory defaults for message interpolator, traversable resolver and constraint validator factory.<T> TReturns an instance of the specified type allowing access to provider-specific APIs.Defines a new validator context and returns aValidatorcompliant this new context.
-
Method Details
-
getValidator
Validator getValidator()Returns an initializedValidatorinstance using the factory defaults for message interpolator, traversable resolver and constraint validator factory.Validator instances can be pooled and shared by the implementation.
- Returns:
- an initialized
Validatorinstance
-
usingContext
ValidatorContext usingContext()Defines a new validator context and returns aValidatorcompliant this new context.- Returns:
- a
ValidatorContextinstance
-
getMessageInterpolator
MessageInterpolator getMessageInterpolator()Returns theMessageInterpolatorinstance configured at initialization time for theValidatorFactory. This is the instance used bygetValidator().- Returns:
MessageInterpolatorinstance
-
getTraversableResolver
TraversableResolver getTraversableResolver()Returns theTraversableResolverinstance configured at initialization time for theValidatorFactory. This is the instance used bygetValidator().- Returns:
TraversableResolverinstance
-
getConstraintValidatorFactory
ConstraintValidatorFactory getConstraintValidatorFactory()Returns theConstraintValidatorFactoryinstance configured at initialization time for theValidatorFactory. This is the instance used bygetValidator().- Returns:
ConstraintValidatorFactoryinstance
-
getParameterNameProvider
ParameterNameProvider getParameterNameProvider()Returns theParameterNameProviderinstance configured at initialization time for theValidatorFactory. This is the instance used by #getValidator().- Returns:
ParameterNameProviderinstance- Since:
- 1.1
-
getClockProvider
ClockProvider getClockProvider()Returns theClockProviderinstance configured at initialization time for theValidatorFactory. This is the instance used by #getValidator().- Returns:
ClockProviderinstance- Since:
- 2.0
-
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, aValidationExceptionis thrown.- Type Parameters:
T- the type of the object to be returned- Parameters:
type- the class of the object to be returned- Returns:
- an instance of the specified class
- Throws:
ValidationException- if the provider does not support the call.
-
close
void close()Closes theValidatorFactoryinstance. After theValidatorFactoryinstance is closed, calling the following methods is not allowed:- methods of this
ValidatorFactoryinstance - methods of
Validatorinstances created by thisValidatorFactory
- Specified by:
closein interfaceAutoCloseable- Since:
- 1.1
- methods of this
-