首页 > 编程语言 > 详细

Spring中的Assert断言常用方法及作用

时间:2019-05-29 10:39:42      阅读:258      评论:0      收藏:0      [点我收藏+]

概念

Assert翻译为中文为"断言",就是断定某一个实际的值就为自己预期想得到的,如果不一样就抛出异常。

方法及作用

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 class, Object object,"class must be of type[class]");  // object必须为class指定的类

Spring中的Assert断言常用方法及作用

原文:https://www.cnblogs.com/luoyu113/p/10942034.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!