Package jakarta.validation
Interface ValidatorFactory
-
- All Superinterfaces:
AutoCloseable
public interface ValidatorFactory extends AutoCloseable
Factory returning initializedValidatorinstances.Implementations are thread-safe and instances are typically cached and reused.
- Author:
- Emmanuel Bernard, Gunnar Morling, Hardy Ferentschik, Guillaume Smet
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclose()Closes theValidatorFactoryinstance.ClockProvidergetClockProvider()Returns theClockProviderinstance configured at initialization time for theValidatorFactory.ConstraintValidatorFactorygetConstraintValidatorFactory()Returns theConstraintValidatorFactoryinstance configured at initialization time for theValidatorFactory.MessageInterpolatorgetMessageInterpolator()Returns theMessageInterpolatorinstance configured at initialization time for theValidatorFactory.ParameterNameProvidergetParameterNameProvider()Returns theParameterNameProviderinstance configured at initialization time for theValidatorFactory.TraversableResolvergetTraversableResolver()Returns theTraversableResolverinstance configured at initialization time for theValidatorFactory.ValidatorgetValidator()Returns an initializedValidatorinstance using the factory defaults for message interpolator, traversable resolver and constraint validator factory.<T> Tunwrap(Class<T> type)Returns an instance of the specified type allowing access to provider-specific APIs.ValidatorContextusingContext()Defines a new validator context and returns aValidatorcompliant this new context.
-
-
-
Method Detail
-
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
<T> T unwrap(Class<T> type)
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
-
-