public final class PathPatternsRequestCondition extends AbstractRequestCondition<PathPatternsRequestCondition>
In contrast to PatternsRequestCondition
, this condition uses
parsed PathPattern
s instead of String pattern matching with
AntPathMatcher
.
Constructor and Description |
---|
PathPatternsRequestCondition()
Default constructor resulting in an
"" (empty path) mapping. |
PathPatternsRequestCondition(PathPatternParser parser,
String... patterns)
Constructor with patterns to use.
|
Modifier and Type | Method and Description |
---|---|
PathPatternsRequestCondition |
combine(PathPatternsRequestCondition 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
PathPattern.combine(PathPattern) . |
int |
compareTo(PathPatternsRequestCondition other,
HttpServletRequest request)
Compare the two conditions based on the URL patterns they contain.
|
protected Collection<PathPattern> |
getContent()
Return the discrete items a request condition is composed of.
|
Set<String> |
getDirectPaths()
Return the mapping paths that are not patterns.
|
PathPattern |
getFirstPattern()
Return the first pattern.
|
PathPatternsRequestCondition |
getMatchingCondition(HttpServletRequest request)
Checks if any of the patterns match the given request and returns an
instance that is guaranteed to contain matching patterns, sorted.
|
Set<PathPattern> |
getPatterns()
Return the patterns in this condition.
|
Set<String> |
getPatternValues()
Return the
getPatterns() mapped to Strings. |
protected String |
getToStringInfix()
The notation to use when printing discrete items of content.
|
boolean |
isEmptyPathMapping()
Whether the condition is the "" (empty path) mapping.
|
equals, hashCode, isEmpty, toString
public PathPatternsRequestCondition()
""
(empty path) mapping.public PathPatternsRequestCondition(PathPatternParser parser, String... patterns)
public Set<PathPattern> getPatterns()
getFirstPattern()
.protected Collection<PathPattern> getContent()
AbstractRequestCondition
For example URL patterns, HTTP request methods, param expressions, etc.
getContent
in class AbstractRequestCondition<PathPatternsRequestCondition>
null
)protected String getToStringInfix()
AbstractRequestCondition
For example " || "
for URL patterns or " && "
for param expressions.
getToStringInfix
in class AbstractRequestCondition<PathPatternsRequestCondition>
public PathPattern getFirstPattern()
public boolean isEmptyPathMapping()
public Set<String> getPatternValues()
getPatterns()
mapped to Strings.public PathPatternsRequestCondition combine(PathPatternsRequestCondition other)
PathPattern.combine(PathPattern)
.
other
- the condition to combine with.@Nullable public PathPatternsRequestCondition getMatchingCondition(HttpServletRequest request)
request
- the current requestnull
if no patterns match.public int compareTo(PathPatternsRequestCondition other, HttpServletRequest request)
It is assumed that both instances have been obtained via
getMatchingCondition(HttpServletRequest)
to ensure they
contain only patterns that match the request and are sorted with
the best matches on top.