1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- package com.fjhx.utils;
- import org.springblade.core.log.exception.ServiceException;
- import org.springblade.core.tool.utils.ObjectUtil;
- public class Assert {
- /**
- * 断言不为空
- *
- * @param obj 参数
- * @param errStr 异常提示
- */
- public static void notEmpty(Object obj, String errStr) {
- if (ObjectUtil.isEmpty(obj)) {
- throw new ServiceException(errStr);
- }
- }
- /**
- * 断言为0
- *
- * @param integer 参数
- * @param errStr 异常提示
- */
- public static void eqZero(Integer integer, String errStr) {
- if (integer != 0) {
- throw new ServiceException(errStr);
- }
- }
- /**
- * 断言为真
- *
- * @param flag 参数
- * @param errStr 异常提示
- */
- public static void eqTrue(Boolean flag, String errStr) {
- if (flag == null || flag.equals(false)) {
- throw new ServiceException(errStr);
- }
- }
- }
|