Class MessageResolver

java.lang.Object
com.atlassian.oai.validator.report.MessageResolver

public class MessageResolver extends Object
Resolves a message key to a ValidationReport.Message object.

Message Strings are resolved from the messages resource bundle.

Message levels are resolved using a configured LevelResolver.

See Also:
  • Constructor Details

  • Method Details

    • get

      Get the message with the given key.

      If no message is found for the key will return null.

      Parameters:
      key - The key of the message to retrieve.
      args - Arguments to use when resolving the message String.
      Returns:
      The message for the given key, or null if no message is found
    • create

      public ValidationReport.Message create(@Nonnull String key, String message, String... additionalInfo)
      Create a message with the given key and message.

      Used when translating validation messages from other sources (e.g. JSON schema validation) where a message has already been generated.

      Uses the configured LevelResolver to resolve the message level.

      Parameters:
      key - The key to include in the message.
      message - The message to include.
      additionalInfo - Additional information to include in the message (if any).
      Returns:
      A message that contains the given key and message string. The level will be set by the configured LevelResolver.
    • getLevel

      public ValidationReport.Level getLevel(@Nonnull String key)
      Get the level that the given message key would be resolved at when using the get(java.lang.String, java.lang.Object...) or create(java.lang.String, java.lang.String, java.lang.String...) methods.

      Used in a small number of places where optimisations can be made if a validation will be ignored.

      Parameters:
      key - The message key to test
      Returns:
      The level the given message key will be resolved at, as determined by the configured LevelResolver.
    • isIgnored

      public boolean isIgnored(@Nonnull String key)
      Determine if the message with the given key would be resolved with a level of ValidationReport.Level.IGNORE.

      Used in a small number of places where optimisations can be made if a validation will be ignored.

      Parameters:
      key - The message key to test
      Returns:
      true if the given message key will be ignored; false otherwise.