Retain single-arg assert methods in deprecated form
Issue: SPR-15196
This commit is contained in:
@@ -88,6 +88,14 @@ public abstract class Assert {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated as of 4.3.7, in favor of {@link #isTrue(boolean, String)}
|
||||
*/
|
||||
@Deprecated
|
||||
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">
|
||||
@@ -118,6 +126,14 @@ public abstract class Assert {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated as of 4.3.7, in favor of {@link #isNull(Object, String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static void isNull(Object object) {
|
||||
isNull(object, "[Assertion failed] - the object argument must be null");
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that an object is not {@code null}.
|
||||
* <pre class="code">
|
||||
@@ -148,6 +164,14 @@ public abstract class Assert {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated as of 4.3.7, in favor of {@link #notNull(Object, String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static void notNull(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.
|
||||
@@ -182,6 +206,15 @@ public abstract class Assert {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated as of 4.3.7, in favor of {@link #hasLength(String, String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static void hasLength(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.
|
||||
@@ -216,6 +249,15 @@ public abstract class Assert {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated as of 4.3.7, in favor of {@link #hasText(String, String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static void hasText(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">
|
||||
@@ -250,6 +292,15 @@ public abstract class Assert {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated as of 4.3.7, in favor of {@link #doesNotContain(String, String, String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static void doesNotContain(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.
|
||||
@@ -282,6 +333,14 @@ public abstract class Assert {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated as of 4.3.7, in favor of {@link #notEmpty(Object[], String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static void notEmpty(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!
|
||||
@@ -322,6 +381,14 @@ public abstract class Assert {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated as of 4.3.7, in favor of {@link #noNullElements(Object[], String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static void noNullElements(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.
|
||||
@@ -356,6 +423,15 @@ public abstract class Assert {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated as of 4.3.7, in favor of {@link #notEmpty(Collection, String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static void notEmpty(Collection<?> collection) {
|
||||
notEmpty(collection,
|
||||
"[Assertion failed] - this collection must not be empty: it must contain at least 1 element");
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that a Map contains entries; that is, it must not be {@code null}
|
||||
* and must contain at least one entry.
|
||||
@@ -388,6 +464,14 @@ public abstract class Assert {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated as of 4.3.7, in favor of {@link #notEmpty(Map, String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static void notEmpty(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">
|
||||
@@ -537,6 +621,14 @@ public abstract class Assert {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated as of 4.3.7, in favor of {@link #state(boolean, String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static void state(boolean expression) {
|
||||
state(expression, "[Assertion failed] - this state invariant must be true");
|
||||
}
|
||||
|
||||
private static String nullSafeGet(Supplier<String> messageSupplier) {
|
||||
return (messageSupplier != null ? messageSupplier.get() : null);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user