Class RequestMappingInfo
java.lang.Object
org.springframework.web.servlet.mvc.method.RequestMappingInfo
- All Implemented Interfaces:
RequestCondition<RequestMappingInfo>
public final class RequestMappingInfo
extends Object
implements RequestCondition<RequestMappingInfo>
Request mapping information. A composite for the following conditions:
PathPatternsRequestCondition
with parsedPathPatterns
orPatternsRequestCondition
with String patterns viaPathMatcher
RequestMethodsRequestCondition
ParamsRequestCondition
HeadersRequestCondition
ConsumesRequestCondition
ProducesRequestCondition
RequestCondition
(optional, custom request condition)
- Since:
- 3.1
- Author:
- Arjen Poutsma, Rossen Stoyanchev
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Defines a builder for creating a RequestMappingInfo.static class
Container for configuration options used for request mapping purposes. -
Constructor Summary
ConstructorDescriptionRequestMappingInfo
(String name, PatternsRequestCondition patterns, RequestMethodsRequestCondition methods, ParamsRequestCondition params, HeadersRequestCondition headers, ConsumesRequestCondition consumes, ProducesRequestCondition produces, RequestCondition<?> custom) Deprecated.RequestMappingInfo
(PatternsRequestCondition patterns, RequestMethodsRequestCondition methods, ParamsRequestCondition params, HeadersRequestCondition headers, ConsumesRequestCondition consumes, ProducesRequestCondition produces, RequestCondition<?> custom) Deprecated.as of 5.3 in favor usingRequestMappingInfo.Builder
viapaths(String...)
.RequestMappingInfo
(RequestMappingInfo info, RequestCondition<?> customRequestCondition) Deprecated.since 5.3 in favor of usingaddCustomCondition(RequestCondition)
. -
Method Summary
Modifier and TypeMethodDescriptionaddCustomCondition
(RequestCondition<?> customCondition) Create a new instance based on the current one, also adding the given custom condition.combine
(RequestMappingInfo other) Combine "this" request mapping info (i.e.int
compareTo
(RequestMappingInfo other, HttpServletRequest request) Compares "this" info (i.e.boolean
<T> RequestCondition<T>
Returns eithergetPathPatternsCondition()
orgetPatternsCondition()
depending on which is not null.Return the "consumes" condition of thisRequestMappingInfo
; or instance with 0 consumes expressions (nevernull
).Return the "custom" condition of thisRequestMappingInfo
, ornull
.Return the mapping paths that are not patterns.Return the "headers" condition of thisRequestMappingInfo
; or instance with 0 header expressions (nevernull
).getMatchingCondition
(HttpServletRequest request) Checks if all conditions in this request mapping info match the provided request and returns a potentially new request mapping info with conditions tailored to the current request.Return the HTTP request methods of thisRequestMappingInfo
; or instance with 0 request methods (nevernull
).getName()
Return the name for this mapping, ornull
.Return the "parameters" condition of thisRequestMappingInfo
; or instance with 0 parameter expressions (nevernull
).Return the patterns condition in use when parsed patterns areenabled
.Return the patterns condition when String pattern matching viaPathMatcher
is in use.Return the patterns for theactive
patterns condition as Strings.Return the "produces" condition of thisRequestMappingInfo
; or instance with 0 produces expressions (nevernull
).int
hashCode()
mutate()
Return a builder to create a new RequestMappingInfo by modifying this one.static RequestMappingInfo.Builder
Create a newRequestMappingInfo.Builder
with the given paths.toString()
-
Constructor Details
-
RequestMappingInfo
@Deprecated public RequestMappingInfo(@Nullable String name, @Nullable PatternsRequestCondition patterns, @Nullable RequestMethodsRequestCondition methods, @Nullable ParamsRequestCondition params, @Nullable HeadersRequestCondition headers, @Nullable ConsumesRequestCondition consumes, @Nullable ProducesRequestCondition produces, @Nullable RequestCondition<?> custom) Deprecated.as of 5.3 in favor usingRequestMappingInfo.Builder
viapaths(String...)
.Full constructor with a mapping name. -
RequestMappingInfo
@Deprecated public RequestMappingInfo(@Nullable PatternsRequestCondition patterns, @Nullable RequestMethodsRequestCondition methods, @Nullable ParamsRequestCondition params, @Nullable HeadersRequestCondition headers, @Nullable ConsumesRequestCondition consumes, @Nullable ProducesRequestCondition produces, @Nullable RequestCondition<?> custom) Deprecated.as of 5.3 in favor usingRequestMappingInfo.Builder
viapaths(String...)
.Create an instance with the given conditions. -
RequestMappingInfo
@Deprecated public RequestMappingInfo(RequestMappingInfo info, @Nullable RequestCondition<?> customRequestCondition) Deprecated.since 5.3 in favor of usingaddCustomCondition(RequestCondition)
.Re-create a RequestMappingInfo with the given custom request condition.
-
-
Method Details
-
getName
Return the name for this mapping, ornull
. -
getPathPatternsCondition
Return the patterns condition in use when parsed patterns areenabled
.This is mutually exclusive with
getPatternsCondition()
such that when one returnsnull
the other one returns an instance.- Since:
- 5.3
- See Also:
-
getPatternsCondition
Return the patterns condition when String pattern matching viaPathMatcher
is in use.This is mutually exclusive with
getPathPatternsCondition()
such that when one returnsnull
the other one returns an instance. -
getActivePatternsCondition
Returns eithergetPathPatternsCondition()
orgetPatternsCondition()
depending on which is not null.- Since:
- 5.3
-
getDirectPaths
Return the mapping paths that are not patterns.- Since:
- 5.3
-
getPatternValues
Return the patterns for theactive
patterns condition as Strings.- Since:
- 5.3
-
getMethodsCondition
Return the HTTP request methods of thisRequestMappingInfo
; or instance with 0 request methods (nevernull
). -
getParamsCondition
Return the "parameters" condition of thisRequestMappingInfo
; or instance with 0 parameter expressions (nevernull
). -
getHeadersCondition
Return the "headers" condition of thisRequestMappingInfo
; or instance with 0 header expressions (nevernull
). -
getConsumesCondition
Return the "consumes" condition of thisRequestMappingInfo
; or instance with 0 consumes expressions (nevernull
). -
getProducesCondition
Return the "produces" condition of thisRequestMappingInfo
; or instance with 0 produces expressions (nevernull
). -
getCustomCondition
Return the "custom" condition of thisRequestMappingInfo
, ornull
. -
addCustomCondition
Create a new instance based on the current one, also adding the given custom condition.- Parameters:
customCondition
- the custom condition to add- Since:
- 5.3
-
combine
Combine "this" request mapping info (i.e. the current instance) with another request mapping info instance.Example: combine type- and method-level request mappings.
- Specified by:
combine
in interfaceRequestCondition<RequestMappingInfo>
- Parameters:
other
- the condition to combine with.- Returns:
- a new request mapping info instance; never
null
-
getMatchingCondition
Checks if all conditions in this request mapping info match the provided request and returns a potentially new request mapping info with conditions tailored to the current request.For example the returned instance may contain the subset of URL patterns that match to the current request, sorted with best matching patterns on top.
- Specified by:
getMatchingCondition
in interfaceRequestCondition<RequestMappingInfo>
- Returns:
- a new instance in case of a match; or
null
otherwise
-
compareTo
Compares "this" info (i.e. the current instance) with another info in the context of a request.Note: It is assumed both instances have been obtained via
getMatchingCondition(HttpServletRequest)
to ensure they have conditions with content relevant to current request.- Specified by:
compareTo
in interfaceRequestCondition<RequestMappingInfo>
-
equals
-
hashCode
public int hashCode() -
toString
-
mutate
Return a builder to create a new RequestMappingInfo by modifying this one.- Returns:
- a builder to create a new, modified instance
- Since:
- 5.3.4
-
paths
Create a newRequestMappingInfo.Builder
with the given paths.- Parameters:
paths
- the paths to use- Since:
- 4.2
-
RequestMappingInfo.Builder
viapaths(String...)
.