Top Description Methods
jakarta.validation

public Interface ValidatorContext

Imports
jakarta.validation.valueextraction.ValueExtractor, .ValueExtractorDeclarationException

Represents the context that is used to create Validator instances. A client may use methods of the ValidatorContext returned by ValidatorFactory#usingContext() to customize the context used to create Validator instances (for instance establish different message interpolators or traversable resolvers).
Authors
Emmanuel Bernard, Gunnar Morling, Guillaume Smet

Method Summary

Modifier and TypeMethod and Description
public ValidatorContext

Returns:

self following the chaining method pattern
addValueExtractor
(ValueExtractor<?>
value extractor implementation
extractor
)

Adds a value extractor to be used by the Validator.

public ValidatorContext

Returns:

self following the chaining method pattern
clockProvider
(ClockProvider
ClockProvider implementation
clockProvider
)

Defines the ClockProvider implementation used by the Validator.

public ValidatorContext

Returns:

self following the chaining method pattern
constraintValidatorFactory
(ConstraintValidatorFactory
the ConstraintValidatorFactory used by the Validator
factory
)

Defines the constraint validator factory implementation used by the Validator.

public Validator

Returns:

contextualized Validator
getValidator
()

Returns an initialized Validator instance respecting the defined state.

public ValidatorContext

Returns:

self following the chaining method pattern
messageInterpolator
(MessageInterpolator
the MessageInterpolator used by the Validator
messageInterpolator
)

Defines the message interpolator implementation used by the Validator.

public ValidatorContext

Returns:

self following the chaining method pattern
parameterNameProvider
(ParameterNameProvider
parameter name provider implementation.
parameterNameProvider
)

Defines the parameter name provider implementation used by the Validator.

public ValidatorContext

Returns:

self following the chaining method pattern
traversableResolver
(TraversableResolver
the TraversableResolver used by the Validator
traversableResolver
)

Defines the traversable resolver implementation used by the Validator.

Method Detail

addValueExtractorback to summary
public ValidatorContext addValueExtractor(ValueExtractor<?> extractor)

Adds a value extractor to be used by the Validator. Has priority over any extractor for the same type and type parameter detected through the service loader, given in the XML configuration or configured for the validator factory.

Parameters
extractor:ValueExtractor<?>

value extractor implementation

Returns:ValidatorContext

self following the chaining method pattern

Exceptions
ValueExtractorDeclarationException:
if more than one extractor for the same type and type parameter is added
Since
2.0
clockProviderback to summary
public ValidatorContext clockProvider(ClockProvider clockProvider)

Defines the ClockProvider implementation used by the Validator. If not set or if null is passed as a parameter, the clock provider of the ValidatorFactory is used.

Parameters
clockProvider:ClockProvider

ClockProvider implementation

Returns:ValidatorContext

self following the chaining method pattern

Since
2.0
constraintValidatorFactoryback to summary
public ValidatorContext constraintValidatorFactory(ConstraintValidatorFactory factory)

Defines the constraint validator factory implementation used by the Validator. If not set or if null is passed as a parameter, the constraint validator factory of the ValidatorFactory is used.

Parameters
factory:ConstraintValidatorFactory

the ConstraintValidatorFactory used by the Validator

Returns:ValidatorContext

self following the chaining method pattern

getValidatorback to summary
public Validator getValidator()

Returns an initialized Validator instance respecting the defined state. Validator instances can be pooled and shared by the implementation.

Returns:Validator

contextualized Validator

messageInterpolatorback to summary
public ValidatorContext messageInterpolator(MessageInterpolator messageInterpolator)

Defines the message interpolator implementation used by the Validator.

If not set or if null is passed as a parameter, the message interpolator of the ValidatorFactory is used.

Parameters
messageInterpolator:MessageInterpolator

the MessageInterpolator used by the Validator

Returns:ValidatorContext

self following the chaining method pattern

parameterNameProviderback to summary
public ValidatorContext parameterNameProvider(ParameterNameProvider parameterNameProvider)

Defines the parameter name provider implementation used by the Validator. If not set or if null is passed as a parameter, the parameter name provider of the ValidatorFactory is used.

Parameters
parameterNameProvider:ParameterNameProvider

parameter name provider implementation.

Returns:ValidatorContext

self following the chaining method pattern

Since
1.1
traversableResolverback to summary
public ValidatorContext traversableResolver(TraversableResolver traversableResolver)

Defines the traversable resolver implementation used by the Validator.

If not set or if null is passed as a parameter, the traversable resolver of the ValidatorFactory is used.

Parameters
traversableResolver:TraversableResolver

the TraversableResolver used by the Validator

Returns:ValidatorContext

self following the chaining method pattern