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

public final Class RequestMethodsRequestCondition

extends AbstractRequestCondition<RequestMethodsRequestCondition>
Class Inheritance
Imports
java.util.Arrays, .Collection, .Collections, .LinkedHashSet, .Map, .Set, org.springframework.http.HttpMethod, org.springframework.http.server.reactive.ServerHttpRequest, org.springframework.lang.Nullable, org.springframework.util.CollectionUtils, .ObjectUtils, org.springframework.web.bind.annotation.RequestMethod, org.springframework.web.cors.reactive.CorsUtils, org.springframework.web.server.ServerWebExchange

A logical disjunction (' || ') request condition that matches a request against a set of RequestMethods.
Author
Rossen Stoyanchev
Since
5.0

Field Summary

Modifier and TypeField and Description
private final Set<RequestMethod>
private static final Map<HttpMethod, RequestMethodsRequestCondition>
requestMethodConditionCache

Per HTTP method cache to return ready instances from getMatchingCondition.

Constructor Summary

AccessConstructor and Description
public
RequestMethodsRequestCondition(RequestMethod...
0 or more HTTP request methods; if, 0 the condition will match to every request
requestMethods
)

Create a new instance with the given request methods.

private
RequestMethodsRequestCondition(Set<RequestMethod> requestMethods)

Private constructor for internal use when combining conditions.

Method Summary

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

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

Returns a new instance with a union of the HTTP request methods from "this" and the "other" instance.

public int
compareTo(RequestMethodsRequestCondition other, ServerWebExchange exchange)

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

Returns:

  • 0 if the two conditions contain the same number of HTTP request methods
  • Less than 0 if "this" instance has an HTTP request method but "other" doesn't
  • Greater than 0 "other" has an HTTP request method but "this" doesn't
protected Collection<RequestMethod>
getContent()

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

Return the discrete items a request condition is composed of.

public RequestMethodsRequestCondition

Returns:

the same instance if the condition is empty (unless the request method is HTTP OPTIONS), a new condition with the matched request method, or null if there is no match or the condition is empty and the request method is OPTIONS.
getMatchingCondition
(ServerWebExchange
the current exchange
exchange
)

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

Check if any of the HTTP request methods match the given request and return an instance that contains the matching HTTP request method only.

public Set<RequestMethod>
getMethods()

Returns all RequestMethods contained in this condition.

protected String
getToStringInfix()

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

The notation to use when printing discrete items of content.

private RequestMethodsRequestCondition
matchPreFlight(ServerHttpRequest request)

On a pre-flight request match to the would-be, actual request.

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

Field Detail

methodsback to summary
private final Set<RequestMethod> methods
requestMethodConditionCacheback to summary
private static final Map<HttpMethod, RequestMethodsRequestCondition> requestMethodConditionCache

Per HTTP method cache to return ready instances from getMatchingCondition.

Constructor Detail

RequestMethodsRequestConditionback to summary
public RequestMethodsRequestCondition(RequestMethod... requestMethods)

Create a new instance with the given request methods.

Parameters
requestMethods:RequestMethod[]

0 or more HTTP request methods; if, 0 the condition will match to every request

RequestMethodsRequestConditionback to summary
private RequestMethodsRequestCondition(Set<RequestMethod> requestMethods)

Private constructor for internal use when combining conditions.

Method Detail

combineback to summary
public RequestMethodsRequestCondition combine(RequestMethodsRequestCondition other)

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

Returns a new instance with a union of the HTTP request methods from "this" and the "other" instance.

Parameters
other:RequestMethodsRequestCondition

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

the condition to combine with.

Returns:RequestMethodsRequestCondition

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(RequestMethodsRequestCondition other, ServerWebExchange exchange)

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

Returns:

  • 0 if the two conditions contain the same number of HTTP request methods
  • Less than 0 if "this" instance has an HTTP request method but "other" doesn't
  • Greater than 0 "other" has an HTTP request method but "this" doesn't

It is assumed that both instances have been obtained via getMatchingCondition(ServerWebExchange) and therefore each instance contains the matching HTTP request method only or is otherwise empty.

Annotations
@Override
getContentback to summary
protected Collection<RequestMethod> 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<RequestMethod>

a collection of objects (never null)

Annotations
@Override
getMatchingConditionback to summary
public RequestMethodsRequestCondition getMatchingCondition(ServerWebExchange exchange)

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

Check if any of the HTTP request methods match the given request and return an instance that contains the matching HTTP request method only.

Parameters
exchange:ServerWebExchange

the current exchange

Returns:RequestMethodsRequestCondition

the same instance if the condition is empty (unless the request method is HTTP OPTIONS), a new condition with the matched request method, or null if there is no match or the condition is empty and the request method is OPTIONS.

Annotations
@Override
@Nullable
getMethodsback to summary
public Set<RequestMethod> getMethods()

Returns all RequestMethods contained in this condition.

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
matchPreFlightback to summary
private RequestMethodsRequestCondition matchPreFlight(ServerHttpRequest request)

On a pre-flight request match to the would-be, actual request. Hence empty conditions is a match, otherwise try to match to the HTTP method in the "Access-Control-Request-Method" header.

Annotations
@Nullable
matchRequestMethodback to summary
private RequestMethodsRequestCondition matchRequestMethod(HttpMethod httpMethod)
Annotations
@Nullable