
com.github.fge.msgsimple.source.MapMessageSource Maven / Gradle / Ivy
package com.github.fge.msgsimple.source;
import java.util.HashMap;
import java.util.Map;
public final class MapMessageSource
implements MessageSource
{
private final Map messages;
public MapMessageSource(final Map messages)
{
checkMap(messages);
this.messages = new HashMap(messages);
}
@Override
public String getMessage(final String key)
{
return messages.get(key);
}
private static void checkMap(final Map map)
{
for (final Map.Entry entry: map.entrySet()) {
if (entry.getKey() == null)
throw new NullPointerException("null keys not allowed in map");
if (entry.getValue() == null)
throw new NullPointerException("null values not allowed in map");
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy