Class TextMessage

java.lang.Object
ch.tocco.nice2.textresources.api.TextMessage
All Implemented Interfaces:
Serializable

public class TextMessage extends Object implements Serializable
Represents a text. Example usage: ``` TextMessage m = new TextMessage("my.key").setVar("name", obj); String s = textResources.formatTextMessage(m); ```
See Also:
  • Constructor Details

    • TextMessage

      public TextMessage(String key)
    • TextMessage

      public TextMessage(String key, Map<String,Object> vars)
    • TextMessage

      public TextMessage(@Nullable @Nullable String module, String key)
  • Method Details

    • setVar

      public TextMessage setVar(String key, Object val)
      Sets/overwrites a variable for this message with the given key.

      If such a placeholder in the message template is found then it will be replaced with the string representation of this value. The value may become localized.

      Returns:
      this
    • hasVars

      public boolean hasVars()
      Tells if this object has any variables that should be replaced in the text message's placeholders.
    • getVars

      public Map<String,Object> getVars()
    • hasModule

      public boolean hasModule()
      Tells if a module name is present.
    • getKey

      public String getKey()
    • setVars

      public void setVars(Map<String,Object> vars)
    • getModule

      public String getModule()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object