Spring的断言工具类Assert的基本使用
2018-02-23 15:41
274 查看
Assert.notNull(Object object, "object is required") - 对象非空
Assert.isTrue(Object object, "object must be true") - 对象必须为true
Assert.notEmpty(Collection collection, "collection must not be empty") - 集合非空
Assert.hasLength(String text, "text must be specified") - 字符不为null且字符长度不为0
Assert.hasText(String text, "text must not be empty") - text 不为null且必须至少包含一个非空格的字符
Assert.isInstanceOf(Class clazz, Object obj, "clazz must be of type [clazz]") - obj必须能被正确造型成为clazz 指定的类
可以把if(判断){}改为断言
Assert.isTrue(Object object, "object must be true") - 对象必须为true
Assert.notEmpty(Collection collection, "collection must not be empty") - 集合非空
Assert.hasLength(String text, "text must be specified") - 字符不为null且字符长度不为0
Assert.hasText(String text, "text must not be empty") - text 不为null且必须至少包含一个非空格的字符
Assert.isInstanceOf(Class clazz, Object obj, "clazz must be of type [clazz]") - obj必须能被正确造型成为clazz 指定的类
可以把if(判断){}改为断言
相关文章推荐
- spring的断言工具类Assert的基本使用
- Spring Assert(方法入参检测工具类-断言)
- Spring Assert(方法入参检测工具类-断言)
- Spring-----Assert断言工具类
- Spring Assert(方法入参检测工具类-断言)
- Spring Assert(方法入参检测工具类-断言)
- Spring Assert断言工具类
- Springboot+Junit测试Http请求实例包括Get,Post,Put和Delete已及断言Assert的使用
- Spring Assert(方法入参检测工具类-断言)
- Spring Assert(方法入参检测工具类-断言)
- Spring Assert(方法入参检测工具类-断言)
- 模态对话框使用OnOK结束时,ASSERT(ContinueModal())断言处报错
- 关于ASSERT(断言)使用的规则--摘自《高质量C/C++编程指南》
- 关于spring中Assert的应用,方法入参检测工具类
- 解决GetDlgItem 使用时出现ASSERT(::IsWindow(m_hWnd))断言
- Spring中的Assert工具类
- android平台使用assert断言
- assert断言函数的使用
- assert断言的使用
- 理解和正确使用Java中的断言(assert)