Skip to content

Commit af170f6

Browse files
committed
Deprecate obsolete Assert APIs for removal in 6.1
See gh-29449
1 parent 727aa51 commit af170f6

File tree

1 file changed

+34
-23
lines changed
  • spring-core/src/main/java/org/springframework/util

1 file changed

+34
-23
lines changed

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

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 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.
@@ -101,9 +101,10 @@ public static void state(boolean expression, Supplier<String> messageSupplier) {
101101
/**
102102
* Assert a boolean expression, throwing an {@code IllegalStateException}
103103
* if the expression evaluates to {@code false}.
104-
* @deprecated as of 4.3.7, in favor of {@link #state(boolean, String)}
104+
* @deprecated as of 4.3.7, in favor of {@link #state(boolean, String)};
105+
* to be removed in 6.1
105106
*/
106-
@Deprecated
107+
@Deprecated(forRemoval = true)
107108
public static void state(boolean expression) {
108109
state(expression, "[Assertion failed] - this state invariant must be true");
109110
}
@@ -143,9 +144,10 @@ public static void isTrue(boolean expression, Supplier<String> messageSupplier)
143144
/**
144145
* Assert a boolean expression, throwing an {@code IllegalArgumentException}
145146
* if the expression evaluates to {@code false}.
146-
* @deprecated as of 4.3.7, in favor of {@link #isTrue(boolean, String)}
147+
* @deprecated as of 4.3.7, in favor of {@link #isTrue(boolean, String)};
148+
* to be removed in 6.1
147149
*/
148-
@Deprecated
150+
@Deprecated(forRemoval = true)
149151
public static void isTrue(boolean expression) {
150152
isTrue(expression, "[Assertion failed] - this expression must be true");
151153
}
@@ -182,9 +184,10 @@ public static void isNull(@Nullable Object object, Supplier<String> messageSuppl
182184

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

223226
/**
224227
* Assert that an object is not {@code null}.
225-
* @deprecated as of 4.3.7, in favor of {@link #notNull(Object, String)}
228+
* @deprecated as of 4.3.7, in favor of {@link #notNull(Object, String)};
229+
* to be removed in 6.1
226230
*/
227-
@Deprecated
231+
@Deprecated(forRemoval = true)
228232
public static void notNull(@Nullable Object object) {
229233
notNull(object, "[Assertion failed] - this argument is required; it must not be null");
230234
}
@@ -267,9 +271,10 @@ public static void hasLength(@Nullable String text, Supplier<String> messageSupp
267271
/**
268272
* Assert that the given String is not empty; that is,
269273
* it must not be {@code null} and not the empty String.
270-
* @deprecated as of 4.3.7, in favor of {@link #hasLength(String, String)}
274+
* @deprecated as of 4.3.7, in favor of {@link #hasLength(String, String)};
275+
* to be removed in 6.1
271276
*/
272-
@Deprecated
277+
@Deprecated(forRemoval = true)
273278
public static void hasLength(@Nullable String text) {
274279
hasLength(text,
275280
"[Assertion failed] - this String argument must have length; it must not be null or empty");
@@ -313,9 +318,10 @@ public static void hasText(@Nullable String text, Supplier<String> messageSuppli
313318
/**
314319
* Assert that the given String contains valid text content; that is, it must not
315320
* be {@code null} and must contain at least one non-whitespace character.
316-
* @deprecated as of 4.3.7, in favor of {@link #hasText(String, String)}
321+
* @deprecated as of 4.3.7, in favor of {@link #hasText(String, String)};
322+
* to be removed in 6.1
317323
*/
318-
@Deprecated
324+
@Deprecated(forRemoval = true)
319325
public static void hasText(@Nullable String text) {
320326
hasText(text,
321327
"[Assertion failed] - this String argument must have text; it must not be null, empty, or blank");
@@ -357,9 +363,10 @@ public static void doesNotContain(@Nullable String textToSearch, String substrin
357363

358364
/**
359365
* Assert that the given text does not contain the given substring.
360-
* @deprecated as of 4.3.7, in favor of {@link #doesNotContain(String, String, String)}
366+
* @deprecated as of 4.3.7, in favor of {@link #doesNotContain(String, String, String)};
367+
* to be removed in 6.1
361368
*/
362-
@Deprecated
369+
@Deprecated(forRemoval = true)
363370
public static void doesNotContain(@Nullable String textToSearch, String substring) {
364371
doesNotContain(textToSearch, substring,
365372
() -> "[Assertion failed] - this String argument must not contain the substring [" + substring + "]");
@@ -400,9 +407,10 @@ public static void notEmpty(@Nullable Object[] array, Supplier<String> messageSu
400407
/**
401408
* Assert that an array contains elements; that is, it must not be
402409
* {@code null} and must contain at least one element.
403-
* @deprecated as of 4.3.7, in favor of {@link #notEmpty(Object[], String)}
410+
* @deprecated as of 4.3.7, in favor of {@link #notEmpty(Object[], String)};
411+
* to be removed in 6.1
404412
*/
405-
@Deprecated
413+
@Deprecated(forRemoval = true)
406414
public static void notEmpty(@Nullable Object[] array) {
407415
notEmpty(array, "[Assertion failed] - this array must not be empty: it must contain at least 1 element");
408416
}
@@ -449,9 +457,10 @@ public static void noNullElements(@Nullable Object[] array, Supplier<String> mes
449457

450458
/**
451459
* Assert that an array contains no {@code null} elements.
452-
* @deprecated as of 4.3.7, in favor of {@link #noNullElements(Object[], String)}
460+
* @deprecated as of 4.3.7, in favor of {@link #noNullElements(Object[], String)};
461+
* to be removed in 6.1
453462
*/
454-
@Deprecated
463+
@Deprecated(forRemoval = true)
455464
public static void noNullElements(@Nullable Object[] array) {
456465
noNullElements(array, "[Assertion failed] - this array must not contain any null elements");
457466
}
@@ -493,9 +502,10 @@ public static void notEmpty(@Nullable Collection<?> collection, Supplier<String>
493502
/**
494503
* Assert that a collection contains elements; that is, it must not be
495504
* {@code null} and must contain at least one element.
496-
* @deprecated as of 4.3.7, in favor of {@link #notEmpty(Collection, String)}
505+
* @deprecated as of 4.3.7, in favor of {@link #notEmpty(Collection, String)};
506+
* to be removed in 6.1
497507
*/
498-
@Deprecated
508+
@Deprecated(forRemoval = true)
499509
public static void notEmpty(@Nullable Collection<?> collection) {
500510
notEmpty(collection,
501511
"[Assertion failed] - this collection must not be empty: it must contain at least 1 element");
@@ -577,9 +587,10 @@ public static void notEmpty(@Nullable Map<?, ?> map, Supplier<String> messageSup
577587
/**
578588
* Assert that a Map contains entries; that is, it must not be {@code null}
579589
* and must contain at least one entry.
580-
* @deprecated as of 4.3.7, in favor of {@link #notEmpty(Map, String)}
590+
* @deprecated as of 4.3.7, in favor of {@link #notEmpty(Map, String)};
591+
* to be removed in 6.1
581592
*/
582-
@Deprecated
593+
@Deprecated(forRemoval = true)
583594
public static void notEmpty(@Nullable Map<?, ?> map) {
584595
notEmpty(map, "[Assertion failed] - this map must not be empty; it must contain at least one entry");
585596
}

0 commit comments

Comments
 (0)