Home  >  Article  >  Java  >  JAVA--assert.notNull

JAVA--assert.notNull

巴扎黑
巴扎黑Original
2017-06-23 16:35:123357browse

Today when I was doing JUnit testing on MySQL, I found that codes similar to assertNull(tu) didn’t know what they meant, so I summarized them as follows.

org.springframework.util.Assert
Assert is translated into Chinese as "assertion".
Roughly speaking, it means to conclude that a certain actual value is what you expect, and if it is different, then Throws an exception.

spring source code is as follows:

/**
* Assert that an object is not null .
*

Assert.notNull(clazz, "The class must not be null");

* @param object the object to check
* @param message the exception message to use if the assertion fails
* @throws IllegalArgumentException if the object is null
*/
public static void notNull(Object object, String message) {
if (object == null) {
throw new IllegalArgumentException(message);
}
}

The meaning of this function is that the incoming object must not be empty. Throws an exception if it is empty.

The above is the detailed content of JAVA--assert.notNull. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn