com.github.fge.msgsimple.provider
Class StaticMessageSourceProvider

java.lang.Object
  extended by com.github.fge.msgsimple.provider.StaticMessageSourceProvider
All Implemented Interfaces:
MessageSourceProvider

@Immutable
public final class StaticMessageSourceProvider
extends Object
implements MessageSourceProvider

Static message source provider

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).

See Also:
StaticMessageSourceProvider.Builder

Nested Class Summary
static class StaticMessageSourceProvider.Builder
          Builder for a StaticMessageSourceProvider
 
Method Summary
 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newBuilder

public static StaticMessageSourceProvider.Builder newBuilder()
Create a new static source builder

Returns:
a builder

withSingleSource

public static MessageSourceProvider withSingleSource(MessageSource source)
Convenience method to create a provider with a single source

This source will be used for all locales.

Parameters:
source - the message source
Returns:
a message provider
See Also:
StaticMessageSourceProvider.Builder.setDefaultSource(MessageSource)

withSingleSource

public static MessageSourceProvider withSingleSource(Locale locale,
                                                     MessageSource source)
Convenience method to create a provider with a single source for a specific locale

Parameters:
locale - the locale
source - the message source
Returns:
a message provider
See Also:
StaticMessageSourceProvider.Builder.addSource(Locale, MessageSource)

getMessageSource

public MessageSource getMessageSource(Locale locale)
Description copied from interface: MessageSourceProvider
Provide a message source for a given locale

Specified by:
getMessageSource in interface MessageSourceProvider
Parameters:
locale - the locale
Returns:
a matching message source; null if none is found