From 9be6cea012b2c5ac55e862329ccb9103e978f3d2 Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Wed, 16 Nov 2022 09:57:14 +0100 Subject: [PATCH] Polishing deprecated methods Added since and forRemoval to Deprecated methods. --- .../scheduling/support/CronSequenceGenerator.java | 6 +++--- .../main/java/org/springframework/util/MimeType.java | 2 +- .../java/org/springframework/util/MimeTypeUtils.java | 3 ++- .../java/org/springframework/util/StringUtils.java | 12 ++++++------ .../org/springframework/util/StringUtilsTests.java | 4 ++-- .../java/org/springframework/http/MediaType.java | 9 +++++---- .../org/springframework/http/MediaTypeTests.java | 12 ++++++------ 7 files changed, 25 insertions(+), 23 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/scheduling/support/CronSequenceGenerator.java b/spring-context/src/main/java/org/springframework/scheduling/support/CronSequenceGenerator.java index efce947cb7..7d502e4459 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/support/CronSequenceGenerator.java +++ b/spring-context/src/main/java/org/springframework/scheduling/support/CronSequenceGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,7 +55,7 @@ import org.springframework.util.StringUtils; * @see CronTrigger * @deprecated as of 5.3, in favor of {@link CronExpression} */ -@Deprecated +@Deprecated(since = "5.3", forRemoval = true) public class CronSequenceGenerator { private final String expression; @@ -84,7 +84,7 @@ public class CronSequenceGenerator { * @see java.util.TimeZone#getDefault() * @deprecated as of 5.3, in favor of {@link CronExpression#parse(String)} */ - @Deprecated + @Deprecated(since = "5.3", forRemoval = true) public CronSequenceGenerator(String expression) { this(expression, TimeZone.getDefault()); } diff --git a/spring-core/src/main/java/org/springframework/util/MimeType.java b/spring-core/src/main/java/org/springframework/util/MimeType.java index 7fe9a46e9f..a1464d8221 100644 --- a/spring-core/src/main/java/org/springframework/util/MimeType.java +++ b/spring-core/src/main/java/org/springframework/util/MimeType.java @@ -708,7 +708,7 @@ public class MimeType implements Comparable, Serializable { * @param the type of mime types that may be compared by this comparator * @deprecated As of 6.0, with no direct replacement */ - @Deprecated(since = "6.0") + @Deprecated(since = "6.0", forRemoval = true) public static class SpecificityComparator implements Comparator { @Override diff --git a/spring-core/src/main/java/org/springframework/util/MimeTypeUtils.java b/spring-core/src/main/java/org/springframework/util/MimeTypeUtils.java index 0a76878a82..b15948a6a4 100644 --- a/spring-core/src/main/java/org/springframework/util/MimeTypeUtils.java +++ b/spring-core/src/main/java/org/springframework/util/MimeTypeUtils.java @@ -55,7 +55,8 @@ public abstract class MimeTypeUtils { * Comparator formally used by {@link #sortBySpecificity(List)}. * @deprecated As of 6.0, with no direct replacement */ - @Deprecated(since = "6.0") + @SuppressWarnings("removal") + @Deprecated(since = "6.0", forRemoval = true) public static final Comparator SPECIFICITY_COMPARATOR = new MimeType.SpecificityComparator<>(); /** diff --git a/spring-core/src/main/java/org/springframework/util/StringUtils.java b/spring-core/src/main/java/org/springframework/util/StringUtils.java index 3c2716be5a..f2eb263234 100644 --- a/spring-core/src/main/java/org/springframework/util/StringUtils.java +++ b/spring-core/src/main/java/org/springframework/util/StringUtils.java @@ -221,9 +221,9 @@ public abstract class StringUtils { * @param str the {@code String} to check * @return the trimmed {@code String} * @see java.lang.Character#isWhitespace - * @deprecated in favor of {@link String#strip()} + * @deprecated since 6.0, in favor of {@link String#strip()} */ - @Deprecated + @Deprecated(since = "6.0") public static String trimWhitespace(String str) { if (!hasLength(str)) { return str; @@ -277,9 +277,9 @@ public abstract class StringUtils { * @param str the {@code String} to check * @return the trimmed {@code String} * @see java.lang.Character#isWhitespace - * @deprecated in favor of {@link String#stripLeading()} + * @deprecated since 6.0, in favor of {@link String#stripLeading()} */ - @Deprecated + @Deprecated(since = "6.0") public static String trimLeadingWhitespace(String str) { if (!hasLength(str)) { return str; @@ -293,9 +293,9 @@ public abstract class StringUtils { * @param str the {@code String} to check * @return the trimmed {@code String} * @see java.lang.Character#isWhitespace - * @deprecated in favor of {@link String#stripTrailing()} + * @deprecated since 6.0, in favor of {@link String#stripTrailing()} */ - @Deprecated + @Deprecated(since = "6.0") public static String trimTrailingWhitespace(String str) { if (!hasLength(str)) { return str; diff --git a/spring-core/src/test/java/org/springframework/util/StringUtilsTests.java b/spring-core/src/test/java/org/springframework/util/StringUtilsTests.java index dbf1108741..783383ec2a 100644 --- a/spring-core/src/test/java/org/springframework/util/StringUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/StringUtilsTests.java @@ -98,7 +98,7 @@ class StringUtilsTests { } @Test - @Deprecated + @SuppressWarnings("deprecation") void trimLeadingWhitespace() { assertThat(StringUtils.trimLeadingWhitespace(null)).isNull(); assertThat(StringUtils.trimLeadingWhitespace("")).isEqualTo(""); @@ -114,7 +114,7 @@ class StringUtilsTests { } @Test - @Deprecated + @SuppressWarnings("deprecation") void trimTrailingWhitespace() { assertThat(StringUtils.trimTrailingWhitespace(null)).isNull(); assertThat(StringUtils.trimTrailingWhitespace("")).isEqualTo(""); diff --git a/spring-web/src/main/java/org/springframework/http/MediaType.java b/spring-web/src/main/java/org/springframework/http/MediaType.java index 71add2323e..d290e506de 100644 --- a/spring-web/src/main/java/org/springframework/http/MediaType.java +++ b/spring-web/src/main/java/org/springframework/http/MediaType.java @@ -836,7 +836,7 @@ public class MediaType extends MimeType implements Serializable { * @param mediaTypes the list of media types to be sorted * @deprecated As of 6.0, in favor of {@link MimeTypeUtils#sortBySpecificity(List)} */ - @Deprecated(since = "6.0") + @Deprecated(since = "6.0", forRemoval = true) public static void sortBySpecificity(List mediaTypes) { Assert.notNull(mediaTypes, "'mediaTypes' must not be null"); if (mediaTypes.size() > 1) { @@ -865,7 +865,7 @@ public class MediaType extends MimeType implements Serializable { * @see #getQualityValue() * @deprecated As of 6.0, with no direct replacement */ - @Deprecated(since = "6.0") + @Deprecated(since = "6.0", forRemoval = true) public static void sortByQualityValue(List mediaTypes) { Assert.notNull(mediaTypes, "'mediaTypes' must not be null"); if (mediaTypes.size() > 1) { @@ -891,7 +891,7 @@ public class MediaType extends MimeType implements Serializable { * Comparator used by {@link #sortByQualityValue(List)}. * @deprecated As of 6.0, with no direct replacement */ - @Deprecated(since = "6.0") + @Deprecated(since = "6.0", forRemoval = true) public static final Comparator QUALITY_VALUE_COMPARATOR = (mediaType1, mediaType2) -> { double quality1 = mediaType1.getQualityValue(); double quality2 = mediaType2.getQualityValue(); @@ -931,7 +931,8 @@ public class MediaType extends MimeType implements Serializable { * Comparator used by {@link #sortBySpecificity(List)}. * @deprecated As of 6.0, with no direct replacement */ - @Deprecated(since = "6.0") + @Deprecated(since = "6.0", forRemoval = true) + @SuppressWarnings("removal") public static final Comparator SPECIFICITY_COMPARATOR = new SpecificityComparator<>() { @Override diff --git a/spring-web/src/test/java/org/springframework/http/MediaTypeTests.java b/spring-web/src/test/java/org/springframework/http/MediaTypeTests.java index 190bdf82e8..a3661ff719 100644 --- a/spring-web/src/test/java/org/springframework/http/MediaTypeTests.java +++ b/spring-web/src/test/java/org/springframework/http/MediaTypeTests.java @@ -291,7 +291,7 @@ public class MediaTypeTests { MediaType allXml = new MediaType("application", "*+xml"); MediaType all = MediaType.ALL; - @SuppressWarnings("deprecation") + @SuppressWarnings("removal") Comparator comp = MediaType.SPECIFICITY_COMPARATOR; // equal @@ -335,7 +335,7 @@ public class MediaTypeTests { } @Test - @SuppressWarnings("deprecation") + @SuppressWarnings("removal") public void sortBySpecificityRelated() { MediaType audioBasic = new MediaType("audio", "basic"); MediaType audio = new MediaType("audio"); @@ -366,7 +366,7 @@ public class MediaTypeTests { } @Test - @SuppressWarnings("deprecation") + @SuppressWarnings("removal") public void sortBySpecificityUnrelated() { MediaType audioBasic = new MediaType("audio", "basic"); MediaType audioWave = new MediaType("audio", "wave"); @@ -398,7 +398,7 @@ public class MediaTypeTests { MediaType allXml = new MediaType("application", "*+xml"); MediaType all = MediaType.ALL; - @SuppressWarnings("deprecation") + @SuppressWarnings("removal") Comparator comp = MediaType.QUALITY_VALUE_COMPARATOR; // equal @@ -442,7 +442,7 @@ public class MediaTypeTests { } @Test - @SuppressWarnings("deprecation") + @SuppressWarnings("removal") public void sortByQualityRelated() { MediaType audioBasic = new MediaType("audio", "basic"); MediaType audio = new MediaType("audio"); @@ -473,7 +473,7 @@ public class MediaTypeTests { } @Test - @SuppressWarnings("deprecation") + @SuppressWarnings("removal") public void sortByQualityUnrelated() { MediaType audioBasic = new MediaType("audio", "basic"); MediaType audioWave = new MediaType("audio", "wave");