Top Description Fields Constructors Methods
org.springframework.web.reactive.result.condition

public final Class PatternsRequestCondition

extends AbstractRequestCondition<PatternsRequestCondition>
Class Inheritance
Imports
java.util.Arrays, .Collection, .Collections, .HashSet, .Iterator, .List, .Set, .SortedSet, .TreeSet, org.springframework.http.server.PathContainer, org.springframework.lang.Nullable, org.springframework.util.ObjectUtils, org.springframework.web.server.ServerWebExchange, org.springframework.web.util.pattern.PathPattern, .PathPatternParser

A logical disjunction (' || ') request condition that matches a request against a set of URL path patterns.
Authors
Rossen Stoyanchev, Brian Clozel
Since
5.0

Field Summary

Modifier and TypeField and Description
private static final Set<String>
private static final SortedSet<PathPattern>
private final SortedSet<PathPattern>
private static final SortedSet<PathPattern>

Constructor Summary

AccessConstructor and Description
public
PatternsRequestCondition(PathPattern...
0 or more URL patterns; if 0 the condition will match to every request.
patterns
)

Creates a new instance with the given URL patterns.

public
PatternsRequestCondition(List<PathPattern> patterns)

Creates a new instance with the given URL patterns.

private

Method Summary

Modifier and TypeMethod and Description
public PatternsRequestCondition
combine(PatternsRequestCondition
the condition to combine with.
other
)

Implements org.springframework.web.reactive.result.condition.RequestCondition.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.
public int
compareTo(PatternsRequestCondition other, ServerWebExchange exchange)

Implements org.springframework.web.reactive.result.condition.RequestCondition.compareTo.

Compare the two conditions based on the URL patterns they contain.

protected Collection<PathPattern>
getContent()

Implements abstract org.springframework.web.reactive.result.condition.AbstractRequestCondition.getContent.

Return the discrete items a request condition is composed of.

public Set<String>
getDirectPaths()

Return the mapping paths that are not patterns.

public PatternsRequestCondition

Returns:

the same instance if the condition contains no patterns; or a new condition with sorted matching patterns; or null if no patterns match.
getMatchingCondition
(ServerWebExchange
the current exchange
exchange
)

Implements org.springframework.web.reactive.result.condition.RequestCondition.getMatchingCondition.

Checks if any of the patterns match the given request and returns an instance that is guaranteed to contain matching patterns, sorted.

private SortedSet<PathPattern>
public Set<PathPattern>
protected String
getToStringInfix()

Implements abstract org.springframework.web.reactive.result.condition.AbstractRequestCondition.getToStringInfix.

The notation to use when printing discrete items of content.

public boolean
isEmptyPathMapping()

Whether the condition is the "" (empty path) mapping.

Inherited from org.springframework.web.reactive.result.condition.AbstractRequestCondition:
equalshashCodeisEmptytoString

Field Detail

EMPTY_PATHback to summary
private static final Set<String> EMPTY_PATH
EMPTY_PATH_PATTERNback to summary
private static final SortedSet<PathPattern> EMPTY_PATH_PATTERN
patternsback to summary
private final SortedSet<PathPattern> patterns
ROOT_PATH_PATTERNSback to summary
private static final SortedSet<PathPattern> ROOT_PATH_PATTERNS

Constructor Detail

PatternsRequestConditionback to summary
public PatternsRequestCondition(PathPattern... patterns)

Creates a new instance with the given URL patterns.

Parameters
patterns:PathPattern[]

0 or more URL patterns; if 0 the condition will match to every request.

PatternsRequestConditionback to summary
public PatternsRequestCondition(List<PathPattern> patterns)

Creates a new instance with the given URL patterns.

PatternsRequestConditionback to summary
private PatternsRequestCondition(SortedSet<PathPattern> patterns)

Method Detail

combineback to summary
public PatternsRequestCondition combine(PatternsRequestCondition other)

Implements org.springframework.web.reactive.result.condition.RequestCondition.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:PatternsRequestCondition

Doc from org.springframework.web.reactive.result.condition.RequestCondition.combine.

the condition to combine with.

Returns:PatternsRequestCondition

Doc from org.springframework.web.reactive.result.condition.RequestCondition.combine.

a request condition instance that is the result of combining the two condition instances.

Annotations
@Override
compareToback to summary
public int compareTo(PatternsRequestCondition other, ServerWebExchange exchange)

Implements org.springframework.web.reactive.result.condition.RequestCondition.compareTo.

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.

Annotations
@Override
getContentback to summary
protected Collection<PathPattern> getContent()

Implements abstract org.springframework.web.reactive.result.condition.AbstractRequestCondition.getContent.

Doc from org.springframework.web.reactive.result.condition.AbstractRequestCondition.getContent.

Return the discrete items a request condition is composed of.

For example URL patterns, HTTP request methods, param expressions, etc.

Returns:Collection<PathPattern>

a collection of objects (never null)

Annotations
@Override
getDirectPathsback to summary
public Set<String> getDirectPaths()

Return the mapping paths that are not patterns.

Since
5.3
getMatchingConditionback to summary
public PatternsRequestCondition getMatchingCondition(ServerWebExchange exchange)

Implements org.springframework.web.reactive.result.condition.RequestCondition.getMatchingCondition.

Checks if any of the patterns match the given request and returns an instance that is guaranteed to contain matching patterns, sorted.

Parameters
exchange:ServerWebExchange

the current exchange

Returns:PatternsRequestCondition

the same instance if the condition contains no patterns; or a new condition with sorted matching patterns; or null if no patterns match.

Annotations
@Override
@Nullable
getMatchingPatternsback to summary
private SortedSet<PathPattern> getMatchingPatterns(ServerWebExchange exchange)
Annotations
@Nullable
getPatternsback to summary
public Set<PathPattern> getPatterns()
getToStringInfixback to summary
protected String getToStringInfix()

Implements abstract org.springframework.web.reactive.result.condition.AbstractRequestCondition.getToStringInfix.

Doc from org.springframework.web.reactive.result.condition.AbstractRequestCondition.getToStringInfix.

The notation to use when printing discrete items of content.

For example " || " for URL patterns or " && " for param expressions.

Annotations
@Override
isEmptyPathMappingback to summary
public boolean isEmptyPathMapping()

Whether the condition is the "" (empty path) mapping.

Since
6.0.10