Class AbstractMessageInterpolator
java.lang.Object
org.hibernate.validator.messageinterpolation.AbstractMessageInterpolator
- All Implemented Interfaces:
MessageInterpolator
- Direct Known Subclasses:
ParameterMessageInterpolator,ResourceBundleMessageInterpolator
Resource bundle backed message interpolator.
- Since:
- 5.2
- Author:
- Emmanuel Bernard, Hardy Ferentschik, Gunnar Morling, Adam Stawicki, Marko Bekhta, Guillaume Smet
-
Nested Class Summary
Nested classes/interfaces inherited from interface jakarta.validation.MessageInterpolator
MessageInterpolator.Context -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMessageInterpolatorusing the default resource bundle locators.AbstractMessageInterpolator(Set<Locale> locales, Locale defaultLocale, LocaleResolver localeResolver, boolean preloadResourceBundles) MessageInterpolatorusing the default resource bundle locators.AbstractMessageInterpolator(ResourceBundleLocator userResourceBundleLocator) MessageInterpolatortaking a resource bundle locator.AbstractMessageInterpolator(ResourceBundleLocator userResourceBundleLocator, Set<Locale> locales, Locale defaultLocale, LocaleResolver localeResolver, boolean preloadResourceBundles) MessageInterpolatortaking a resource bundle locator.AbstractMessageInterpolator(ResourceBundleLocator userResourceBundleLocator, ResourceBundleLocator contributorResourceBundleLocator) MessageInterpolatortaking two resource bundle locators.AbstractMessageInterpolator(ResourceBundleLocator userResourceBundleLocator, ResourceBundleLocator contributorResourceBundleLocator, boolean cacheMessages) MessageInterpolatortaking two resource bundle locators.AbstractMessageInterpolator(ResourceBundleLocator userResourceBundleLocator, ResourceBundleLocator contributorResourceBundleLocator, Set<Locale> localesToInitialize, Locale defaultLocale, LocaleResolver localeResolver, boolean preloadResourceBundles) MessageInterpolatortaking two resource bundle locators.AbstractMessageInterpolator(ResourceBundleLocator userResourceBundleLocator, ResourceBundleLocator contributorResourceBundleLocator, Set<Locale> locales, Locale defaultLocale, LocaleResolver localeResolver, boolean preloadResourceBundles, boolean cacheMessages) MessageInterpolatortaking two resource bundle locators. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract Stringinterpolate(MessageInterpolator.Context context, Locale locale, String term) interpolate(String message, MessageInterpolator.Context context) Interpolates the message template based on the constraint validation context.interpolate(String message, MessageInterpolator.Context context, Locale locale) Interpolates the message template based on the constraint validation context.
-
Field Details
-
DEFAULT_VALIDATION_MESSAGES
The name of the default message bundle.- See Also:
-
USER_VALIDATION_MESSAGES
The name of the user-provided message bundle as defined in the specification.- See Also:
-
CONTRIBUTOR_VALIDATION_MESSAGES
Default name of the message bundle defined by a constraint definition contributor.- Since:
- 5.2
- See Also:
-
-
Constructor Details
-
AbstractMessageInterpolator
public AbstractMessageInterpolator()MessageInterpolatorusing the default resource bundle locators. -
AbstractMessageInterpolator
MessageInterpolatortaking a resource bundle locator.- Parameters:
userResourceBundleLocator-ResourceBundleLocatorused to load user provided resource bundle
-
AbstractMessageInterpolator
public AbstractMessageInterpolator(ResourceBundleLocator userResourceBundleLocator, ResourceBundleLocator contributorResourceBundleLocator) MessageInterpolatortaking two resource bundle locators.- Parameters:
userResourceBundleLocator-ResourceBundleLocatorused to load user provided resource bundlecontributorResourceBundleLocator-ResourceBundleLocatorused to load resource bundle of constraint contributor- Since:
- 5.2
-
AbstractMessageInterpolator
public AbstractMessageInterpolator(ResourceBundleLocator userResourceBundleLocator, ResourceBundleLocator contributorResourceBundleLocator, boolean cacheMessages) MessageInterpolatortaking two resource bundle locators.- Parameters:
userResourceBundleLocator-ResourceBundleLocatorused to load user provided resource bundlecontributorResourceBundleLocator-ResourceBundleLocatorused to load resource bundle of constraint contributorcacheMessages- Whether resolved messages should be cached or not.- Since:
- 5.2
-
AbstractMessageInterpolator
@Incubating public AbstractMessageInterpolator(Set<Locale> locales, Locale defaultLocale, LocaleResolver localeResolver, boolean preloadResourceBundles) MessageInterpolatorusing the default resource bundle locators.- Parameters:
locales- the set of locales to initialize at bootstrapdefaultLocale- the default localelocaleResolver- the locale resolverpreloadResourceBundles- if the resource bundled should be initialized at initialization time, this is useful in the case of aPredefinedScopeValidatorFactoryImpl- Since:
- 6.1.1
-
AbstractMessageInterpolator
@Incubating public AbstractMessageInterpolator(ResourceBundleLocator userResourceBundleLocator, Set<Locale> locales, Locale defaultLocale, LocaleResolver localeResolver, boolean preloadResourceBundles) MessageInterpolatortaking a resource bundle locator.- Parameters:
userResourceBundleLocator-ResourceBundleLocatorused to load user provided resource bundlelocales- the set of locales to initialize at bootstrapdefaultLocale- the default localelocaleResolver- the locale resolverpreloadResourceBundles- if the resource bundled should be initialized at initialization time, this is useful in the case of aPredefinedScopeValidatorFactoryImpl- Since:
- 6.1.1
-
AbstractMessageInterpolator
@Incubating public AbstractMessageInterpolator(ResourceBundleLocator userResourceBundleLocator, ResourceBundleLocator contributorResourceBundleLocator, Set<Locale> localesToInitialize, Locale defaultLocale, LocaleResolver localeResolver, boolean preloadResourceBundles) MessageInterpolatortaking two resource bundle locators.- Parameters:
userResourceBundleLocator-ResourceBundleLocatorused to load user provided resource bundlecontributorResourceBundleLocator-ResourceBundleLocatorused to load resource bundle of constraint contributorlocalesToInitialize- the set of locales to initialize at bootstrapdefaultLocale- the default localelocaleResolver- the locale resolverpreloadResourceBundles- if the resource bundled should be initialized at initialization time, this is useful in the case of aPredefinedScopeValidatorFactoryImpl- Since:
- 6.1.1
-
AbstractMessageInterpolator
@Incubating public AbstractMessageInterpolator(ResourceBundleLocator userResourceBundleLocator, ResourceBundleLocator contributorResourceBundleLocator, Set<Locale> locales, Locale defaultLocale, LocaleResolver localeResolver, boolean preloadResourceBundles, boolean cacheMessages) MessageInterpolatortaking two resource bundle locators.- Parameters:
userResourceBundleLocator-ResourceBundleLocatorused to load user provided resource bundlecontributorResourceBundleLocator-ResourceBundleLocatorused to load resource bundle of constraint contributorlocales- the set of locales to initialize at bootstrapdefaultLocale- the default localecacheMessages- whether resolved messages should be cached or notlocaleResolver- the locale resolverpreloadResourceBundles- if the resource bundled should be initialized at initialization time, this is useful in the case of aPredefinedScopeValidatorFactoryImpl- Since:
- 6.1.1
-
-
Method Details
-
interpolate
Description copied from interface:MessageInterpolatorInterpolates the message template based on the constraint validation context.The locale is defaulted according to the
MessageInterpolatorimplementation. See the implementation documentation for more detail.- Specified by:
interpolatein interfaceMessageInterpolator- Parameters:
message- the message to interpolatecontext- contextual information related to the interpolation- Returns:
- interpolated error message
-
interpolate
Description copied from interface:MessageInterpolatorInterpolates the message template based on the constraint validation context. TheLocaleused is provided as a parameter.- Specified by:
interpolatein interfaceMessageInterpolator- Parameters:
message- the message to interpolatecontext- contextual information related to the interpolationlocale- the locale targeted for the message- Returns:
- interpolated error message
-
interpolate
protected abstract String interpolate(MessageInterpolator.Context context, Locale locale, String term)
-