Class LevelResolver

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

public class LevelResolver extends Object
Resolves the ValidationReport.Level for a given message key.

Levels are specified hierarchically - if a level is not found for the given key it will inherit the level of its parent key. If no level is found for any parent key the defaultLevel will be returned.

For example:

     validation.request=ERROR
     validation.request.body=WARN

     getLevel("validation.request.body.missing") == WARN
     getLevel("validation.request.parameter.query.missing") == ERROR
 
See Also:
  • Method Details

    • create

      public static LevelResolver.Builder create()
      Create a new LevelResolver instance using a builder to obtain configuration.
      Returns:
      a new builder to use for creating LevelResolver instances.
    • defaultResolver

      public static LevelResolver defaultResolver()
      Create a new default LevelResolver.

      This resolver will load levels using the LevelLoader.defaultLoaderChain() and apply a default level of ValidationReport.Level.ERROR.

      Returns:
      a new LevelResolver with default configuration.
    • getLevel

      Gets the ValidationReport.Level for the given message key.

      Levels are specified hierarchically - if a level is not found for the given key it will inherit the level of its parent key. If no level is found for any parent key the defaultLevel will be returned.

      For example:

           validation.request=ERROR
           validation.request.body=WARN
      
           getLevel("validation.request.body.missing") == WARN
           getLevel("validation.request.parameter.query.missing") == ERROR
       
      Parameters:
      key - the message key to resolve e.g. "validation.request.body.missing"
      Returns:
      The level to use for the given message key