public final class CachingTranslationProvider extends Object implements TranslationProvider
TranslationProvider
that caches results returned from its wrapped provider if possible.
Messages with placeholders cannot be cached.
Constructor and Description |
---|
CachingTranslationProvider(TranslationProvider backingProvider) |
Modifier and Type | Method and Description |
---|---|
String |
applyPlaceholders(String raw,
Object... placeholders)
Applied placeholders to the given raw message.
|
@Nullable String |
get(String key)
Returns a message of a single line.
|
@Nullable String |
get(String key,
Object... placeholders)
Returns a message of a single line.
|
@Nullable List<String> |
getList(String key)
Returns a message of one or more lines.
|
@Nullable List<String> |
getList(String key,
Object... placeholders)
Returns a message of one or more lines.
|
public CachingTranslationProvider(TranslationProvider backingProvider)
public @Nullable String get(String key)
TranslationProvider
get
in interface TranslationProvider
key
- the key of the requested messagepublic @Nullable String get(String key, Object... placeholders)
TranslationProvider
get
in interface TranslationProvider
key
- the key of the requested messageplaceholders
- the placeholders to use in this messagepublic @Nullable List<String> getList(String key)
TranslationProvider
getList
in interface TranslationProvider
key
- the key of the requested messagepublic @Nullable List<String> getList(String key, Object... placeholders)
TranslationProvider
getList
in interface TranslationProvider
key
- the key of the requested messageplaceholders
- the placeholders to use in this messagepublic String applyPlaceholders(String raw, Object... placeholders)
TranslationProvider
applyPlaceholders
in interface TranslationProvider
raw
- the raw message to processplaceholders
- placeholders to use