Package org.springframework.web.servlet.mvc.method

# 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:

1. `PathPatternsRequestCondition` with parsed `PathPatterns` or `PatternsRequestCondition` with String patterns via `PathMatcher`
2. `RequestMethodsRequestCondition`
3. `ParamsRequestCondition`
4. `HeadersRequestCondition`
5. `ConsumesRequestCondition`
6. `ProducesRequestCondition`
7. `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)`
Deprecated.
as of 5.3 in favor using `RequestMappingInfo.Builder` via `paths(String...)`.
`RequestMappingInfo(PatternsRequestCondition patterns, RequestMethodsRequestCondition methods, ParamsRequestCondition params, HeadersRequestCondition headers, ConsumesRequestCondition consumes, ProducesRequestCondition produces, RequestCondition<?> custom)`
Deprecated.
as of 5.3 in favor using `RequestMappingInfo.Builder` via `paths(String...)`.
`RequestMappingInfo(RequestMappingInfo info, RequestCondition<?> customRequestCondition)`
Deprecated.
since 5.3 in favor of using `addCustomCondition(RequestCondition)`.

## Method Summary

Modifier and Type
Method
Description
`RequestMappingInfo`
`addCustomCondition(RequestCondition<?> customCondition)`
Create a new instance based on the current one, also adding the given custom condition.
`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)`
`<T> RequestCondition<T>`
`getActivePatternsCondition()`
Returns either `getPathPatternsCondition()` or `getPatternsCondition()` depending on which is not null.
`ConsumesRequestCondition`
`getConsumesCondition()`
Return the "consumes" condition of this `RequestMappingInfo`; or instance with 0 consumes expressions (never `null`).
`RequestCondition<?>`
`getCustomCondition()`
Return the "custom" condition of this `RequestMappingInfo`, or `null`.
`Set<String>`
`getDirectPaths()`
Return the mapping paths that are not patterns.
`HeadersRequestCondition`
`getHeadersCondition()`
Return the "headers" condition of this `RequestMappingInfo`; or instance with 0 header expressions (never `null`).
`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 this `RequestMappingInfo`; or instance with 0 request methods (never `null`).
`String`
`getName()`
Return the name for this mapping, or `null`.
`ParamsRequestCondition`
`getParamsCondition()`
Return the "parameters" condition of this `RequestMappingInfo`; or instance with 0 parameter expressions (never `null`).
`PathPatternsRequestCondition`
`getPathPatternsCondition()`
Return the patterns condition in use when parsed patterns are `enabled`.
`PatternsRequestCondition`
`getPatternsCondition()`
Return the patterns condition when String pattern matching via `PathMatcher` is in use.
`Set<String>`
`getPatternValues()`
Return the patterns for the `active` patterns condition as Strings.
`ProducesRequestCondition`
`getProducesCondition()`
Return the "produces" condition of this `RequestMappingInfo`; or instance with 0 produces expressions (never `null`).
`int`
`hashCode()`
`boolean`
`isEmptyMapping()`
Whether the request mapping has an empty URL path mapping.
`RequestMappingInfo.Builder`
`mutate()`
Return a builder to create a new RequestMappingInfo by modifying this one.
`static RequestMappingInfo.Builder`
`paths(String... paths)`
Create a new `RequestMappingInfo.Builder` with the given paths.
`String`
`toString()`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

## 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 using `RequestMappingInfo.Builder` via `paths(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 using `RequestMappingInfo.Builder` via `paths(String...)`.
Create an instance with the given conditions.

### RequestMappingInfo

@Deprecated public RequestMappingInfo(RequestMappingInfo info, @Nullable RequestCondition<?> customRequestCondition)
Deprecated.
since 5.3 in favor of using `addCustomCondition(RequestCondition)`.
Re-create a RequestMappingInfo with the given custom request condition.

## Method Details

### getName

@Nullable public String getName()
Return the name for this mapping, or `null`.

### getPathPatternsCondition

@Nullable public PathPatternsRequestCondition getPathPatternsCondition()
Return the patterns condition in use when parsed patterns are `enabled`.

This is mutually exclusive with `getPatternsCondition()` such that when one returns `null` the other one returns an instance.

Since:
  5.3
See Also:
  - `getActivePatternsCondition()`

### getPatternsCondition

@Nullable public PatternsRequestCondition getPatternsCondition()
Return the patterns condition when String pattern matching via `PathMatcher` is in use.

This is mutually exclusive with `getPathPatternsCondition()` such that when one returns `null` the other one returns an instance.

### getActivePatternsCondition

public <T> RequestCondition<T> getActivePatternsCondition()
Returns either `getPathPatternsCondition()` or `getPatternsCondition()` depending on which is not null.

Since:
  5.3

### getDirectPaths

public Set<String> getDirectPaths()
Return the mapping paths that are not patterns.

Since:
  5.3

### getPatternValues

public Set<String> getPatternValues()
Return the patterns for the `active` patterns condition as Strings.

Since:
  5.3

### isEmptyMapping

public boolean isEmptyMapping()
Whether the request mapping has an empty URL path mapping.

Since:
  6.0.10

### getMethodsCondition

public RequestMethodsRequestCondition getMethodsCondition()
Return the HTTP request methods of this `RequestMappingInfo`; or instance with 0 request methods (never `null`).

### getParamsCondition

public ParamsRequestCondition getParamsCondition()
Return the "parameters" condition of this `RequestMappingInfo`; or instance with 0 parameter expressions (never `null`).

### getHeadersCondition

public HeadersRequestCondition getHeadersCondition()
Return the "headers" condition of this `RequestMappingInfo`; or instance with 0 header expressions (never `null`).

### getConsumesCondition

public ConsumesRequestCondition getConsumesCondition()
Return the "consumes" condition of this `RequestMappingInfo`; or instance with 0 consumes expressions (never `null`).

### getProducesCondition

public ProducesRequestCondition getProducesCondition()
Return the "produces" condition of this `RequestMappingInfo`; or instance with 0 produces expressions (never `null`).

### getCustomCondition

@Nullable public RequestCondition<?> getCustomCondition()
Return the "custom" condition of this `RequestMappingInfo`, or `null`.

### addCustomCondition

public RequestMappingInfo addCustomCondition(RequestCondition<?> customCondition)
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

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 interface `RequestCondition<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 interface `RequestCondition<RequestMappingInfo>`
Returns:
  a new instance in case of a 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 interface `RequestCondition<RequestMappingInfo>`

### equals

public boolean equals(@Nullable Object other)

Overrides:
  `equals` in class `Object`

### hashCode

public int hashCode()

Overrides:
  `hashCode` in class `Object`

### toString

public String toString()

Overrides:
  `toString` in class `Object`

### mutate

public RequestMappingInfo.Builder 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

public static RequestMappingInfo.Builder paths(String... paths)
Create a new `RequestMappingInfo.Builder` with the given paths.

Parameters:
  `paths` - the paths to use
Since:
  4.2