Package io.inversion
Class Rule<R extends Rule>
- java.lang.Object
-
- io.inversion.Rule<R>
-
- All Implemented Interfaces:
java.lang.Comparable<R>
- Direct Known Subclasses:
AclRule,Action,Collection,Db,Endpoint
public abstract class Rule<R extends Rule> extends java.lang.Object implements java.lang.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)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRule.RuleMatcher
-
Field Summary
Fields Modifier and Type Field Description static java.util.SortedSet<java.lang.String>ALL_METHODSprotected io.inversion.json.JSMapconfigMapJSNodeis used because it implements a case insensitive map without modifying the keysprotected java.lang.Stringdescriptionprotected java.util.List<Rule.RuleMatcher>excludeMatchersMethod/path combinations that would cause this Rule to be excluded from the relevant processing.protected java.lang.StringexcludeOnprotected java.util.List<Rule.RuleMatcher>includeMatchersMethod/path combinations that would cause this Rule to be included in the relevant processing.protected java.lang.StringincludeOnAn optional querystring that will be applied to every request processed.protected org.slf4j.Loggerlogprotected java.lang.StringnameThe name used for configuration and debug purposes.protected intorderRules are always processed in sequence sorted by ascending order.protected java.util.List<Param>params
-
Constructor Summary
Constructors Constructor Description Rule()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterWiringComplete(io.inversion.context.Context context)protected voidcheckLazyConfig()intcompareTo(Rule a)protected voiddoLazyConfig()java.util.List<io.inversion.utils.Path>getAllExcludePaths()java.util.List<java.lang.String>getAllIncludeMethods()java.util.List<io.inversion.utils.Path>getAllIncludePaths()protected java.util.List<Rule.RuleMatcher>getDefaultIncludeMatchers()Designed to allow subclasses to provide a default match behavior of no configuration was provided by the developer.java.lang.StringgetDescription()java.util.List<Rule.RuleMatcher>getExcludeMatchers()java.util.List<Rule.RuleMatcher>getIncludeMatchers()java.lang.StringgetName()intgetOrder()java.util.List<Param>getParams()io.inversion.utils.Pathmatch(java.lang.String method, io.inversion.utils.Path path)Find the first ordered Path that satisfies this method/path match.io.inversion.utils.Pathmatch(java.lang.String method, io.inversion.utils.Path path, boolean bidirectional)booleanmatches(java.lang.String method, io.inversion.utils.Path path)Check if the http method and path match this Rule.booleanmatches(java.lang.String method, java.lang.String path)Check if the http method and path match this Rule.java.lang.StringtoString()RulewithDescription(java.lang.String description)RwithExcludeOn(Rule.RuleMatcher matcher)Don't select this Rule when RuleMatcher matchesRwithExcludeOn(java.lang.String... specs)RwithIncludeOn(Rule.RuleMatcher matcher)RwithIncludeOn(java.lang.String... specs)RwithName(java.lang.String name)RwithOrder(int order)RwithParam(Param param)RwithParams(java.util.List<Param> params)
-
-
-
Field Detail
-
ALL_METHODS
public static final java.util.SortedSet<java.lang.String> ALL_METHODS
-
log
protected final transient org.slf4j.Logger log
-
includeMatchers
protected final java.util.List<Rule.RuleMatcher> includeMatchers
Method/path combinations that would cause this Rule to be included in the relevant processing.
-
excludeMatchers
protected final java.util.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
JSNodeis used because it implements a case insensitive map without modifying the keys
-
name
protected java.lang.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 java.lang.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 java.lang.String excludeOn
-
description
protected java.lang.String description
-
params
protected java.util.List<Param> params
-
-
Method Detail
-
afterWiringComplete
public void afterWiringComplete(io.inversion.context.Context context)
-
checkLazyConfig
protected void checkLazyConfig()
-
doLazyConfig
protected void doLazyConfig()
-
getDefaultIncludeMatchers
protected java.util.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(java.lang.String method, java.lang.String path)Check if the http method and path match this Rule.- Parameters:
method- the HTTP method to matchpath- the concrete path to match- Returns:
- true if the http method and path are included and not excluded
-
matches
public boolean matches(java.lang.String method, io.inversion.utils.Path path)Check if the http method and path match this Rule.- Parameters:
method- the HTTP method to matchpath- 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(java.lang.String method, io.inversion.utils.Path path)Find the first ordered Path that satisfies this method/path match.- Parameters:
method- the HTTP method to matchpath- 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(java.lang.String method, io.inversion.utils.Path path, boolean bidirectional)
-
getAllIncludeMethods
public java.util.List<java.lang.String> getAllIncludeMethods()
-
getAllIncludePaths
public java.util.List<io.inversion.utils.Path> getAllIncludePaths()
-
getAllExcludePaths
public java.util.List<io.inversion.utils.Path> getAllExcludePaths()
-
getIncludeMatchers
public java.util.List<Rule.RuleMatcher> getIncludeMatchers()
-
withIncludeOn
public R withIncludeOn(Rule.RuleMatcher matcher)
-
withIncludeOn
public R withIncludeOn(java.lang.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(java.lang.String... specs)
-
getExcludeMatchers
public java.util.List<Rule.RuleMatcher> getExcludeMatchers()
-
getName
public java.lang.String getName()
-
withName
public R withName(java.lang.String name)
-
withDescription
public Rule withDescription(java.lang.String description)
-
getDescription
public java.lang.String getDescription()
-
getOrder
public int getOrder()
-
withOrder
public R withOrder(int order)
-
compareTo
public int compareTo(Rule a)
-
getParams
public java.util.List<Param> getParams()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-