Class VersionRequestCondition
- All Implemented Interfaces:
RequestCondition<VersionRequestCondition>
RequestMapping.version().- Since:
- 7.0
- Author:
- Rossen Stoyanchev
-
Constructor Summary
ConstructorsConstructorDescriptionVersionRequestCondition(@Nullable String version, @Nullable ApiVersionStrategy strategy) Constructor with the version, if set on the@RequestMapping, and theApiVersionStrategy, if API versioning is enabled. -
Method Summary
Modifier and TypeMethodDescriptioncombine(VersionRequestCondition other) Combine this condition with another such as conditions from a type-level and method-level@RequestMappingannotation.intcompareTo(VersionRequestCondition other, ServerWebExchange exchange) 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(ServerWebExchange exchange) Check if the condition matches the request returning a potentially new instance created for the current request.protected StringThe notation to use when printing discrete items of content.Return the raw version value.voidhandleMatch(ServerWebExchange exchange) Perform a final check on the matched request mapping version.Methods inherited from class AbstractRequestCondition
equals, hashCode, isEmpty, toString
-
Constructor Details
-
VersionRequestCondition
Constructor with the version, if set on the@RequestMapping, and theApiVersionStrategy, if API versioning is enabled.
-
-
Method Details
-
getContent
Description copied from class:AbstractRequestConditionReturn the discrete items a request condition is composed of.For example URL patterns, HTTP request methods, param expressions, etc.
- Specified by:
getContentin classAbstractRequestCondition<VersionRequestCondition>- Returns:
- a collection of objects (never
null)
-
getToStringInfix
Description copied from class:AbstractRequestConditionThe notation to use when printing discrete items of content.For example
" || "for URL patterns or" && "for param expressions.- Specified by:
getToStringInfixin classAbstractRequestCondition<VersionRequestCondition>
-
getVersion
-
combine
Description copied from interface:RequestConditionCombine this condition with another such as conditions from a type-level and method-level@RequestMappingannotation.- 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:RequestConditionCheck 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
nullotherwise.
-
compareTo
Description copied from interface:RequestConditionCompare this condition to another condition in the context of a specific request. This method assumes both instances have been obtained viaRequestCondition.getMatchingCondition(ServerWebExchange)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(ServerWebExchange). 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:
exchange- the current exchange- Throws:
NotAcceptableApiVersionException- if the matched condition has a fixed version that is not equal to the request version
-