com.github.fge.msgsimple.source
Class MapMessageSource

java.lang.Object
  extended by com.github.fge.msgsimple.source.MapMessageSource
All Implemented Interfaces:
MessageSource

public final class MapMessageSource
extends Object
implements MessageSource

A Map-based message source

This is a simple message source using a Map as a key/value pair to look up messages.

In order to build such a source, use newBuilder(). Sample:

     final MessageSource source = MapMessageSource.newBuilder()
         .put("key1", "message1").put("key2", "message2")
         .putAll(existingMap).build();
 

Note that null keys or values are not allowed.

See Also:
MapMessageSource.Builder

Nested Class Summary
static class MapMessageSource.Builder
          Builder class for a MapMessageSource
 
Method Summary
 String getKey(String key)
          Return a message matching a given key
static MapMessageSource.Builder newBuilder()
          Create a new builder for a map message source
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newBuilder

public static MapMessageSource.Builder newBuilder()
Create a new builder for a map message source

Returns:
a MapMessageSource.Builder

getKey

public String getKey(String key)
Description copied from interface: MessageSource
Return a message matching a given key

Note that this method MUST return null if there is no match for the given key.

Note also that it is guaranteed that you will never get a null key.

Specified by:
getKey in interface MessageSource
Parameters:
key - the key
Returns:
see description