您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

JAVA--assert.notNull

2024/4/1 17:54:00发布19次查看
今天我做junit关于mysql测试时发现,类似于assertnull(tu)之类的代码不知道什么意思,因此稍微总结如下。
org.springframework.util.assert
assert翻译为中文为断言.
大概来说,就是断定某一个实际的值就为自己预期想得到的,如果不一样就抛出异常.
spring源码如下:
/**
* assert that an object is not <code>null</code> .
* <pre class="code">assert.notnull(clazz, the class must not be null);</pre>
* @param object the object to check
* @param message the exception message to use if the assertion fails
* @throws illegalargumentexception if the object is <code>null</code>
*/
public static void notnull(object object, string message) {
if (object == null) {
throw new illegalargumentexception(message);
}
}
该函数的意思是传入的object必须不能为空。如果为空就抛出异常。
以上就是java--assert.notnull的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product