com.zusmart.base.util.Assert Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of zusmart-base Show documentation
Show all versions of zusmart-base Show documentation
提供基础的工具类及方法类,Logging,Scanner,Buffer,NetWork,Future,Thread
package com.zusmart.base.util;
public abstract class Assert {
/**
* 断言,字符串为空时抛出{@link IllegalArgumentException}异常
*
* @param value
* 需要判断的值
* @param message
* 异常信息
*/
public static void isBlank(CharSequence value, String message) {
if (StringUtils.isBlank(value)) {
throw new IllegalArgumentException(message);
}
}
/**
* 断言,对象为空时抛出{@link IllegalArgumentException}异常
*
* @param value
* 需要判断的值
* @param message
* 异常信息
*/
public static void isNull(Object value, String message) {
if (null == value) {
throw new IllegalArgumentException(message);
}
}
/**
* 断言,判断指定结果是否为true,true则抛出{@link IllegalArgumentException}异常
*
* @param value
* 需要判断的值
* @param message
* 异常信息
*/
public static void isTrue(boolean value, String message) {
if (value) {
throw new IllegalArgumentException(message);
}
}
}