Class RiskscapeMessage

java.lang.Object
nz.org.riskscape.engine.i18n.RiskscapeMessage
All Implemented Interfaces:
MessageKey

public class RiskscapeMessage extends Object implements MessageKey
  • Method Details

    • of

      public static RiskscapeMessage of(@NonNull @NonNull String code, Object... arguments)

      Build a RiskscapeMessage with desired code and messageArguments.

      Parameters:
      code -
      arguments -
      Returns:
      RiskscapeMessage with desired code and messageArguments
    • withDefault

      public static RiskscapeMessage withDefault(@NonNull @NonNull String code, @NonNull @NonNull String defaultMessage, Object... arguments)

      Build a RiskscapeMessage with desired code and messageArguments.

      Parameters:
      code -
      defaultMessage -
      arguments -
      Returns:
      RiskscapeMessage with default code and messageArguments
    • ofDefault

      public static RiskscapeMessage ofDefault(@NonNull @NonNull String defaultMessage, Object... args)

      Build a RiskscapeMessage that only contains the default message.

      Useful when API's require a RiskscapeMessage to be used but there are no reasonable codes to use. Such as when the message actually comes from user provided sources.

    • equals

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

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getCode

      public String getCode()
      Description copied from interface: MessageKey

      Return the code that identifies this message in ResourceBundle lookups.

      Specified by:
      getCode in interface MessageKey
    • getMessageArguments

      public Object[] getMessageArguments()
      Description copied from interface: MessageKey

      Return the array of arguments to be used to resolve this message.

      The default implementation simply returns null.

      Specified by:
      getMessageArguments in interface MessageKey
      Returns:
      an array of objects to be used as parameters to replace placeholders within the message text
    • getDefaultMessage

      public String getDefaultMessage()
      Description copied from interface: MessageKey

      Return the default message to be used to resolve this message should lookups of 'code' fail to find a message.

      Specified by:
      getDefaultMessage in interface MessageKey
      Returns:
      the default message, or null if no default