|
@@ -0,0 +1,41 @@
|
|
|
+package cn.hnthyy.thmz.Utils;
|
|
|
+
|
|
|
+import cn.hnthyy.thmz.common.exception.BizException;
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+
|
|
|
+import java.util.Collection;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Description:断言工具类
|
|
|
+ * @Author:lihong
|
|
|
+ */
|
|
|
+public class AssertUtil {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @description: 不能为空 支持集合 ,字符串 ,Map
|
|
|
+ * @author: lihong
|
|
|
+ * @param: object
|
|
|
+ * @param: message
|
|
|
+ **/
|
|
|
+ public static void isNotBlank(Object object,String message){
|
|
|
+ if (object == null) {
|
|
|
+ throw new BizException(message,-1);
|
|
|
+ }
|
|
|
+ else if (object instanceof Collection) {
|
|
|
+ if(CollUtil.isEmpty((Collection)object)){
|
|
|
+ throw new BizException(message,-1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (object instanceof Map) {
|
|
|
+ if(CollUtil.isEmpty((Map)object)){
|
|
|
+ throw new BizException(message,-1);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if (StrUtil.isBlank(object.toString())) {
|
|
|
+ throw new BizException(message,-1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|