Package valorless.valorlessutils.json
Interface MessageArguments
public interface MessageArguments
Provides message arguments by key.
-
Method Summary
Modifier and TypeMethodDescriptiondefault MessageArguments
combinedWith
(MessageArguments other) Creates aMessageArguments
that combines this and the given otherMessageArguments
.@Nullable Object
Gets the message argument for the specified key.static MessageArguments
Creates aMessageArguments
that is backed by the givenMap
.default MessageArguments
Creates aMessageArguments
that prefixes the keys of thisMessageArguments
.
-
Method Details
-
ofMap
Creates aMessageArguments
that is backed by the givenMap
.The returned
MessageArguments
is a view on the underlying Map: It dynamically reflects changes to the underlying Map.- Parameters:
arguments
- the mapping from keys to message arguments, notnull
- Returns:
- the
MessageArguments
-
get
Gets the message argument for the specified key.The returned message argument can be of any type. The caller of this method is responsible for formatting it appropriately for use as message argument. The returned object may also be a
Supplier
: In this case, the object returned by the Supplier is meant to be used as the actual message argument.- Parameters:
key
- the key- Returns:
- the message argument, or
null
if there is none for the given key
-
combinedWith
Creates aMessageArguments
that combines this and the given otherMessageArguments
.If no argument is found for a key inside this
MessageArguments
, the given otherMessageArguments
is queried for an argument.- Parameters:
other
- the otherMessageArguments
- Returns:
- the combined
MessageArguments
-
prefixed
Creates aMessageArguments
that prefixes the keys of thisMessageArguments
.The returned
MessageArguments
is a view: The prefix is dynamically stripped from the passed keys in order to construct the key with which the lookup is performed in this originalMessageArguments
.- Parameters:
keyPrefix
- the key prefix, notnull
- Returns:
- the prefixed
MessageArguments
-