Top Description Methods
org.springframework.web.servlet.mvc.condition

public Interface RequestCondition<T>

Known Direct Implementers
org.springframework.web.servlet.mvc.method.RequestMappingInfo, org.springframework.web.servlet.mvc.condition.AbstractRequestCondition
Type Parameters
<T>
the type of objects that this RequestCondition can be combined with and compared to
Imports
jakarta.servlet.http.HttpServletRequest, org.springframework.lang.Nullable

Contract for request mapping conditions.

Request conditions can be combined via combine(Object), matched to a request via getMatchingCondition(HttpServletRequest), and compared to each other via compareTo(Object, HttpServletRequest) to determine which is a closer match for a given request.

Authors
Rossen Stoyanchev, Arjen Poutsma
Since
3.1

Method Summary

Modifier and TypeMethod and Description
public T

Returns:

a request condition instance that is the result of combining the two condition instances.
combine
(T
the condition to combine with.
other
)

Combine this condition with another such as conditions from a type-level and method-level @RequestMapping annotation.

public int
compareTo(T other, HttpServletRequest request)

Compare this condition to another condition in the context of a specific request.

public T

Returns:

a condition instance in case of a match or null otherwise.
getMatchingCondition
(HttpServletRequest request)

Check if the condition matches the request returning a potentially new instance created for the current request.

Method Detail

combineback to summary
public T combine(T other)

Combine this condition with another such as conditions from a type-level and method-level @RequestMapping annotation.

Parameters
other:T

the condition to combine with.

Returns:T

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

compareToback to summary
public int compareTo(T other, HttpServletRequest request)

Compare this condition to another condition in the context of a specific request. This method assumes both instances have been obtained via getMatchingCondition(HttpServletRequest) to ensure they have content relevant to current request only.

getMatchingConditionback to summary
public T getMatchingCondition(HttpServletRequest request)

Check if the condition matches the request returning a potentially new instance created for the current request. For example a condition with multiple URL patterns may return a new instance only with those patterns that match the request.

For CORS pre-flight requests, conditions should match to the would-be, actual request (e.g. URL pattern, query parameters, and the HTTP method from the "Access-Control-Request-Method" header). If a condition cannot be matched to a pre-flight request it should return an instance with empty content thus not causing a failure to match.

Returns:T

a condition instance in case of a match or null otherwise.

Annotations
@Nullable