public final class Assert
extends java.lang.Object
| 构造器和说明 |
|---|
Assert() |
| 限定符和类型 | 方法和说明 |
|---|---|
static boolean |
hasText(java.lang.String str)
Check whether the given
String contains actual text. |
static void |
hasText(java.lang.String text,
java.lang.String message)
Assert that the given String contains valid text content; that is, it must not be
null and must contain at least one non-whitespace character. |
static void |
isTrue(boolean expression,
java.lang.String message)
Assert a boolean expression, throwing an
IllegalArgumentException if the
expression evaluates to false. |
static void |
notEmpty(java.util.Collection<?> collection,
java.lang.String message)
Assert that the collection is not
null and not empty. |
static void |
notNull(java.lang.Object object,
java.lang.String message)
Assert that an object is not
null. |
public static void notEmpty(@Nullable
java.util.Collection<?> collection,
java.lang.String message)
null and not empty.collection - the collection to checkmessage - the exception message to use if the assertion failsjava.lang.IllegalArgumentException - if the collection is null or emptypublic static void notNull(@Nullable
java.lang.Object object,
java.lang.String message)
null.
Assert.notNull(clazz, "The class must not be null");
object - the object to checkmessage - the exception message to use if the assertion failsjava.lang.IllegalArgumentException - if the object is nullpublic static void hasText(@Nullable
java.lang.String text,
java.lang.String message)
null and must contain at least one non-whitespace character.
Assert.hasText(name, "'name' must not be empty");
text - the String to checkmessage - the exception message to use if the assertion failsjava.lang.IllegalArgumentException - if the text does not contain valid text contentpublic static boolean hasText(@Nullable
java.lang.String str)
String contains actual text.
More specifically, this method returns true if the String is not
null, its length is greater than 0, and it contains at least one
non-whitespace character.
str - the String to check (may be null)true if the String is not null, its length is
greater than 0, and it does not contain whitespace onlyCharacter.isWhitespace(char)public static void isTrue(boolean expression,
java.lang.String message)
IllegalArgumentException if the
expression evaluates to false.expression - a boolean expressionmessage - the exception message to use if the assertion failsjava.lang.IllegalArgumentException - if expression is false