public final class PatternsRequestCondition extends AbstractRequestCondition<PatternsRequestCondition>
Modifier and Type | Field and Description |
---|---|
private java.util.Set<java.lang.String> |
fileExtensions |
private HttpRequestPathHelper |
pathHelper |
private PathMatcher |
pathMatcher |
private java.util.Set<java.lang.String> |
patterns |
private boolean |
useSuffixPatternMatch |
private boolean |
useTrailingSlashMatch |
Modifier | Constructor and Description |
---|---|
private |
PatternsRequestCondition(java.util.Collection<java.lang.String> patterns,
HttpRequestPathHelper pathHelper,
PathMatcher pathMatcher,
boolean useSuffixPatternMatch,
boolean useTrailingSlashMatch,
java.util.Set<java.lang.String> fileExtensions)
Private constructor accepting a collection of patterns.
|
|
PatternsRequestCondition(java.lang.String... patterns)
Creates a new instance with the given URL patterns.
|
|
PatternsRequestCondition(java.lang.String[] patterns,
HttpRequestPathHelper pathHelper,
PathMatcher pathMatcher,
boolean useSuffixPatternMatch,
boolean useTrailingSlashMatch,
java.util.Set<java.lang.String> extensions)
Creates a new instance with the given URL patterns.
|
Modifier and Type | Method and Description |
---|---|
private static java.util.List<java.lang.String> |
asList(java.lang.String... patterns) |
PatternsRequestCondition |
combine(PatternsRequestCondition other)
Returns a new instance with URL patterns from the current instance ("this") and
the "other" instance as follows:
If there are patterns in both instances, combine the patterns in "this" with
the patterns in "other" using
PathMatcher.combine(String, String) . |
int |
compareTo(PatternsRequestCondition other,
ServerWebExchange exchange)
Compare the two conditions based on the URL patterns they contain.
|
protected java.util.Collection<java.lang.String> |
getContent()
Return the discrete items a request condition is composed of.
|
PatternsRequestCondition |
getMatchingCondition(ServerWebExchange exchange)
Checks if any of the patterns match the given request and returns an instance
that is guaranteed to contain matching patterns, sorted via
PathMatcher.getPatternComparator(String) . |
private java.lang.String |
getMatchingPattern(java.lang.String pattern,
java.lang.String lookupPath) |
java.util.List<java.lang.String> |
getMatchingPatterns(java.lang.String lookupPath)
Find the patterns matching the given lookup path.
|
java.util.Set<java.lang.String> |
getPatterns() |
protected java.lang.String |
getToStringInfix()
The notation to use when printing discrete items of content.
|
private static java.util.Set<java.lang.String> |
prependLeadingSlash(java.util.Collection<java.lang.String> patterns) |
equals, hashCode, isEmpty, toString
private final java.util.Set<java.lang.String> patterns
private final HttpRequestPathHelper pathHelper
private final PathMatcher pathMatcher
private final boolean useSuffixPatternMatch
private final boolean useTrailingSlashMatch
private final java.util.Set<java.lang.String> fileExtensions
public PatternsRequestCondition(java.lang.String... patterns)
patterns
- 0 or more URL patterns; if 0 the condition will match to every request.public PatternsRequestCondition(java.lang.String[] patterns, HttpRequestPathHelper pathHelper, PathMatcher pathMatcher, boolean useSuffixPatternMatch, boolean useTrailingSlashMatch, java.util.Set<java.lang.String> extensions)
patterns
- the URL patterns to use; if 0, the condition will match to every request.pathHelper
- to determine the lookup path for a requestpathMatcher
- for pattern path matchinguseSuffixPatternMatch
- whether to enable matching by suffix (".*")useTrailingSlashMatch
- whether to match irrespective of a trailing slashextensions
- file extensions to consider for path matchingprivate PatternsRequestCondition(java.util.Collection<java.lang.String> patterns, HttpRequestPathHelper pathHelper, PathMatcher pathMatcher, boolean useSuffixPatternMatch, boolean useTrailingSlashMatch, java.util.Set<java.lang.String> fileExtensions)
private static java.util.List<java.lang.String> asList(java.lang.String... patterns)
private static java.util.Set<java.lang.String> prependLeadingSlash(java.util.Collection<java.lang.String> patterns)
public java.util.Set<java.lang.String> getPatterns()
protected java.util.Collection<java.lang.String> getContent()
AbstractRequestCondition
For example URL patterns, HTTP request methods, param expressions, etc.
getContent
in class AbstractRequestCondition<PatternsRequestCondition>
null
protected java.lang.String getToStringInfix()
AbstractRequestCondition
For example " || "
for URL patterns or " && "
for param expressions.
getToStringInfix
in class AbstractRequestCondition<PatternsRequestCondition>
public PatternsRequestCondition combine(PatternsRequestCondition other)
PathMatcher.combine(String, String)
.
other
- the condition to combine with.public PatternsRequestCondition getMatchingCondition(ServerWebExchange exchange)
PathMatcher.getPatternComparator(String)
.
A matching pattern is obtained by making checks in the following order:
exchange
- the current exchangenull
if no patterns match.public java.util.List<java.lang.String> getMatchingPatterns(java.lang.String lookupPath)
getMatchingCondition(ServerWebExchange)
.
This method is provided as an alternative to be used if no request is available
(e.g. introspection, tooling, etc).lookupPath
- the lookup path to match to existing patternsprivate java.lang.String getMatchingPattern(java.lang.String pattern, java.lang.String lookupPath)
public int compareTo(PatternsRequestCondition other, ServerWebExchange exchange)
PathMatcher.getPatternComparator(String)
. If all compared
patterns match equally, but one instance has more patterns, it is
considered a closer match.
It is assumed that both instances have been obtained via
getMatchingCondition(ServerWebExchange)
to ensure they
contain only patterns that match the request and are sorted with
the best matches on top.