读spring源码之—Assert.notNull
来源:互联网 发布:java高并发书 编辑:程序博客网 时间:2024/06/15 05:28
org.springframework.util.Assert
Assert翻译为中文为"断言".用过JUNIT的应该都知道这个概念了.
就是断定某一个实际的值就为自己预期想得到的,如果不一样就抛出异常.
Assert经常用于:
1.判断METHOD的参数是否属于正常值.
2.JUNIT中使用.
Assert翻译为中文为"断言".用过JUNIT的应该都知道这个概念了.
就是断定某一个实际的值就为自己预期想得到的,如果不一样就抛出异常.
Assert经常用于:
1.判断METHOD的参数是否属于正常值.
2.JUNIT中使用.
我发现SPRING1.2.6里面有BUG
请看:
org.springframework.core.io.support.EncodedResource中
public EncodedResource(Resource resource, String encoding) {
}
Assert.notNull("Resource is required");
这句应该为
Assert.notNull(resource,"Resource is required");
不然resource都没传过来,还断什么言啊,呵呵.
------------------------------------------------------------------------
上面是在网上看到了,但是我进入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);
}
}
* 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必须不能为空。如果为空就抛出异常。
1 0
- 读spring源码之—Assert.notNull
- 读spring源码之—Assert.notNull
- spring源码之—Assert.notNull
- spring源码之—Assert.notNull-断言
- spring源码之—Assert.notNull
- spring源码之—Assert.notNull()
- Nodejs源码分析之assert
- spring——assert用法
- spring Assert
- spring assert
- Spring Assert
- spring assert
- spring assert
- xUtils系列之DbUtils-NotNull注解
- spring内核工具包分析之StringUtils与Assert断言
- 企业实战之Spring项目《hibernate validator+Assert参数校验》
- spring注解中@NotEmpty,@NotBlank,@NotNull用法区别
- Spring源码之AbstractAutowireCapableBeanFactory
- 数组排序(区分大小写)
- CentOS6.5配置网络yum源
- Excel键盘快捷键大全(三)
- 富文本 QTextDocument 解析及相关
- FJNU2016-2017学年第二十届低年级程序设计竞赛(正式赛) 题解
- 读spring源码之—Assert.notNull
- C++源码流程图分析[转载]
- myeclipse安装jad插件,实现项目中的所有jar包里的.class文件直接查看
- 打开eclipse的opens the android sdk and avd manager提示错误:error:location of the android sdk has not been
- 希尔排序
- Recurrent Neural Networks - collections
- NodeJs小试牛刀--聊天室搭建
- 安卓解决6.0以后没有setLatestEventInfo方法的解决方案
- springboot+mybatis实现security