Class VersionRequestCondition
- All Implemented Interfaces:
RequestCondition<VersionRequestCondition>
RequestMapping.version()
.- Since:
- 7.0
- Author:
- Rossen Stoyanchev
-
Constructor Summary
ConstructorsConstructorDescriptionVersionRequestCondition
(String configuredVersion, ApiVersionStrategy versionStrategy) -
Method Summary
Modifier and TypeMethodDescriptioncombine
(VersionRequestCondition other) Combine this condition with another such as conditions from a type-level and method-level@RequestMapping
annotation.int
compareTo
(VersionRequestCondition other, HttpServletRequest request) Compare this condition to another condition in the context of a specific request.protected Collection<String>
Return the discrete items a request condition is composed of.getMatchingCondition
(HttpServletRequest request) Check if the condition matches the request returning a potentially new instance created for the current request.protected String
The notation to use when printing discrete items of content.void
handleMatch
(HttpServletRequest request) Perform a final check on the matched request mapping version.Methods inherited from class org.springframework.web.servlet.mvc.condition.AbstractRequestCondition
equals, hashCode, isEmpty, toString
-
Constructor Details
-
VersionRequestCondition
public VersionRequestCondition() -
VersionRequestCondition
-
-
Method Details
-
getContent
Description copied from class:AbstractRequestCondition
Return the discrete items a request condition is composed of.For example URL patterns, HTTP request methods, param expressions, etc.
- Specified by:
getContent
in classAbstractRequestCondition<VersionRequestCondition>
- Returns:
- a collection of objects (never
null
)
-
getToStringInfix
Description copied from class:AbstractRequestCondition
The notation to use when printing discrete items of content.For example
" || "
for URL patterns or" && "
for param expressions.- Specified by:
getToStringInfix
in classAbstractRequestCondition<VersionRequestCondition>
-
getVersion
-
combine
Description copied from interface:RequestCondition
Combine this condition with another such as conditions from a type-level and method-level@RequestMapping
annotation.- Parameters:
other
- the condition to combine with.- Returns:
- a request condition instance that is the result of combining the two condition instances.
-
getMatchingCondition
Description copied from interface:RequestCondition
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 (for example, 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:
- a condition instance in case of a match or
null
otherwise.
-
compareTo
Description copied from interface:RequestCondition
Compare this condition to another condition in the context of a specific request. This method assumes both instances have been obtained viaRequestCondition.getMatchingCondition(HttpServletRequest)
to ensure they have content relevant to current request only. -
handleMatch
Perform a final check on the matched request mapping version.In order to ensure baseline versions are properly capped by higher fixed versions, initially we match all versions as baseline versions in
getMatchingCondition(HttpServletRequest)
. Once the highest of potentially multiple matches is selected, we enforce the strict match for fixed versions.For example, given controller methods for "1.2+" and "1.5", and a request for "1.6", both are matched, allowing "1.5" to be selected, but that is then rejected as not acceptable since it is not an exact match.
- Parameters:
request
- the current request- Throws:
NotAcceptableApiVersionException
- if the matched condition has a fixed version that is not equal to the request version
-