Class PatternsRequestCondition
java.lang.Object
org.springframework.web.reactive.result.condition.AbstractRequestCondition<PatternsRequestCondition>
org.springframework.web.reactive.result.condition.PatternsRequestCondition
- All Implemented Interfaces:
RequestCondition<PatternsRequestCondition>
public final class PatternsRequestCondition
extends AbstractRequestCondition<PatternsRequestCondition>
A logical disjunction (' || ') request condition that matches a request
against a set of URL path patterns.
- Since:
- 5.0
- Author:
- Rossen Stoyanchev, Brian Clozel
-
Constructor Summary
ConstructorsConstructorDescriptionPatternsRequestCondition(List<org.springframework.web.util.pattern.PathPattern> patterns) Creates a new instance with the given URL patterns.PatternsRequestCondition(org.springframework.web.util.pattern.PathPattern... patterns) Creates a new instance with the given URL patterns. -
Method Summary
Modifier and TypeMethodDescriptioncombine(PatternsRequestCondition other) Combine the patterns of the current and of the other instances as follows: If only one instance has patterns, use those.intcompareTo(PatternsRequestCondition other, org.springframework.web.server.ServerWebExchange exchange) Compare the two conditions based on the URL patterns they contain.protected Collection<org.springframework.web.util.pattern.PathPattern>Return the discrete items a request condition is composed of.Return the mapping paths that are not patterns.getMatchingCondition(org.springframework.web.server.ServerWebExchange exchange) Checks if any of the patterns match the given request and returns an instance that is guaranteed to contain matching patterns, sorted.Set<org.springframework.web.util.pattern.PathPattern>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.reactive.result.condition.AbstractRequestCondition
equals, hashCode, isEmpty, toString
-
Constructor Details
-
PatternsRequestCondition
public PatternsRequestCondition(org.springframework.web.util.pattern.PathPattern... patterns) Creates a new instance with the given URL patterns.- Parameters:
patterns- 0 or more URL patterns; if 0 the condition will match to every request.
-
PatternsRequestCondition
Creates a new instance with the given URL patterns.
-
-
Method Details
-
getPatterns
-
getContent
Description 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 classAbstractRequestCondition<PatternsRequestCondition>- Returns:
- a collection of objects (never
null)
-
getToStringInfix
Description 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 classAbstractRequestCondition<PatternsRequestCondition>
-
isEmptyPathMapping
public boolean isEmptyPathMapping()Whether the condition is the "" (empty path) mapping.- Since:
- 6.0.10
-
getDirectPaths
Return the mapping paths that are not patterns.- Since:
- 5.3
-
combine
Combine the patterns of the current and of the other instances as follows:- If only one instance has patterns, use those.
- If both have patterns, combine patterns from "this" instance with
patterns from the other instance via
PathPattern.combine(PathPattern). - If neither has patterns, use
""and"/"as root path patterns.
- Parameters:
other- the condition to combine with.- Returns:
- a request condition instance that is the result of combining the two condition instances.
-
getMatchingCondition
@Nullable public PatternsRequestCondition getMatchingCondition(org.springframework.web.server.ServerWebExchange exchange) Checks if any of the patterns match the given request and returns an instance that is guaranteed to contain matching patterns, sorted.- Parameters:
exchange- the current exchange- Returns:
- the same instance if the condition contains no patterns;
or a new condition with sorted matching patterns;
or
nullif no patterns match.
-
compareTo
public int compareTo(PatternsRequestCondition other, org.springframework.web.server.ServerWebExchange exchange) Compare 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(ServerWebExchange)to ensure they contain only patterns that match the request and are sorted with the best matches on top.
-