public final class MapMessageSource extends Object implements MessageSource
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.
MapMessageSource.Builder
Modifier and Type | Class and Description |
---|---|
static class |
MapMessageSource.Builder
Builder class for a
MapMessageSource |
Modifier and Type | Method and Description |
---|---|
String |
getKey(String key)
Return a message matching a given key
|
static MapMessageSource.Builder |
newBuilder()
Create a new builder for a map message source
|
public static MapMessageSource.Builder newBuilder()
MapMessageSource.Builder
public String getKey(String key)
MessageSource
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.
getKey
in interface MessageSource
key
- the key