Polishing deprecated methods

Added since and forRemoval to Deprecated methods.
This commit is contained in:
Arjen Poutsma 2022-11-16 09:57:14 +01:00
parent 37b439182e
commit 9be6cea012
7 changed files with 25 additions and 23 deletions

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 * @see CronTrigger
* @deprecated as of 5.3, in favor of {@link CronExpression} * @deprecated as of 5.3, in favor of {@link CronExpression}
*/ */
@Deprecated @Deprecated(since = "5.3", forRemoval = true)
public class CronSequenceGenerator { public class CronSequenceGenerator {
private final String expression; private final String expression;
@ -84,7 +84,7 @@ public class CronSequenceGenerator {
* @see java.util.TimeZone#getDefault() * @see java.util.TimeZone#getDefault()
* @deprecated as of 5.3, in favor of {@link CronExpression#parse(String)} * @deprecated as of 5.3, in favor of {@link CronExpression#parse(String)}
*/ */
@Deprecated @Deprecated(since = "5.3", forRemoval = true)
public CronSequenceGenerator(String expression) { public CronSequenceGenerator(String expression) {
this(expression, TimeZone.getDefault()); this(expression, TimeZone.getDefault());
} }

View File

@ -708,7 +708,7 @@ public class MimeType implements Comparable<MimeType>, Serializable {
* @param <T> the type of mime types that may be compared by this comparator * @param <T> the type of mime types that may be compared by this comparator
* @deprecated As of 6.0, with no direct replacement * @deprecated As of 6.0, with no direct replacement
*/ */
@Deprecated(since = "6.0") @Deprecated(since = "6.0", forRemoval = true)
public static class SpecificityComparator<T extends MimeType> implements Comparator<T> { public static class SpecificityComparator<T extends MimeType> implements Comparator<T> {
@Override @Override

View File

@ -55,7 +55,8 @@ public abstract class MimeTypeUtils {
* Comparator formally used by {@link #sortBySpecificity(List)}. * Comparator formally used by {@link #sortBySpecificity(List)}.
* @deprecated As of 6.0, with no direct replacement * @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<MimeType> SPECIFICITY_COMPARATOR = new MimeType.SpecificityComparator<>(); public static final Comparator<MimeType> SPECIFICITY_COMPARATOR = new MimeType.SpecificityComparator<>();
/** /**

View File

@ -221,9 +221,9 @@ public abstract class StringUtils {
* @param str the {@code String} to check * @param str the {@code String} to check
* @return the trimmed {@code String} * @return the trimmed {@code String}
* @see java.lang.Character#isWhitespace * @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) { public static String trimWhitespace(String str) {
if (!hasLength(str)) { if (!hasLength(str)) {
return str; return str;
@ -277,9 +277,9 @@ public abstract class StringUtils {
* @param str the {@code String} to check * @param str the {@code String} to check
* @return the trimmed {@code String} * @return the trimmed {@code String}
* @see java.lang.Character#isWhitespace * @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) { public static String trimLeadingWhitespace(String str) {
if (!hasLength(str)) { if (!hasLength(str)) {
return str; return str;
@ -293,9 +293,9 @@ public abstract class StringUtils {
* @param str the {@code String} to check * @param str the {@code String} to check
* @return the trimmed {@code String} * @return the trimmed {@code String}
* @see java.lang.Character#isWhitespace * @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) { public static String trimTrailingWhitespace(String str) {
if (!hasLength(str)) { if (!hasLength(str)) {
return str; return str;

View File

@ -98,7 +98,7 @@ class StringUtilsTests {
} }
@Test @Test
@Deprecated @SuppressWarnings("deprecation")
void trimLeadingWhitespace() { void trimLeadingWhitespace() {
assertThat(StringUtils.trimLeadingWhitespace(null)).isNull(); assertThat(StringUtils.trimLeadingWhitespace(null)).isNull();
assertThat(StringUtils.trimLeadingWhitespace("")).isEqualTo(""); assertThat(StringUtils.trimLeadingWhitespace("")).isEqualTo("");
@ -114,7 +114,7 @@ class StringUtilsTests {
} }
@Test @Test
@Deprecated @SuppressWarnings("deprecation")
void trimTrailingWhitespace() { void trimTrailingWhitespace() {
assertThat(StringUtils.trimTrailingWhitespace(null)).isNull(); assertThat(StringUtils.trimTrailingWhitespace(null)).isNull();
assertThat(StringUtils.trimTrailingWhitespace("")).isEqualTo(""); assertThat(StringUtils.trimTrailingWhitespace("")).isEqualTo("");

View File

@ -836,7 +836,7 @@ public class MediaType extends MimeType implements Serializable {
* @param mediaTypes the list of media types to be sorted * @param mediaTypes the list of media types to be sorted
* @deprecated As of 6.0, in favor of {@link MimeTypeUtils#sortBySpecificity(List)} * @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<MediaType> mediaTypes) { public static void sortBySpecificity(List<MediaType> mediaTypes) {
Assert.notNull(mediaTypes, "'mediaTypes' must not be null"); Assert.notNull(mediaTypes, "'mediaTypes' must not be null");
if (mediaTypes.size() > 1) { if (mediaTypes.size() > 1) {
@ -865,7 +865,7 @@ public class MediaType extends MimeType implements Serializable {
* @see #getQualityValue() * @see #getQualityValue()
* @deprecated As of 6.0, with no direct replacement * @deprecated As of 6.0, with no direct replacement
*/ */
@Deprecated(since = "6.0") @Deprecated(since = "6.0", forRemoval = true)
public static void sortByQualityValue(List<MediaType> mediaTypes) { public static void sortByQualityValue(List<MediaType> mediaTypes) {
Assert.notNull(mediaTypes, "'mediaTypes' must not be null"); Assert.notNull(mediaTypes, "'mediaTypes' must not be null");
if (mediaTypes.size() > 1) { if (mediaTypes.size() > 1) {
@ -891,7 +891,7 @@ public class MediaType extends MimeType implements Serializable {
* Comparator used by {@link #sortByQualityValue(List)}. * Comparator used by {@link #sortByQualityValue(List)}.
* @deprecated As of 6.0, with no direct replacement * @deprecated As of 6.0, with no direct replacement
*/ */
@Deprecated(since = "6.0") @Deprecated(since = "6.0", forRemoval = true)
public static final Comparator<MediaType> QUALITY_VALUE_COMPARATOR = (mediaType1, mediaType2) -> { public static final Comparator<MediaType> QUALITY_VALUE_COMPARATOR = (mediaType1, mediaType2) -> {
double quality1 = mediaType1.getQualityValue(); double quality1 = mediaType1.getQualityValue();
double quality2 = mediaType2.getQualityValue(); double quality2 = mediaType2.getQualityValue();
@ -931,7 +931,8 @@ public class MediaType extends MimeType implements Serializable {
* Comparator used by {@link #sortBySpecificity(List)}. * Comparator used by {@link #sortBySpecificity(List)}.
* @deprecated As of 6.0, with no direct replacement * @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<MediaType> SPECIFICITY_COMPARATOR = new SpecificityComparator<>() { public static final Comparator<MediaType> SPECIFICITY_COMPARATOR = new SpecificityComparator<>() {
@Override @Override

View File

@ -291,7 +291,7 @@ public class MediaTypeTests {
MediaType allXml = new MediaType("application", "*+xml"); MediaType allXml = new MediaType("application", "*+xml");
MediaType all = MediaType.ALL; MediaType all = MediaType.ALL;
@SuppressWarnings("deprecation") @SuppressWarnings("removal")
Comparator<MediaType> comp = MediaType.SPECIFICITY_COMPARATOR; Comparator<MediaType> comp = MediaType.SPECIFICITY_COMPARATOR;
// equal // equal
@ -335,7 +335,7 @@ public class MediaTypeTests {
} }
@Test @Test
@SuppressWarnings("deprecation") @SuppressWarnings("removal")
public void sortBySpecificityRelated() { public void sortBySpecificityRelated() {
MediaType audioBasic = new MediaType("audio", "basic"); MediaType audioBasic = new MediaType("audio", "basic");
MediaType audio = new MediaType("audio"); MediaType audio = new MediaType("audio");
@ -366,7 +366,7 @@ public class MediaTypeTests {
} }
@Test @Test
@SuppressWarnings("deprecation") @SuppressWarnings("removal")
public void sortBySpecificityUnrelated() { public void sortBySpecificityUnrelated() {
MediaType audioBasic = new MediaType("audio", "basic"); MediaType audioBasic = new MediaType("audio", "basic");
MediaType audioWave = new MediaType("audio", "wave"); MediaType audioWave = new MediaType("audio", "wave");
@ -398,7 +398,7 @@ public class MediaTypeTests {
MediaType allXml = new MediaType("application", "*+xml"); MediaType allXml = new MediaType("application", "*+xml");
MediaType all = MediaType.ALL; MediaType all = MediaType.ALL;
@SuppressWarnings("deprecation") @SuppressWarnings("removal")
Comparator<MediaType> comp = MediaType.QUALITY_VALUE_COMPARATOR; Comparator<MediaType> comp = MediaType.QUALITY_VALUE_COMPARATOR;
// equal // equal
@ -442,7 +442,7 @@ public class MediaTypeTests {
} }
@Test @Test
@SuppressWarnings("deprecation") @SuppressWarnings("removal")
public void sortByQualityRelated() { public void sortByQualityRelated() {
MediaType audioBasic = new MediaType("audio", "basic"); MediaType audioBasic = new MediaType("audio", "basic");
MediaType audio = new MediaType("audio"); MediaType audio = new MediaType("audio");
@ -473,7 +473,7 @@ public class MediaTypeTests {
} }
@Test @Test
@SuppressWarnings("deprecation") @SuppressWarnings("removal")
public void sortByQualityUnrelated() { public void sortByQualityUnrelated() {
MediaType audioBasic = new MediaType("audio", "basic"); MediaType audioBasic = new MediaType("audio", "basic");
MediaType audioWave = new MediaType("audio", "wave"); MediaType audioWave = new MediaType("audio", "wave");