Class MessageResolver
java.lang.Object
com.atlassian.oai.validator.report.MessageResolver
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 Summary
ConstructorsConstructorDescriptionCreate a new instance with the defaultLevelResolver(all messages will be emitted at the ERROR level).MessageResolver(LevelResolver levelResolver) Create a new instance with the provided {LevelResolver}. -
Method Summary
Modifier and TypeMethodDescriptionCreate a message with the given key and message.Get the message with the given key.Get the level that the given message key would be resolved at when using theget(java.lang.String, java.lang.Object...)orcreate(java.lang.String, java.lang.String, java.lang.String...)methods.booleanDetermine if the message with the given key would be resolved with a level ofValidationReport.Level.IGNORE.
-
Constructor Details
-
MessageResolver
public MessageResolver()Create a new instance with the defaultLevelResolver(all messages will be emitted at the ERROR level).- See Also:
-
MessageResolver
Create a new instance with the provided {LevelResolver}.
-
-
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
nullif 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
LevelResolverto 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
Get the level that the given message key would be resolved at when using theget(java.lang.String, java.lang.Object...)orcreate(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
Determine if the message with the given key would be resolved with a level ofValidationReport.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:
trueif the given message key will be ignored;falseotherwise.
-