Class PathPatternsRequestCondition
java.lang.Object
org.springframework.web.servlet.mvc.condition.AbstractRequestCondition<PathPatternsRequestCondition>
org.springframework.web.servlet.mvc.condition.PathPatternsRequestCondition
- All Implemented Interfaces:
- RequestCondition<PathPatternsRequestCondition>
public final class PathPatternsRequestCondition
extends AbstractRequestCondition<PathPatternsRequestCondition>
A logical disjunction (' || ') request condition that matches a request
 against a set of URL path patterns.
 
In contrast to PatternsRequestCondition, this condition uses
 parsed PathPatterns instead of String pattern matching with
 AntPathMatcher.
- Since:
- 5.3
- Author:
- Rossen Stoyanchev
- 
Constructor SummaryConstructorsConstructorDescriptionDefault constructor resulting in an""(empty path) mapping.PathPatternsRequestCondition(PathPatternParser parser, String... patterns) Constructor with patterns to use.
- 
Method SummaryModifier and TypeMethodDescriptionReturns 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" usingPathPattern.combine(PathPattern).intcompareTo(PathPatternsRequestCondition other, HttpServletRequest request) Compare the two conditions based on the URL patterns they contain.protected Collection<PathPattern>Return the discrete items a request condition is composed of.Return the mapping paths that are not patterns.Return the first pattern.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.Return the patterns in this condition.Return thegetPatterns()mapped to Strings.protected StringThe notation to use when printing discrete items of content.booleanWhether the condition is the "" (empty path) mapping.Methods inherited from class org.springframework.web.servlet.mvc.condition.AbstractRequestConditionequals, hashCode, isEmpty, toString
- 
Constructor Details- 
PathPatternsRequestConditionpublic PathPatternsRequestCondition()Default constructor resulting in an""(empty path) mapping.
- 
PathPatternsRequestConditionConstructor with patterns to use.
 
- 
- 
Method Details- 
getPatternsReturn the patterns in this condition. If only the first (top) pattern is needed usegetFirstPattern().
- 
getContentDescription copied from class:AbstractRequestConditionReturn the discrete items a request condition is composed of.For example URL patterns, HTTP request methods, param expressions, etc. - Specified by:
- getContentin class- AbstractRequestCondition<PathPatternsRequestCondition>
- Returns:
- a collection of objects (never null)
 
- 
getToStringInfixDescription copied from class:AbstractRequestConditionThe notation to use when printing discrete items of content.For example " || "for URL patterns or" && "for param expressions.- Specified by:
- getToStringInfixin class- AbstractRequestCondition<PathPatternsRequestCondition>
 
- 
getFirstPatternReturn the first pattern.
- 
isEmptyPathMappingpublic boolean isEmptyPathMapping()Whether the condition is the "" (empty path) mapping.
- 
getDirectPathsReturn the mapping paths that are not patterns.
- 
getPatternValuesReturn thegetPatterns()mapped to Strings.
- 
combineReturns 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).
- If only one instance has patterns, use them.
- If neither instance has patterns, use an empty String (i.e. "").
 - Parameters:
- other- the condition to combine with.
- Returns:
- a request condition instance that is the result of combining the two condition instances.
 
- If there are patterns in both instances, combine the patterns in
 "this" with the patterns in "other" using
 
- 
getMatchingConditionChecks if any of the patterns match the given request and returns an instance that is guaranteed to contain matching patterns, sorted.- Parameters:
- request- the current request
- Returns:
- the same instance if the condition contains no patterns;
 or a new condition with sorted matching patterns;
 or nullif no patterns match.
 
- 
compareToCompare the two conditions based on the URL patterns they contain. Patterns are compared one at a time, from top to bottom. 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(HttpServletRequest)to ensure they contain only patterns that match the request and are sorted with the best matches on top.
 
-