Skip to content

Commit

Permalink
Remove APIs deprecated for removal in 6.1
Browse files Browse the repository at this point in the history
This is the first commit that removes deprecated APIs.

Subsequent commits will remove additional deprecated APIs.

See gh-29449
  • Loading branch information
sbrannen committed Apr 19, 2023
1 parent d446de6 commit 7df2e2a
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 508 deletions.

This file was deleted.

123 changes: 1 addition & 122 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-2022 the original author or authors.
* Copyright 2002-2023 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 @@ -98,17 +98,6 @@ 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)};
* to be removed in 6.1
*/
@Deprecated(forRemoval = true)
public static void state(boolean expression) {
state(expression, "[Assertion failed] - this state invariant must be true");
}

/**
* Assert a boolean expression, throwing an {@code IllegalArgumentException}
* if the expression evaluates to {@code false}.
Expand Down Expand Up @@ -141,17 +130,6 @@ 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)};
* to be removed in 6.1
*/
@Deprecated(forRemoval = true)
public static void isTrue(boolean expression) {
isTrue(expression, "[Assertion failed] - this expression must be true");
}

/**
* Assert that an object is {@code null}.
* <pre class="code">Assert.isNull(value, "The value must be null");</pre>
Expand Down Expand Up @@ -182,16 +160,6 @@ 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)};
* to be removed in 6.1
*/
@Deprecated(forRemoval = true)
public static void isNull(@Nullable Object object) {
isNull(object, "[Assertion failed] - the object argument must be null");
}

/**
* Assert that an object is not {@code null}.
* <pre class="code">Assert.notNull(clazz, "The class must not be null");</pre>
Expand Down Expand Up @@ -223,16 +191,6 @@ 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)};
* to be removed in 6.1
*/
@Deprecated(forRemoval = true)
public static void notNull(@Nullable Object object) {
notNull(object, "[Assertion failed] - this argument is required; it must not be null");
}

/**
* Assert that the given String is not empty; that is,
* it must not be {@code null} and not the empty String.
Expand Down Expand Up @@ -268,18 +226,6 @@ 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)};
* to be removed in 6.1
*/
@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");
}

/**
* 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.
Expand Down Expand Up @@ -315,18 +261,6 @@ 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)};
* to be removed in 6.1
*/
@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");
}

/**
* Assert that the given text does not contain the given substring.
* <pre class="code">Assert.doesNotContain(name, "rod", "Name must not contain 'rod'");</pre>
Expand Down Expand Up @@ -361,17 +295,6 @@ 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)};
* to be removed in 6.1
*/
@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 + "]");
}

/**
* Assert that an array contains elements; that is, it must not be
* {@code null} and must contain at least one element.
Expand Down Expand Up @@ -404,17 +327,6 @@ 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)};
* to be removed in 6.1
*/
@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");
}

/**
* Assert that an array contains no {@code null} elements.
* <p>Note: Does not complain if the array is empty!
Expand Down Expand Up @@ -455,16 +367,6 @@ 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)};
* to be removed in 6.1
*/
@Deprecated(forRemoval = true)
public static void noNullElements(@Nullable Object[] array) {
noNullElements(array, "[Assertion failed] - this array must not contain any null elements");
}

/**
* Assert that a collection contains elements; that is, it must not be
* {@code null} and must contain at least one element.
Expand Down Expand Up @@ -499,18 +401,6 @@ 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)};
* to be removed in 6.1
*/
@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");
}

/**
* Assert that a collection contains no {@code null} elements.
* <p>Note: Does not complain if the collection is empty!
Expand Down Expand Up @@ -584,17 +474,6 @@ 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)};
* to be removed in 6.1
*/
@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");
}

/**
* Assert that the provided object is an instance of the provided class.
* <pre class="code">Assert.instanceOf(Foo.class, foo, "Foo expected");</pre>
Expand Down
Loading

0 comments on commit 7df2e2a

Please sign in to comment.