Interface MessageArguments


public interface MessageArguments
Provides message arguments by key.
  • Method Details

    • ofMap

      static MessageArguments ofMap(Map<? extends @NonNull String,@NonNull ?> arguments)
      Creates a MessageArguments that is backed by the given Map.

      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, not null
      Returns:
      the MessageArguments
    • get

      @Nullable Object get(String key)
      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

      default MessageArguments combinedWith(MessageArguments other)
      Creates a MessageArguments that combines this and the given other MessageArguments.

      If no argument is found for a key inside this MessageArguments, the given other MessageArguments is queried for an argument.

      Parameters:
      other - the other MessageArguments
      Returns:
      the combined MessageArguments
    • prefixed

      default MessageArguments prefixed(String keyPrefix)
      Creates a MessageArguments that prefixes the keys of this MessageArguments.

      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 original MessageArguments.

      Parameters:
      keyPrefix - the key prefix, not null
      Returns:
      the prefixed MessageArguments