Rename ApiDeprecationHandler to insert "Version"

The name is a bit long, but it is necessary to indicate it's a handler
for a deprecation version, and the decision is based on the version,
not an individual endpoint.

See gh-35049
This commit is contained in:
rstoyanchev
2025-06-25 12:03:35 +01:00
parent 7606a929c9
commit 785aab8ad5
14 changed files with 47 additions and 47 deletions
@@ -22,13 +22,13 @@ import jakarta.servlet.http.HttpServletResponse;
/**
* Contract to add handling of requests with a deprecated API version. Typically,
* this involves use of response headers to send hints and information about
* the deprecation to clients.
* the deprecated version to clients.
*
* @author Rossen Stoyanchev
* @since 7.0
* @see StandardApiDeprecationHandler
* @see StandardApiVersionDeprecationHandler
*/
public interface ApiDeprecationHandler {
public interface ApiVersionDeprecationHandler {
/**
* Check if the requested API version is deprecated, and if so handle it
@@ -69,7 +69,7 @@ public interface ApiVersionStrategy {
* @param version the resolved and parsed request version
* @param request the current request
* @param response the current response
* @see ApiDeprecationHandler
* @see ApiVersionDeprecationHandler
*/
void handleDeprecations(Comparable<?> version, HttpServletRequest request, HttpServletResponse response);
@@ -44,7 +44,7 @@ public class DefaultApiVersionStrategy implements ApiVersionStrategy {
private final @Nullable Comparable<?> defaultVersion;
private final @Nullable ApiDeprecationHandler deprecationHandler;
private final @Nullable ApiVersionDeprecationHandler deprecationHandler;
private final Set<Comparable<?>> supportedVersions = new TreeSet<>();
@@ -65,7 +65,7 @@ public class DefaultApiVersionStrategy implements ApiVersionStrategy {
public DefaultApiVersionStrategy(
List<ApiVersionResolver> versionResolvers, ApiVersionParser<?> versionParser,
boolean versionRequired, @Nullable String defaultVersion,
@Nullable ApiDeprecationHandler deprecationHandler) {
@Nullable ApiVersionDeprecationHandler deprecationHandler) {
Assert.notEmpty(versionResolvers, "At least one ApiVersionResolver is required");
Assert.notNull(versionParser, "ApiVersionParser is required");
@@ -33,7 +33,7 @@ import org.springframework.http.MediaType;
import org.springframework.util.Assert;
/**
* {@code ApiDeprecationHandler} based on
* {@code ApiVersionDeprecationHandler} based on
* <a href="https://datatracker.ietf.org/doc/html/rfc9745">RFC 9745</a> and
* <a href="https://datatracker.ietf.org/doc/html/rfc8594">RFC 8594</a> that
* provides the option to set the "Deprecation" and "Sunset" response headers,
@@ -45,7 +45,7 @@ import org.springframework.util.Assert;
* @author Rossen Stoyanchev
* @since 7.0
*/
public class StandardApiDeprecationHandler implements ApiDeprecationHandler {
public class StandardApiVersionDeprecationHandler implements ApiVersionDeprecationHandler {
private final ApiVersionParser<?> versionParser;
@@ -57,9 +57,9 @@ public class StandardApiDeprecationHandler implements ApiDeprecationHandler {
* <p>By default, {@link SemanticApiVersionParser} is used to parse configured
* API versions, so those can be compared to request versions parsed at runtime.
* If you have a custom parser, then please use the
* {@link #StandardApiDeprecationHandler(ApiVersionParser)} constructor.
* {@link #StandardApiVersionDeprecationHandler(ApiVersionParser)} constructor.
*/
public StandardApiDeprecationHandler() {
public StandardApiVersionDeprecationHandler() {
this(new SemanticApiVersionParser());
}
@@ -68,7 +68,7 @@ public class StandardApiDeprecationHandler implements ApiDeprecationHandler {
* This needs to be the same as the parser type used at runtime to parse
* request versions.
*/
public StandardApiDeprecationHandler(ApiVersionParser<?> parser) {
public StandardApiVersionDeprecationHandler(ApiVersionParser<?> parser) {
this.versionParser = parser;
}
@@ -109,7 +109,7 @@ public class StandardApiDeprecationHandler implements ApiDeprecationHandler {
@Override
public String toString() {
return "StandardApiDeprecationHandler " + this.infos.values();
return "StandardApiVersionDeprecationHandler " + this.infos.values();
}
@@ -122,7 +122,7 @@ public class StandardApiDeprecationHandler implements ApiDeprecationHandler {
private VersionSpec(Comparable<?> version) {
this.version = version;
StandardApiDeprecationHandler.this.infos.put(version, new VersionInfo(version));
StandardApiVersionDeprecationHandler.this.infos.put(version, new VersionInfo(version));
}
/**
@@ -198,7 +198,7 @@ public class StandardApiDeprecationHandler implements ApiDeprecationHandler {
}
private VersionSpec map(Function<VersionInfo, VersionInfo> function) {
StandardApiDeprecationHandler.this.infos.compute(this.version, (version, versionInfo) -> {
StandardApiVersionDeprecationHandler.this.infos.compute(this.version, (version, versionInfo) -> {
Assert.state(versionInfo != null, "No VersionInfo");
return function.apply(versionInfo);
});