Class PredefinedScopeValidatorContextImpl

java.lang.Object
org.hibernate.validator.internal.engine.PredefinedScopeValidatorContextImpl
All Implemented Interfaces:
ValidatorContext, HibernateValidatorContext

public class PredefinedScopeValidatorContextImpl extends Object implements HibernateValidatorContext
Author:
Guillaume Smet
  • Constructor Details

  • Method Details

    • messageInterpolator

      public HibernateValidatorContext messageInterpolator(MessageInterpolator messageInterpolator)
      Description copied from interface: ValidatorContext
      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.

      Specified by:
      messageInterpolator in interface HibernateValidatorContext
      Specified by:
      messageInterpolator in interface ValidatorContext
      Parameters:
      messageInterpolator - the MessageInterpolator used by the Validator
      Returns:
      self following the chaining method pattern
    • traversableResolver

      public HibernateValidatorContext traversableResolver(TraversableResolver traversableResolver)
      Description copied from interface: ValidatorContext
      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.

      Specified by:
      traversableResolver in interface HibernateValidatorContext
      Specified by:
      traversableResolver in interface ValidatorContext
      Parameters:
      traversableResolver - the TraversableResolver used by the Validator
      Returns:
      self following the chaining method pattern
    • constraintValidatorFactory

      public HibernateValidatorContext constraintValidatorFactory(ConstraintValidatorFactory factory)
      Description copied from interface: ValidatorContext
      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.
      Specified by:
      constraintValidatorFactory in interface HibernateValidatorContext
      Specified by:
      constraintValidatorFactory in interface ValidatorContext
      Parameters:
      factory - the ConstraintValidatorFactory used by the Validator
      Returns:
      self following the chaining method pattern
    • parameterNameProvider

      public HibernateValidatorContext parameterNameProvider(ParameterNameProvider parameterNameProvider)
      Description copied from interface: ValidatorContext
      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.
      Specified by:
      parameterNameProvider in interface HibernateValidatorContext
      Specified by:
      parameterNameProvider in interface ValidatorContext
      Parameters:
      parameterNameProvider - parameter name provider implementation.
      Returns:
      self following the chaining method pattern
    • clockProvider

      public HibernateValidatorContext clockProvider(ClockProvider clockProvider)
      Description copied from interface: ValidatorContext
      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.
      Specified by:
      clockProvider in interface HibernateValidatorContext
      Specified by:
      clockProvider in interface ValidatorContext
      Parameters:
      clockProvider - ClockProvider implementation
      Returns:
      self following the chaining method pattern
    • addValueExtractor

      public HibernateValidatorContext addValueExtractor(ValueExtractor<?> extractor)
      Description copied from interface: ValidatorContext
      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.
      Specified by:
      addValueExtractor in interface HibernateValidatorContext
      Specified by:
      addValueExtractor in interface ValidatorContext
      Parameters:
      extractor - value extractor implementation
      Returns:
      self following the chaining method pattern
    • failFast

      public HibernateValidatorContext failFast(boolean failFast)
      Description copied from interface: HibernateValidatorContext
      En- or disables the fail fast mode. When fail fast is enabled the validation will stop on the first constraint violation detected.
      Specified by:
      failFast in interface HibernateValidatorContext
      Parameters:
      failFast - true to enable fail fast, false otherwise.
      Returns:
      this following the chaining method pattern
    • allowOverridingMethodAlterParameterConstraint

      public HibernateValidatorContext allowOverridingMethodAlterParameterConstraint(boolean allow)
      Description copied from interface: HibernateValidatorContext
      Define whether overriding methods that override constraints should throw a ConstraintDefinitionException. The default value is false, i.e. do not allow.

      See Section 4.5.5 of the JSR 380 specification, specifically

       "In sub types (be it sub classes/interfaces or interface implementations), no parameter constraints may
       be declared on overridden or implemented methods, nor may parameters be marked for cascaded validation.
       This would pose a strengthening of preconditions to be fulfilled by the caller."
       
      Specified by:
      allowOverridingMethodAlterParameterConstraint in interface HibernateValidatorContext
      Parameters:
      allow - flag determining whether validation will allow overriding to alter parameter constraints.
      Returns:
      this following the chaining method pattern
    • allowMultipleCascadedValidationOnReturnValues

      public HibernateValidatorContext allowMultipleCascadedValidationOnReturnValues(boolean allow)
      Description copied from interface: HibernateValidatorContext
      Define whether more than one constraint on a return value may be marked for cascading validation are allowed. The default value is false, i.e. do not allow.

      See Section 4.5.5 of the JSR 380 specification, specifically

       "One must not mark a method return value for cascaded validation more than once in a line of a class hierarchy.
       In other words, overriding methods on sub types (be it sub classes/interfaces or interface implementations)
       cannot mark the return value for cascaded validation if the return value has already been marked on the
       overridden method of the super type or interface."
       
      Specified by:
      allowMultipleCascadedValidationOnReturnValues in interface HibernateValidatorContext
      Parameters:
      allow - flag determining whether validation will allow multiple cascaded validation on return values.
      Returns:
      this following the chaining method pattern
    • allowParallelMethodsDefineParameterConstraints

      public HibernateValidatorContext allowParallelMethodsDefineParameterConstraints(boolean allow)
      Description copied from interface: HibernateValidatorContext
      Define whether parallel methods that define constraints should throw a ConstraintDefinitionException. The default value is false, i.e. do not allow.

      See Section 4.5.5 of the JSR 380 specification, specifically

       "If a sub type overrides/implements a method originally defined in several parallel types of the hierarchy
       (e.g. two interfaces not extending each other, or a class and an interface not implemented by said class),
       no parameter constraints may be declared for that method at all nor parameters be marked for cascaded validation.
       This again is to avoid an unexpected strengthening of preconditions to be fulfilled by the caller."
       
      Specified by:
      allowParallelMethodsDefineParameterConstraints in interface HibernateValidatorContext
      Parameters:
      allow - flag determining whether validation will allow parameter constraints in parallel hierarchies
      Returns:
      this following the chaining method pattern
    • enableTraversableResolverResultCache

      public HibernateValidatorContext enableTraversableResolverResultCache(boolean enabled)
      Description copied from interface: HibernateValidatorContext
      Define whether the per validation call caching of TraversableResolver results is enabled. The default value is true, i.e. the caching is enabled.

      This behavior was initially introduced to cache the JPATraversableResolver results but the map lookups it introduces can be counterproductive when the TraversableResolver calls are very fast.

      Specified by:
      enableTraversableResolverResultCache in interface HibernateValidatorContext
      Parameters:
      enabled - flag determining whether per validation call caching is enabled for TraversableResolver results.
      Returns:
      this following the chaining method pattern
    • temporalValidationTolerance

      public HibernateValidatorContext temporalValidationTolerance(Duration temporalValidationTolerance)
      Description copied from interface: HibernateValidatorContext
      Define the temporal validation tolerance i.e. the acceptable margin of error when comparing date/time in temporal constraints.
      Specified by:
      temporalValidationTolerance in interface HibernateValidatorContext
      Parameters:
      temporalValidationTolerance - the tolerance
      Returns:
      this following the chaining method pattern
    • constraintValidatorPayload

      public HibernateValidatorContext constraintValidatorPayload(Object dynamicPayload)
      Description copied from interface: HibernateValidatorContext
      Define a payload passed to the constraint validators. If the method is called multiple times, only the payload passed last will be propagated.
      Specified by:
      constraintValidatorPayload in interface HibernateValidatorContext
      Parameters:
      dynamicPayload - the payload passed to constraint validators
      Returns:
      this following the chaining method pattern
    • showValidatedValuesInTraceLogs

      public HibernateValidatorContext showValidatedValuesInTraceLogs(boolean enabled)
      Description copied from interface: HibernateValidatorContext
      Define whether values that are currently being validated should be part of the logging at trace level, or not.
      Specified by:
      showValidatedValuesInTraceLogs in interface HibernateValidatorContext
      Parameters:
      enabled - true to show the values at trace level, false otherwise.
      Returns:
      this following the chaining method pattern
    • getValidator

      public Validator getValidator()
      Description copied from interface: ValidatorContext
      Returns an initialized Validator instance respecting the defined state. Validator instances can be pooled and shared by the implementation.
      Specified by:
      getValidator in interface ValidatorContext
      Returns:
      contextualized Validator