Interface HibernateConstraintValidatorInitializationContext


@Incubating public interface HibernateConstraintValidatorInitializationContext
Provides contextual data and operations when initializing a constraint validator.
Since:
6.0.5
Author:
Marko Bekhta
  • Method Details

    • getScriptEvaluatorForLanguage

      ScriptEvaluator getScriptEvaluatorForLanguage(String languageName)
      Returns a ScriptEvaluator created by the ScriptEvaluatorFactory passed at bootstrap.
      Parameters:
      languageName - the name of the scripting language
      Returns:
      a script evaluator for the given language. Never null.
      Throws:
      ScriptEvaluatorNotFoundException - in case no ScriptEvaluator was found for a given languageName
    • getClockProvider

      ClockProvider getClockProvider()
      Returns the provider for obtaining the current time in the form of a Clock, e.g. when validating the Future and Past constraints.
      Returns:
      the provider for obtaining the current time, never null. If no specific provider has been configured during bootstrap, a default implementation using the current system time and the current default time zone as returned by Clock.systemDefaultZone() will be returned.
    • getTemporalValidationTolerance

      @Incubating Duration getTemporalValidationTolerance()
      Returns the temporal validation tolerance i.e. the acceptable margin of error when comparing date/time in temporal constraints.
      Returns:
      the tolerance
      Since:
      6.0.5
    • getSharedData

      @Incubating <C> C getSharedData(Class<C> type)
      Returns an instance of the specified data type or null if the current context does not contain such data. The requested data type must match the one with which it was originally added with BaseHibernateValidatorConfiguration.addConstraintValidatorInitializationSharedData(Object).
      Parameters:
      type - the type of data to retrieve
      Returns:
      an instance of the specified type or null if the current constraint initialization context does not contain an instance of such type
      Since:
      9.1.0
      See Also:
    • getSharedData

      @Incubating <C, V extends C> C getSharedData(Class<C> type, Supplier<V> createIfNotPresent)
      Returns an instance of the specified data type or attempts to create it with a supplier, if the current context does not contain such data.
      Parameters:
      type - the type of data to retrieve
      createIfNotPresent - the supplier to create an instance of shared data, if it is not already present in this context.
      Returns:
      an instance of the specified type or null if the current constraint initialization context does not contain an instance of such type
      Since:
      9.1.0
      See Also: