public class Assert extends Object
Constructor and Description |
---|
Assert() |
Modifier and Type | Method and Description |
---|---|
static void |
isTrue(boolean expression)
断言是否为真,如果为
false 抛出 IllegalArgumentException 异常Assert.isTrue(i > 0, "The value must be greater than zero"); |
static void |
isTrue(boolean expression,
String errorMsgTemplate,
Object... params)
断言是否为真,如果为
false 抛出 IllegalArgumentException 异常Assert.isTrue(i > 0, "The value must be greater than zero"); |
static String |
notBlank(String text)
检查给定字符串是否为空白(null、空串或只包含空白符),为空抛出
IllegalArgumentException
Assert.notBlank(name, "Name must not be blank"); |
static String |
notBlank(String text,
String errorMsgTemplate,
Object... params)
检查给定字符串是否为空白(null、空串或只包含空白符),为空抛出
IllegalArgumentException
Assert.notBlank(name, "Name must not be blank"); |
static <T> T |
notNull(T object)
|
static <T> T |
notNull(T object,
String errorMsgTemplate,
Object... params)
|
public static void isTrue(boolean expression, String errorMsgTemplate, Object... params) throws IllegalArgumentException
false
抛出 IllegalArgumentException
异常Assert.isTrue(i > 0, "The value must be greater than zero");
expression
- 波尔值errorMsgTemplate
- 错误抛出异常附带的消息模板,变量用{}代替params
- 参数列表IllegalArgumentException
- if expression is false
public static void isTrue(boolean expression) throws IllegalArgumentException
false
抛出 IllegalArgumentException
异常Assert.isTrue(i > 0, "The value must be greater than zero");
expression
- 波尔值IllegalArgumentException
- if expression is false
public static <T> T notNull(T object, String errorMsgTemplate, Object... params) throws NullPointerException
null
,如果为null
抛出NullPointerException
异常 Assert that an object is not null
.
Assert.notNull(clazz, "The class must not be null");
T
- 被检查对象泛型类型object
- 被检查对象errorMsgTemplate
- 错误消息模板,变量使用{}表示params
- 参数NullPointerException
- if the object is null
public static <T> T notNull(T object) throws NullPointerException
T
- 被检查对象类型object
- 被检查对象NullPointerException
- if the object is null
public static String notBlank(String text) throws IllegalArgumentException
IllegalArgumentException
Assert.notBlank(name, "Name must not be blank");
text
- 被检查字符串IllegalArgumentException
- 被检查字符串为空白UStringUtil.isNotBlank(CharSequence)
public static String notBlank(String text, String errorMsgTemplate, Object... params) throws IllegalArgumentException
IllegalArgumentException
Assert.notBlank(name, "Name must not be blank");
text
- 被检查字符串errorMsgTemplate
- 错误消息模板,变量使用{}表示params
- 参数IllegalArgumentException
- 被检查字符串为空白UStringUtil.isNotBlank(CharSequence)
Copyright © 2020. All rights reserved.