@Immutable public final class StaticMessageSourceProvider extends Object implements MessageSourceProvider
The simplest form of such a provider is one which only has a default message source. You can define specific message sources for specific locales too.
Convenience static factory methods exist for building a message source
provider from a single message source; for more elaborage scenarios, you need
to use a StaticMessageSourceProvider.Builder (using the newBuilder() method).
StaticMessageSourceProvider.Builder| Modifier and Type | Class and Description |
|---|---|
static class |
StaticMessageSourceProvider.Builder
Builder for a
StaticMessageSourceProvider |
| Modifier and Type | Method and Description |
|---|---|
MessageSource |
getMessageSource(Locale locale)
Provide a message source for a given locale
|
static StaticMessageSourceProvider.Builder |
newBuilder()
Create a new static source builder
|
static MessageSourceProvider |
withSingleSource(Locale locale,
MessageSource source)
Convenience method to create a provider with a single source for a
specific locale
|
static MessageSourceProvider |
withSingleSource(MessageSource source)
Convenience method to create a provider with a single source
|
public static StaticMessageSourceProvider.Builder newBuilder()
public static MessageSourceProvider withSingleSource(MessageSource source)
This source will be used for all locales.
source - the message sourceStaticMessageSourceProvider.Builder.setDefaultSource(MessageSource)public static MessageSourceProvider withSingleSource(Locale locale, MessageSource source)
locale - the localesource - the message sourceStaticMessageSourceProvider.Builder.addSource(Locale, MessageSource)public MessageSource getMessageSource(Locale locale)
MessageSourceProvidergetMessageSource in interface MessageSourceProviderlocale - the localenull if none is found