Class TranslatableMessage


  • public class TranslatableMessage
    extends Object
    A message which can be translated using a translation service, providing a translation key and optional set of values to be substituted into the translation string associated with that key.
    • Constructor Detail

      • TranslatableMessage

        public TranslatableMessage​(String key)
        Creates a new TranslatableMessage associated with the given translation key, without any associated variables.
        Parameters:
        key - The translation key to associate with the TranslatableMessage.
      • TranslatableMessage

        public TranslatableMessage​(String key,
                                   Object variables)
        Creates a new TranslatableMessage associated with the given translation key and associated variables.
        Parameters:
        key - The translation key to associate with the TranslatableMessage.
        variables - An arbitrary object whose properties should be substituted for the corresponding placeholders within the string associated with the given translation key.
    • Method Detail

      • getKey

        public String getKey()
        Returns the arbitrary key which can be used to look up the message to be displayed in the user's native language.
        Returns:
        The arbitrary key associated with the human-readable message.
      • getVariables

        public Object getVariables()
        Returns an arbitrary object whose properties should be substituted for the corresponding placeholders within the string associated with the key. If not applicable, null is returned.
        Returns:
        An arbitrary object whose properties should be substituted for the corresponding placeholders within the string associated with the key, or null if not applicable.