Package io.inversion

Class Rule<R extends Rule>

java.lang.Object
io.inversion.Rule<R>
All Implemented Interfaces:
Comparable<R>
Direct Known Subclasses:
AclRule, Action, Collection, Db, Endpoint

public abstract class Rule<R extends Rule> extends Object implements Comparable<R>
Matches against an HTTP method and URL path to determine if the object should be included when processing the associated Request.

Matching relies heavily on variablized Path matching via Path.matches(String)

  • Field Details

    • ALL_METHODS

      public static final SortedSet<String> ALL_METHODS
    • log

      protected final transient org.slf4j.Logger log
    • includeMatchers

      protected final List<Rule.RuleMatcher> includeMatchers
      Method/path combinations that would cause this Rule to be included in the relevant processing.
    • excludeMatchers

      protected final List<Rule.RuleMatcher> excludeMatchers
      Method/path combinations that would cause this Rule to be excluded from the relevant processing.
    • configMap

      protected final transient io.inversion.json.JSMap configMap
      JSNode is used because it implements a case insensitive map without modifying the keys
    • name

      protected String name
      The name used for configuration and debug purposes.
    • order

      protected int order
      Rules are always processed in sequence sorted by ascending order.
    • includeOn

      protected String includeOn
      An optional querystring that will be applied to every request processed. This is useful to force specific params on different endpoints/actions etc.
    • excludeOn

      protected String excludeOn
    • description

      protected String description
    • params

      protected List<Param> params
  • Constructor Details

    • Rule

      public Rule()
  • Method Details

    • afterWiringComplete

      public void afterWiringComplete(io.inversion.context.Context context)
    • checkLazyConfig

      protected void checkLazyConfig()
    • doLazyConfig

      protected void doLazyConfig()
    • getDefaultIncludeMatchers

      protected List<Rule.RuleMatcher> getDefaultIncludeMatchers()
      Designed to allow subclasses to provide a default match behavior of no configuration was provided by the developer.
      Returns:
      the default include match "*","*"
    • matches

      public boolean matches(String method, String path)
      Check if the http method and path match this Rule.
      Parameters:
      method - the HTTP method to match
      path - the concrete path to match
      Returns:
      true if the http method and path are included and not excluded
    • matches

      public boolean matches(String method, io.inversion.utils.Path path)
      Check if the http method and path match this Rule.
      Parameters:
      method - the HTTP method to match
      path - the concrete path to match
      Returns:
      true if the http method and path are included and not excluded
    • match

      public io.inversion.utils.Path match(String method, io.inversion.utils.Path path)
      Find the first ordered Path that satisfies this method/path match.
      Parameters:
      method - the HTTP method to match
      path - the concrete path to match
      Returns:
      the first includeMatchers path to match when method also matches, null if no matches or excluded
    • match

      public io.inversion.utils.Path match(String method, io.inversion.utils.Path path, boolean bidirectional)
    • getAllIncludeMethods

      public List<String> getAllIncludeMethods()
    • getAllIncludePaths

      public List<io.inversion.utils.Path> getAllIncludePaths()
    • getAllExcludePaths

      public List<io.inversion.utils.Path> getAllExcludePaths()
    • getIncludeMatchers

      public List<Rule.RuleMatcher> getIncludeMatchers()
    • withIncludeOn

      public R withIncludeOn(Rule.RuleMatcher matcher)
    • withIncludeOn

      public R withIncludeOn(String... specs)
    • withExcludeOn

      public R withExcludeOn(Rule.RuleMatcher matcher)
      Don't select this Rule when RuleMatcher matches
      Parameters:
      matcher - the method/path combo to exclude
      Returns:
      this
    • withExcludeOn

      public R withExcludeOn(String... specs)
    • getExcludeMatchers

      public List<Rule.RuleMatcher> getExcludeMatchers()
    • getName

      public String getName()
    • withName

      public R withName(String name)
    • withDescription

      public Rule withDescription(String description)
    • getDescription

      public String getDescription()
    • getOrder

      public int getOrder()
    • withOrder

      public R withOrder(int order)
    • compareTo

      public int compareTo(Rule a)
      Specified by:
      compareTo in interface Comparable<R extends Rule>
    • getParams

      public List<Param> getParams()
    • withParams

      public R withParams(List<Param> params)
    • withParam

      public R withParam(Param param)
    • toString

      public String toString()
      Overrides:
      toString in class Object