Polish AssertUtil: add assertNotNull and assertTrue

Signed-off-by: Eric Zhao <sczyh16@gmail.com>
This commit is contained in:
Eric Zhao 2022-11-14 23:15:42 +08:00 committed by LearningGp
parent 1483669aaf
commit 4e41c14514
1 changed files with 13 additions and 1 deletions

View File

@ -24,7 +24,19 @@ import java.util.Collection;
*/
public class AssertUtil {
private AssertUtil(){}
private AssertUtil() {}
public static void assertNotNull(Object object, String message) {
if (object == null) {
throw new IllegalArgumentException(message);
}
}
public static void assertTrue(boolean value, String message) {
if (!value) {
throw new IllegalArgumentException(message);
}
}
public static void notEmpty(String string, String message) {
if (StringUtil.isEmpty(string)) {