Skip to content

Commit

Permalink
Deprecate obsolete Assert APIs for removal in 6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrannen committed Nov 8, 2022
1 parent 727aa51 commit af170f6
Showing 1 changed file with 34 additions and 23 deletions.
57 changes: 34 additions & 23 deletions spring-core/src/main/java/org/springframework/util/Assert.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 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.
Expand Down Expand Up @@ -101,9 +101,10 @@ public static void state(boolean expression, Supplier<String> messageSupplier) {
/**
* Assert a boolean expression, throwing an {@code IllegalStateException}
* if the expression evaluates to {@code false}.
* @deprecated as of 4.3.7, in favor of {@link #state(boolean, String)}
* @deprecated as of 4.3.7, in favor of {@link #state(boolean, String)};
* to be removed in 6.1
*/
@Deprecated
@Deprecated(forRemoval = true)
public static void state(boolean expression) {
state(expression, "[Assertion failed] - this state invariant must be true");
}
Expand Down Expand Up @@ -143,9 +144,10 @@ public static void isTrue(boolean expression, Supplier<String> messageSupplier)
/**
* Assert a boolean expression, throwing an {@code IllegalArgumentException}
* if the expression evaluates to {@code false}.
* @deprecated as of 4.3.7, in favor of {@link #isTrue(boolean, String)}
* @deprecated as of 4.3.7, in favor of {@link #isTrue(boolean, String)};
* to be removed in 6.1
*/
@Deprecated
@Deprecated(forRemoval = true)
public static void isTrue(boolean expression) {
isTrue(expression, "[Assertion failed] - this expression must be true");
}
Expand Down Expand Up @@ -182,9 +184,10 @@ public static void isNull(@Nullable Object object, Supplier<String> messageSuppl

/**
* Assert that an object is {@code null}.
* @deprecated as of 4.3.7, in favor of {@link #isNull(Object, String)}
* @deprecated as of 4.3.7, in favor of {@link #isNull(Object, String)};
* to be removed in 6.1
*/
@Deprecated
@Deprecated(forRemoval = true)
public static void isNull(@Nullable Object object) {
isNull(object, "[Assertion failed] - the object argument must be null");
}
Expand Down Expand Up @@ -222,9 +225,10 @@ public static void notNull(@Nullable Object object, Supplier<String> messageSupp

/**
* Assert that an object is not {@code null}.
* @deprecated as of 4.3.7, in favor of {@link #notNull(Object, String)}
* @deprecated as of 4.3.7, in favor of {@link #notNull(Object, String)};
* to be removed in 6.1
*/
@Deprecated
@Deprecated(forRemoval = true)
public static void notNull(@Nullable Object object) {
notNull(object, "[Assertion failed] - this argument is required; it must not be null");
}
Expand Down Expand Up @@ -267,9 +271,10 @@ public static void hasLength(@Nullable String text, Supplier<String> messageSupp
/**
* Assert that the given String is not empty; that is,
* it must not be {@code null} and not the empty String.
* @deprecated as of 4.3.7, in favor of {@link #hasLength(String, String)}
* @deprecated as of 4.3.7, in favor of {@link #hasLength(String, String)};
* to be removed in 6.1
*/
@Deprecated
@Deprecated(forRemoval = true)
public static void hasLength(@Nullable String text) {
hasLength(text,
"[Assertion failed] - this String argument must have length; it must not be null or empty");
Expand Down Expand Up @@ -313,9 +318,10 @@ public static void hasText(@Nullable String text, Supplier<String> messageSuppli
/**
* Assert that the given String contains valid text content; that is, it must not
* be {@code null} and must contain at least one non-whitespace character.
* @deprecated as of 4.3.7, in favor of {@link #hasText(String, String)}
* @deprecated as of 4.3.7, in favor of {@link #hasText(String, String)};
* to be removed in 6.1
*/
@Deprecated
@Deprecated(forRemoval = true)
public static void hasText(@Nullable String text) {
hasText(text,
"[Assertion failed] - this String argument must have text; it must not be null, empty, or blank");
Expand Down Expand Up @@ -357,9 +363,10 @@ public static void doesNotContain(@Nullable String textToSearch, String substrin

/**
* Assert that the given text does not contain the given substring.
* @deprecated as of 4.3.7, in favor of {@link #doesNotContain(String, String, String)}
* @deprecated as of 4.3.7, in favor of {@link #doesNotContain(String, String, String)};
* to be removed in 6.1
*/
@Deprecated
@Deprecated(forRemoval = true)
public static void doesNotContain(@Nullable String textToSearch, String substring) {
doesNotContain(textToSearch, substring,
() -> "[Assertion failed] - this String argument must not contain the substring [" + substring + "]");
Expand Down Expand Up @@ -400,9 +407,10 @@ public static void notEmpty(@Nullable Object[] array, Supplier<String> messageSu
/**
* Assert that an array contains elements; that is, it must not be
* {@code null} and must contain at least one element.
* @deprecated as of 4.3.7, in favor of {@link #notEmpty(Object[], String)}
* @deprecated as of 4.3.7, in favor of {@link #notEmpty(Object[], String)};
* to be removed in 6.1
*/
@Deprecated
@Deprecated(forRemoval = true)
public static void notEmpty(@Nullable Object[] array) {
notEmpty(array, "[Assertion failed] - this array must not be empty: it must contain at least 1 element");
}
Expand Down Expand Up @@ -449,9 +457,10 @@ public static void noNullElements(@Nullable Object[] array, Supplier<String> mes

/**
* Assert that an array contains no {@code null} elements.
* @deprecated as of 4.3.7, in favor of {@link #noNullElements(Object[], String)}
* @deprecated as of 4.3.7, in favor of {@link #noNullElements(Object[], String)};
* to be removed in 6.1
*/
@Deprecated
@Deprecated(forRemoval = true)
public static void noNullElements(@Nullable Object[] array) {
noNullElements(array, "[Assertion failed] - this array must not contain any null elements");
}
Expand Down Expand Up @@ -493,9 +502,10 @@ public static void notEmpty(@Nullable Collection<?> collection, Supplier<String>
/**
* Assert that a collection contains elements; that is, it must not be
* {@code null} and must contain at least one element.
* @deprecated as of 4.3.7, in favor of {@link #notEmpty(Collection, String)}
* @deprecated as of 4.3.7, in favor of {@link #notEmpty(Collection, String)};
* to be removed in 6.1
*/
@Deprecated
@Deprecated(forRemoval = true)
public static void notEmpty(@Nullable Collection<?> collection) {
notEmpty(collection,
"[Assertion failed] - this collection must not be empty: it must contain at least 1 element");
Expand Down Expand Up @@ -577,9 +587,10 @@ public static void notEmpty(@Nullable Map<?, ?> map, Supplier<String> messageSup
/**
* Assert that a Map contains entries; that is, it must not be {@code null}
* and must contain at least one entry.
* @deprecated as of 4.3.7, in favor of {@link #notEmpty(Map, String)}
* @deprecated as of 4.3.7, in favor of {@link #notEmpty(Map, String)};
* to be removed in 6.1
*/
@Deprecated
@Deprecated(forRemoval = true)
public static void notEmpty(@Nullable Map<?, ?> map) {
notEmpty(map, "[Assertion failed] - this map must not be empty; it must contain at least one entry");
}
Expand Down

0 comments on commit af170f6

Please sign in to comment.