Skip to content

Commit 9be6cea

Browse files
committed
Polishing deprecated methods
Added since and forRemoval to Deprecated methods.
1 parent 37b4391 commit 9be6cea

File tree

7 files changed

+25
-23
lines changed

7 files changed

+25
-23
lines changed

spring-context/src/main/java/org/springframework/scheduling/support/CronSequenceGenerator.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -55,7 +55,7 @@
5555
* @see CronTrigger
5656
* @deprecated as of 5.3, in favor of {@link CronExpression}
5757
*/
58-
@Deprecated
58+
@Deprecated(since = "5.3", forRemoval = true)
5959
public class CronSequenceGenerator {
6060

6161
private final String expression;
@@ -84,7 +84,7 @@ public class CronSequenceGenerator {
8484
* @see java.util.TimeZone#getDefault()
8585
* @deprecated as of 5.3, in favor of {@link CronExpression#parse(String)}
8686
*/
87-
@Deprecated
87+
@Deprecated(since = "5.3", forRemoval = true)
8888
public CronSequenceGenerator(String expression) {
8989
this(expression, TimeZone.getDefault());
9090
}

spring-core/src/main/java/org/springframework/util/MimeType.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ private static Map<String, String> addCharsetParameter(Charset charset, Map<Stri
708708
* @param <T> the type of mime types that may be compared by this comparator
709709
* @deprecated As of 6.0, with no direct replacement
710710
*/
711-
@Deprecated(since = "6.0")
711+
@Deprecated(since = "6.0", forRemoval = true)
712712
public static class SpecificityComparator<T extends MimeType> implements Comparator<T> {
713713

714714
@Override

spring-core/src/main/java/org/springframework/util/MimeTypeUtils.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ public abstract class MimeTypeUtils {
5555
* Comparator formally used by {@link #sortBySpecificity(List)}.
5656
* @deprecated As of 6.0, with no direct replacement
5757
*/
58-
@Deprecated(since = "6.0")
58+
@SuppressWarnings("removal")
59+
@Deprecated(since = "6.0", forRemoval = true)
5960
public static final Comparator<MimeType> SPECIFICITY_COMPARATOR = new MimeType.SpecificityComparator<>();
6061

6162
/**

spring-core/src/main/java/org/springframework/util/StringUtils.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,9 @@ public static boolean containsWhitespace(@Nullable String str) {
221221
* @param str the {@code String} to check
222222
* @return the trimmed {@code String}
223223
* @see java.lang.Character#isWhitespace
224-
* @deprecated in favor of {@link String#strip()}
224+
* @deprecated since 6.0, in favor of {@link String#strip()}
225225
*/
226-
@Deprecated
226+
@Deprecated(since = "6.0")
227227
public static String trimWhitespace(String str) {
228228
if (!hasLength(str)) {
229229
return str;
@@ -277,9 +277,9 @@ public static String trimAllWhitespace(String str) {
277277
* @param str the {@code String} to check
278278
* @return the trimmed {@code String}
279279
* @see java.lang.Character#isWhitespace
280-
* @deprecated in favor of {@link String#stripLeading()}
280+
* @deprecated since 6.0, in favor of {@link String#stripLeading()}
281281
*/
282-
@Deprecated
282+
@Deprecated(since = "6.0")
283283
public static String trimLeadingWhitespace(String str) {
284284
if (!hasLength(str)) {
285285
return str;
@@ -293,9 +293,9 @@ public static String trimLeadingWhitespace(String str) {
293293
* @param str the {@code String} to check
294294
* @return the trimmed {@code String}
295295
* @see java.lang.Character#isWhitespace
296-
* @deprecated in favor of {@link String#stripTrailing()}
296+
* @deprecated since 6.0, in favor of {@link String#stripTrailing()}
297297
*/
298-
@Deprecated
298+
@Deprecated(since = "6.0")
299299
public static String trimTrailingWhitespace(String str) {
300300
if (!hasLength(str)) {
301301
return str;

spring-core/src/test/java/org/springframework/util/StringUtilsTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ void trimAllWhitespace() {
9898
}
9999

100100
@Test
101-
@Deprecated
101+
@SuppressWarnings("deprecation")
102102
void trimLeadingWhitespace() {
103103
assertThat(StringUtils.trimLeadingWhitespace(null)).isNull();
104104
assertThat(StringUtils.trimLeadingWhitespace("")).isEqualTo("");
@@ -114,7 +114,7 @@ void trimLeadingWhitespace() {
114114
}
115115

116116
@Test
117-
@Deprecated
117+
@SuppressWarnings("deprecation")
118118
void trimTrailingWhitespace() {
119119
assertThat(StringUtils.trimTrailingWhitespace(null)).isNull();
120120
assertThat(StringUtils.trimTrailingWhitespace("")).isEqualTo("");

spring-web/src/main/java/org/springframework/http/MediaType.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ public static String toString(Collection<MediaType> mediaTypes) {
836836
* @param mediaTypes the list of media types to be sorted
837837
* @deprecated As of 6.0, in favor of {@link MimeTypeUtils#sortBySpecificity(List)}
838838
*/
839-
@Deprecated(since = "6.0")
839+
@Deprecated(since = "6.0", forRemoval = true)
840840
public static void sortBySpecificity(List<MediaType> mediaTypes) {
841841
Assert.notNull(mediaTypes, "'mediaTypes' must not be null");
842842
if (mediaTypes.size() > 1) {
@@ -865,7 +865,7 @@ public static void sortBySpecificity(List<MediaType> mediaTypes) {
865865
* @see #getQualityValue()
866866
* @deprecated As of 6.0, with no direct replacement
867867
*/
868-
@Deprecated(since = "6.0")
868+
@Deprecated(since = "6.0", forRemoval = true)
869869
public static void sortByQualityValue(List<MediaType> mediaTypes) {
870870
Assert.notNull(mediaTypes, "'mediaTypes' must not be null");
871871
if (mediaTypes.size() > 1) {
@@ -891,7 +891,7 @@ public static void sortBySpecificityAndQuality(List<MediaType> mediaTypes) {
891891
* Comparator used by {@link #sortByQualityValue(List)}.
892892
* @deprecated As of 6.0, with no direct replacement
893893
*/
894-
@Deprecated(since = "6.0")
894+
@Deprecated(since = "6.0", forRemoval = true)
895895
public static final Comparator<MediaType> QUALITY_VALUE_COMPARATOR = (mediaType1, mediaType2) -> {
896896
double quality1 = mediaType1.getQualityValue();
897897
double quality2 = mediaType2.getQualityValue();
@@ -931,7 +931,8 @@ else if (!mediaType1.getSubtype().equals(mediaType2.getSubtype())) { // audio/b
931931
* Comparator used by {@link #sortBySpecificity(List)}.
932932
* @deprecated As of 6.0, with no direct replacement
933933
*/
934-
@Deprecated(since = "6.0")
934+
@Deprecated(since = "6.0", forRemoval = true)
935+
@SuppressWarnings("removal")
935936
public static final Comparator<MediaType> SPECIFICITY_COMPARATOR = new SpecificityComparator<>() {
936937

937938
@Override

spring-web/src/test/java/org/springframework/http/MediaTypeTests.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ public void specificityComparator() throws Exception {
291291
MediaType allXml = new MediaType("application", "*+xml");
292292
MediaType all = MediaType.ALL;
293293

294-
@SuppressWarnings("deprecation")
294+
@SuppressWarnings("removal")
295295
Comparator<MediaType> comp = MediaType.SPECIFICITY_COMPARATOR;
296296

297297
// equal
@@ -335,7 +335,7 @@ public void specificityComparator() throws Exception {
335335
}
336336

337337
@Test
338-
@SuppressWarnings("deprecation")
338+
@SuppressWarnings("removal")
339339
public void sortBySpecificityRelated() {
340340
MediaType audioBasic = new MediaType("audio", "basic");
341341
MediaType audio = new MediaType("audio");
@@ -366,7 +366,7 @@ public void sortBySpecificityRelated() {
366366
}
367367

368368
@Test
369-
@SuppressWarnings("deprecation")
369+
@SuppressWarnings("removal")
370370
public void sortBySpecificityUnrelated() {
371371
MediaType audioBasic = new MediaType("audio", "basic");
372372
MediaType audioWave = new MediaType("audio", "wave");
@@ -398,7 +398,7 @@ public void qualityComparator() throws Exception {
398398
MediaType allXml = new MediaType("application", "*+xml");
399399
MediaType all = MediaType.ALL;
400400

401-
@SuppressWarnings("deprecation")
401+
@SuppressWarnings("removal")
402402
Comparator<MediaType> comp = MediaType.QUALITY_VALUE_COMPARATOR;
403403

404404
// equal
@@ -442,7 +442,7 @@ public void qualityComparator() throws Exception {
442442
}
443443

444444
@Test
445-
@SuppressWarnings("deprecation")
445+
@SuppressWarnings("removal")
446446
public void sortByQualityRelated() {
447447
MediaType audioBasic = new MediaType("audio", "basic");
448448
MediaType audio = new MediaType("audio");
@@ -473,7 +473,7 @@ public void sortByQualityRelated() {
473473
}
474474

475475
@Test
476-
@SuppressWarnings("deprecation")
476+
@SuppressWarnings("removal")
477477
public void sortByQualityUnrelated() {
478478
MediaType audioBasic = new MediaType("audio", "basic");
479479
MediaType audioWave = new MediaType("audio", "wave");

0 commit comments

Comments
 (0)