类 PatternsRequestCondition
- java.lang.Object
- org.springframework.web.reactive.result.condition.AbstractRequestCondition<PatternsRequestCondition>
- org.springframework.web.reactive.result.condition.PatternsRequestCondition
- 所有已实现的接口:
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.- 从以下版本开始:
- 5.0
- 作者:
- Rossen Stoyanchev, Brian Clozel
构造器概要
构造器 构造器 说明 PatternsRequestCondition(List<PathPattern> patterns)
Creates a new instance with the given URL patterns.PatternsRequestCondition(PathPattern... patterns)
Creates a new instance with the given URL 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" usingPathPattern.combine(PathPattern)
.int
compareTo(PatternsRequestCondition other, ServerWebExchange exchange)
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.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.Set<PathPattern>
getPatterns()
protected String
getToStringInfix()
The notation to use when printing discrete items of content.从类继承的方法 org.springframework.web.reactive.result.condition.AbstractRequestCondition
equals, hashCode, isEmpty, toString
构造器详细资料
PatternsRequestCondition
public PatternsRequestCondition(PathPattern... patterns)
Creates a new instance with the given URL patterns.- 参数:
patterns
- 0 or more URL patterns; if 0 the condition will match to every request.
PatternsRequestCondition
public PatternsRequestCondition(List<PathPattern> patterns)
Creates a new instance with the given URL patterns.
方法详细资料
getPatterns
public Set<PathPattern> getPatterns()
getContent
protected Collection<PathPattern> getContent()
从类复制的说明:AbstractRequestCondition
Return the discrete items a request condition is composed of.For example URL patterns, HTTP request methods, param expressions, etc.
- 指定者:
getContent
在类中AbstractRequestCondition<PatternsRequestCondition>
- 返回:
- a collection of objects (never
null
)
getToStringInfix
protected String getToStringInfix()
从类复制的说明:AbstractRequestCondition
The notation to use when printing discrete items of content.For example
" || "
for URL patterns or" && "
for param expressions.
combine
public 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
PathPattern.combine(PathPattern)
. - If only one instance has patterns, use them.
- If neither instance has patterns, use an empty String (i.e. "").
- 参数:
other
- the condition to combine with.- 返回:
- 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
getMatchingCondition
@Nullable public 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.- 参数:
exchange
- the current exchange- 返回:
- the same instance if the condition contains no patterns; or a new condition with sorted matching patterns; or
null
if no patterns match.
compareTo
public int compareTo(PatternsRequestCondition other, 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.