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. Encapsulates the following request mapping conditions:PatternsRequestCondition
RequestMethodsRequestCondition
ParamsRequestCondition
HeadersRequestCondition
ConsumesRequestCondition
ProducesRequestCondition
RequestCondition
(optional, custom request condition)
- Since:
- 3.1
- Author:
- Arjen Poutsma, Rossen Stoyanchev
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
RequestMappingInfo.Builder
Defines a builder for creating a RequestMappingInfo.static class
RequestMappingInfo.BuilderConfiguration
Container for configuration options used for request mapping purposes.
Constructor Summary
Constructors Constructor Description RequestMappingInfo(String name, PatternsRequestCondition patterns, RequestMethodsRequestCondition methods, ParamsRequestCondition params, HeadersRequestCondition headers, ConsumesRequestCondition consumes, ProducesRequestCondition produces, RequestCondition<?> custom)
RequestMappingInfo(PatternsRequestCondition patterns, RequestMethodsRequestCondition methods, ParamsRequestCondition params, HeadersRequestCondition headers, ConsumesRequestCondition consumes, ProducesRequestCondition produces, RequestCondition<?> custom)
Creates a new instance with the given request conditions.RequestMappingInfo(RequestMappingInfo info, RequestCondition<?> customRequestCondition)
Re-create a RequestMappingInfo with the given custom request condition.
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description RequestMappingInfo
combine(RequestMappingInfo other)
Combine "this" request mapping info (i.e.int
compareTo(RequestMappingInfo other, HttpServletRequest request)
Compares "this" info (i.e.boolean
equals(Object other)
ConsumesRequestCondition
getConsumesCondition()
Return the "consumes" condition of thisRequestMappingInfo
; or instance with 0 consumes expressions (nevernull
).RequestCondition<?>
getCustomCondition()
Return the "custom" condition of thisRequestMappingInfo
, ornull
.HeadersRequestCondition
getHeadersCondition()
Return the "headers" condition of thisRequestMappingInfo
; or instance with 0 header expressions (nevernull
).RequestMappingInfo
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.RequestMethodsRequestCondition
getMethodsCondition()
Return the HTTP request methods of thisRequestMappingInfo
; or instance with 0 request methods (nevernull
).String
getName()
Return the name for this mapping, ornull
.ParamsRequestCondition
getParamsCondition()
Return the "parameters" condition of thisRequestMappingInfo
; or instance with 0 parameter expressions (nevernull
).PatternsRequestCondition
getPatternsCondition()
Return the URL patterns of thisRequestMappingInfo
; or instance with 0 patterns (nevernull
).ProducesRequestCondition
getProducesCondition()
Return the "produces" condition of thisRequestMappingInfo
; or instance with 0 produces expressions (nevernull
).int
hashCode()
static RequestMappingInfo.Builder
paths(String... paths)
Create a newRequestMappingInfo.Builder
with the given paths.String
toString()
Constructor Detail
RequestMappingInfo
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)
RequestMappingInfo
public RequestMappingInfo(@Nullable PatternsRequestCondition patterns, @Nullable RequestMethodsRequestCondition methods, @Nullable ParamsRequestCondition params, @Nullable HeadersRequestCondition headers, @Nullable ConsumesRequestCondition consumes, @Nullable ProducesRequestCondition produces, @Nullable RequestCondition<?> custom)
Creates a new instance with the given request conditions.
RequestMappingInfo
public RequestMappingInfo(RequestMappingInfo info, @Nullable RequestCondition<?> customRequestCondition)
Re-create a RequestMappingInfo with the given custom request condition.
Method Detail
getPatternsCondition
public PatternsRequestCondition getPatternsCondition()
Return the URL patterns of thisRequestMappingInfo
; or instance with 0 patterns (nevernull
).
getMethodsCondition
public RequestMethodsRequestCondition getMethodsCondition()
Return the HTTP request methods of thisRequestMappingInfo
; or instance with 0 request methods (nevernull
).
getParamsCondition
public ParamsRequestCondition getParamsCondition()
Return the "parameters" condition of thisRequestMappingInfo
; or instance with 0 parameter expressions (nevernull
).
getHeadersCondition
public HeadersRequestCondition getHeadersCondition()
Return the "headers" condition of thisRequestMappingInfo
; or instance with 0 header expressions (nevernull
).
getConsumesCondition
public ConsumesRequestCondition getConsumesCondition()
Return the "consumes" condition of thisRequestMappingInfo
; or instance with 0 consumes expressions (nevernull
).
getProducesCondition
public ProducesRequestCondition getProducesCondition()
Return the "produces" condition of thisRequestMappingInfo
; or instance with 0 produces expressions (nevernull
).
getCustomCondition
@Nullable public RequestCondition<?> getCustomCondition()
Return the "custom" condition of thisRequestMappingInfo
, ornull
.
combine
public RequestMappingInfo combine(RequestMappingInfo other)
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
@Nullable public RequestMappingInfo 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.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 all conditions match; or
null
otherwise
compareTo
public int compareTo(RequestMappingInfo other, HttpServletRequest request)
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>
paths
public static RequestMappingInfo.Builder paths(String... paths)
Create a newRequestMappingInfo.Builder
with the given paths.- Parameters:
paths
- the paths to use- Since:
- 4.2