Package tech.mgl.core.utils
Class MGL_Asserts
java.lang.Object
tech.mgl.core.utils.MGL_Asserts
Name: MGL_Asserts
Package: tech.mgl.frame.common
Description: ${DESC}
Author: bbd12 www.mgl.tech
Email: hotpot@mgl.tech
Date: 2017/4/26
Version: V1.0
-
Constructor Details
-
MGL_Asserts
public MGL_Asserts()
-
-
Method Details
-
notBlank
没有值则抛出异常- Parameters:
text-message-
-
state
反状态- Parameters:
expression-message-
-
notEmpty
判断对象是否为空- Type Parameters:
T-- Parameters:
object-message-- Returns:
-
notNull
断言对象是否不为null,如果为null抛出指定类型异常 并使用指定的函数获取错误信息返回Assert.notNull(clazz, ()->{ // to query relation message return new IllegalArgumentException("relation message to return"); });- Type Parameters:
T- 被检查对象泛型类型X- 异常类型- Parameters:
object- 被检查对象errorSupplier- 错误抛出异常附带的消息生产接口- Returns:
- 被检查后的对象
- Throws:
X- if the object isnull- Since:
- 5.4.5
-
notNull
public static <T> T notNull(T object, String errorMsgTemplate, Object... params) throws IllegalArgumentException 断言对象是否不为null,如果为null抛出IllegalArgumentException异常 Assert that an object is notnull.Assert.notNull(clazz, "The class must not be null");
- Type Parameters:
T- 被检查对象泛型类型- Parameters:
object- 被检查对象errorMsgTemplate- 错误消息模板,变量使用{}表示params- 参数- Returns:
- 被检查后的对象
- Throws:
IllegalArgumentException- if the object isnull
-
notNull
- Type Parameters:
T- 被检查对象类型- Parameters:
object- 被检查对象- Returns:
- 非空对象
- Throws:
IllegalArgumentException- if the object isnull
-