|
@@ -6,14 +6,12 @@ import cn.hutool.core.util.StrUtil;
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
public class Assert {
|
|
|
|
|
|
|
|
|
* 断言为空
|
|
|
- *
|
|
|
- * @param obj 参数
|
|
|
- * @param errStr 异常提示
|
|
|
*/
|
|
|
public static void empty(Object obj, String errStr) {
|
|
|
if (ObjectUtil.isNotEmpty(obj)) {
|
|
@@ -23,9 +21,6 @@ public class Assert {
|
|
|
|
|
|
|
|
|
* 断言不为空
|
|
|
- *
|
|
|
- * @param obj 参数
|
|
|
- * @param errStr 异常提示
|
|
|
*/
|
|
|
public static void notEmpty(Object obj, String errStr) {
|
|
|
if (ObjectUtil.isEmpty(obj)) {
|
|
@@ -35,9 +30,6 @@ public class Assert {
|
|
|
|
|
|
|
|
|
* 断言不为空
|
|
|
- *
|
|
|
- * @param obj 参数
|
|
|
- * @param errStr 异常提示
|
|
|
*/
|
|
|
public static void notNull(Object obj, String errStr) {
|
|
|
if (ObjectUtil.isNull(obj)) {
|
|
@@ -47,9 +39,6 @@ public class Assert {
|
|
|
|
|
|
|
|
|
* 断言不为空
|
|
|
- *
|
|
|
- * @param str 参数
|
|
|
- * @param errStr 异常提示
|
|
|
*/
|
|
|
public static void notBlank(String str, String errStr) {
|
|
|
if (StrUtil.isBlank(str)) {
|
|
@@ -59,57 +48,42 @@ public class Assert {
|
|
|
|
|
|
|
|
|
* 断言为0
|
|
|
- *
|
|
|
- * @param integer 参数
|
|
|
- * @param errStr 异常提示
|
|
|
*/
|
|
|
public static void eqZero(Integer integer, String errStr) {
|
|
|
- if (integer != 0) {
|
|
|
+ if (!Objects.equals(integer, 0)) {
|
|
|
throw new ServiceException(errStr);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
* 断言为0
|
|
|
- *
|
|
|
- * @param integer 参数
|
|
|
- * @param errStr 异常提示
|
|
|
*/
|
|
|
- public static void eqZero(Long integer, String errStr) {
|
|
|
- if (integer != 0) {
|
|
|
+ public static void eqZero(Long along, String errStr) {
|
|
|
+ if (!Objects.equals(along, 0L)) {
|
|
|
throw new ServiceException(errStr);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
* 断言为1
|
|
|
- *
|
|
|
- * @param along 参数
|
|
|
- * @param errStr 异常提示
|
|
|
*/
|
|
|
- public static void eqOne(Long along, String errStr) {
|
|
|
- if (along != 1) {
|
|
|
+ public static void eqOne(Integer integer, String errStr) {
|
|
|
+ if (!Objects.equals(integer, 1)) {
|
|
|
throw new ServiceException(errStr);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
* 断言为1
|
|
|
- *
|
|
|
- * @param integer 参数
|
|
|
- * @param errStr 异常提示
|
|
|
*/
|
|
|
- public static void eqOne(Integer integer, String errStr) {
|
|
|
- if (integer != 1) {
|
|
|
+ public static void eqOne(Long along, String errStr) {
|
|
|
+ if (!Objects.equals(along, 1L)) {
|
|
|
throw new ServiceException(errStr);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
* 断言为真
|
|
|
- *
|
|
|
- * @param flag 参数
|
|
|
- * @param errStr 异常提示
|
|
|
*/
|
|
|
public static void eqTrue(Boolean flag, String errStr) {
|
|
|
if (flag == null || flag.equals(false)) {
|
|
@@ -119,9 +93,6 @@ public class Assert {
|
|
|
|
|
|
|
|
|
* 断言大于0
|
|
|
- *
|
|
|
- * @param bigDecimal 参数
|
|
|
- * @param errStr 异常提示
|
|
|
*/
|
|
|
public static void gtZero(BigDecimal bigDecimal, String errStr) {
|
|
|
if (bigDecimal == null || BigDecimal.ZERO.compareTo(bigDecimal) > 0) {
|
|
@@ -131,9 +102,6 @@ public class Assert {
|
|
|
|
|
|
|
|
|
* 断言大于等于0
|
|
|
- *
|
|
|
- * @param bigDecimal 参数
|
|
|
- * @param errStr 异常提示
|
|
|
*/
|
|
|
public static void geZero(BigDecimal bigDecimal, String errStr) {
|
|
|
if (bigDecimal == null || BigDecimal.ZERO.compareTo(bigDecimal) >= 0) {
|
|
@@ -143,9 +111,6 @@ public class Assert {
|
|
|
|
|
|
|
|
|
* 断言大于0
|
|
|
- *
|
|
|
- * @param integer 参数
|
|
|
- * @param errStr 异常提示
|
|
|
*/
|
|
|
public static void gtZero(Integer integer, String errStr) {
|
|
|
if (integer == null || integer <= 0) {
|