Class AbstractMessageInterpolator

    • Field Detail

      • DEFAULT_VALIDATION_MESSAGES

        public static final String DEFAULT_VALIDATION_MESSAGES
        The name of the default message bundle.
        See Also:
        Constant Field Values
      • USER_VALIDATION_MESSAGES

        public static final String USER_VALIDATION_MESSAGES
        The name of the user-provided message bundle as defined in the specification.
        See Also:
        Constant Field Values
      • CONTRIBUTOR_VALIDATION_MESSAGES

        public static final String CONTRIBUTOR_VALIDATION_MESSAGES
        Default name of the message bundle defined by a constraint definition contributor.
        Since:
        5.2
        See Also:
        Constant Field Values
    • Constructor Detail

      • AbstractMessageInterpolator

        public AbstractMessageInterpolator()
        MessageInterpolator using the default resource bundle locators.
      • AbstractMessageInterpolator

        public AbstractMessageInterpolator​(ResourceBundleLocator userResourceBundleLocator)
        MessageInterpolator taking a resource bundle locator.
        Parameters:
        userResourceBundleLocator - ResourceBundleLocator used to load user provided resource bundle
      • AbstractMessageInterpolator

        public AbstractMessageInterpolator​(ResourceBundleLocator userResourceBundleLocator,
                                           ResourceBundleLocator contributorResourceBundleLocator)
        MessageInterpolator taking two resource bundle locators.
        Parameters:
        userResourceBundleLocator - ResourceBundleLocator used to load user provided resource bundle
        contributorResourceBundleLocator - ResourceBundleLocator used to load resource bundle of constraint contributor
        Since:
        5.2
      • AbstractMessageInterpolator

        public AbstractMessageInterpolator​(ResourceBundleLocator userResourceBundleLocator,
                                           ResourceBundleLocator contributorResourceBundleLocator,
                                           boolean cacheMessages)
        MessageInterpolator taking two resource bundle locators.
        Parameters:
        userResourceBundleLocator - ResourceBundleLocator used to load user provided resource bundle
        contributorResourceBundleLocator - ResourceBundleLocator used to load resource bundle of constraint contributor
        cacheMessages - Whether resolved messages should be cached or not.
        Since:
        5.2
      • AbstractMessageInterpolator

        @Incubating
        public AbstractMessageInterpolator​(Set<Locale> locales,
                                           Locale defaultLocale,
                                           LocaleResolver localeResolver,
                                           boolean preloadResourceBundles)
        MessageInterpolator using the default resource bundle locators.
        Parameters:
        locales - the set of locales to initialize at bootstrap
        defaultLocale - the default locale
        localeResolver - the locale resolver
        preloadResourceBundles - if the resource bundled should be initialized at initialization time, this is useful in the case of a PredefinedScopeValidatorFactoryImpl
        Since:
        6.1.1
      • AbstractMessageInterpolator

        @Incubating
        public AbstractMessageInterpolator​(ResourceBundleLocator userResourceBundleLocator,
                                           Set<Locale> locales,
                                           Locale defaultLocale,
                                           LocaleResolver localeResolver,
                                           boolean preloadResourceBundles)
        MessageInterpolator taking a resource bundle locator.
        Parameters:
        userResourceBundleLocator - ResourceBundleLocator used to load user provided resource bundle
        locales - the set of locales to initialize at bootstrap
        defaultLocale - the default locale
        localeResolver - the locale resolver
        preloadResourceBundles - if the resource bundled should be initialized at initialization time, this is useful in the case of a PredefinedScopeValidatorFactoryImpl
        Since:
        6.1.1
      • AbstractMessageInterpolator

        @Incubating
        public AbstractMessageInterpolator​(ResourceBundleLocator userResourceBundleLocator,
                                           ResourceBundleLocator contributorResourceBundleLocator,
                                           Set<Locale> localesToInitialize,
                                           Locale defaultLocale,
                                           LocaleResolver localeResolver,
                                           boolean preloadResourceBundles)
        MessageInterpolator taking two resource bundle locators.
        Parameters:
        userResourceBundleLocator - ResourceBundleLocator used to load user provided resource bundle
        contributorResourceBundleLocator - ResourceBundleLocator used to load resource bundle of constraint contributor
        localesToInitialize - the set of locales to initialize at bootstrap
        defaultLocale - the default locale
        localeResolver - the locale resolver
        preloadResourceBundles - if the resource bundled should be initialized at initialization time, this is useful in the case of a PredefinedScopeValidatorFactoryImpl
        Since:
        6.1.1
      • AbstractMessageInterpolator

        @Incubating
        public AbstractMessageInterpolator​(ResourceBundleLocator userResourceBundleLocator,
                                           ResourceBundleLocator contributorResourceBundleLocator,
                                           Set<Locale> locales,
                                           Locale defaultLocale,
                                           LocaleResolver localeResolver,
                                           boolean preloadResourceBundles,
                                           boolean cacheMessages)
        MessageInterpolator taking two resource bundle locators.
        Parameters:
        userResourceBundleLocator - ResourceBundleLocator used to load user provided resource bundle
        contributorResourceBundleLocator - ResourceBundleLocator used to load resource bundle of constraint contributor
        locales - the set of locales to initialize at bootstrap
        defaultLocale - the default locale
        cacheMessages - whether resolved messages should be cached or not
        localeResolver - the locale resolver
        preloadResourceBundles - if the resource bundled should be initialized at initialization time, this is useful in the case of a PredefinedScopeValidatorFactoryImpl
        Since:
        6.1.1
    • Method Detail

      • interpolate

        public String interpolate​(String message,
                                  MessageInterpolator.Context context)
        Description copied from interface: MessageInterpolator
        Interpolates the message template based on the constraint validation context.

        The locale is defaulted according to the MessageInterpolator implementation. See the implementation documentation for more detail.

        Specified by:
        interpolate in interface MessageInterpolator
        Parameters:
        message - the message to interpolate
        context - contextual information related to the interpolation
        Returns:
        interpolated error message
      • interpolate

        public String interpolate​(String message,
                                  MessageInterpolator.Context context,
                                  Locale locale)
        Description copied from interface: MessageInterpolator
        Interpolates the message template based on the constraint validation context. The Locale used is provided as a parameter.
        Specified by:
        interpolate in interface MessageInterpolator
        Parameters:
        message - the message to interpolate
        context - contextual information related to the interpolation
        locale - the locale targeted for the message
        Returns:
        interpolated error message