Commit 2f228f9f by 刘宇峰

框架完善

1 parent 97411acd
package com.glsx.plat.context.utils; package com.glsx.plat.context.utils;
import com.glsx.plat.exception.ValidateException; import com.glsx.plat.exception.ValidateException;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import java.util.Objects;
/** /**
* 断言工具类 * 断言工具类
*/ */
public class AssertUtil { public class AssertUtils {
public static void isBlank(String str, String message) { public static void isBlank(String str, String message) {
if (StringUtils.isBlank(str)) { if (StringUtils.isBlank(str)) {
...@@ -15,7 +18,13 @@ public class AssertUtil { ...@@ -15,7 +18,13 @@ public class AssertUtil {
} }
public static void isNull(Object object, String message) { public static void isNull(Object object, String message) {
if (object == null) { if (Objects.isNull(object)) {
throw new ValidateException(message);
}
}
public static void isEmpty(Object object, String message) {
if (CollectionUtils.sizeIsEmpty(object)) {
throw new ValidateException(message); throw new ValidateException(message);
} }
} }
......
/**
* Copyright (c) 2016-2019 人人开源 All rights reserved.
* <p>
* https://www.renren.io
* <p>
* 版权所有,侵权必究!
*/
package com.glsx.plat.context.utils.validator;
import com.glsx.plat.exception.ValidateException;
import org.apache.commons.lang.StringUtils;
/**
* 数据校验
*/
public abstract class AssertUtils {
public static void isBlank(String str, String message) {
if (StringUtils.isBlank(str)) {
throw new ValidateException(message);
}
}
public static void isNull(Object object, String message) {
if (object == null) {
throw new ValidateException(message);
}
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!