|
@@ -0,0 +1,36 @@
|
|
|
+package com.hrsk.cloud.eg.domain.common.utils;
|
|
|
+
|
|
|
+
|
|
|
+import com.hrsk.pangu.tool.exception.BizException;
|
|
|
+/**
|
|
|
+ * @author: bianlanzhou
|
|
|
+ * @create: 2024-07-27 10:04
|
|
|
+ * @description: FROM GUAVA PRECONDITION,BIZ业务校验
|
|
|
+ **/
|
|
|
+public class BizPreconditions {
|
|
|
+ /**
|
|
|
+ * 验证参数
|
|
|
+ * @param expression 表达式
|
|
|
+ * @param errorMessage 错误信息
|
|
|
+ */
|
|
|
+ public static void checkArgument(boolean expression, String errorMessage) {
|
|
|
+ if (!expression) {
|
|
|
+ throw new BizException(errorMessage);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 验证不为空
|
|
|
+ * @param reference 入参
|
|
|
+ * @param errorMessage 错误信息
|
|
|
+ * @return T
|
|
|
+ * @param <T> T
|
|
|
+ */
|
|
|
+ public static <T> T checkNotNull( T reference, String errorMessage) {
|
|
|
+ if (reference == null) {
|
|
|
+ throw new BizException(errorMessage);
|
|
|
+ } else {
|
|
|
+ return reference;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|