+优化V.isEmpty(Object), V.notEmpty(Object)校验实现

This commit is contained in:
mazhicheng 2019-06-20 18:48:39 +08:00
parent 136e83d33a
commit 72b0bd703c
3 changed files with 34 additions and 6 deletions

View File

@ -5,8 +5,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/** /**
* 基础CRUD的父类Mapper * 基础CRUD的父类Mapper
* @author Mazhicheng * @author Mazhicheng
* @version 2018/12/22 * @version v2.0
* Copyright © www.dibo.ltd * @date 2018/12/22
*/ */
public interface BaseCrudMapper<T> extends BaseMapper<T> { public interface BaseCrudMapper<T> extends BaseMapper<T> {

View File

@ -5,8 +5,8 @@ import com.diboot.core.entity.Metadata;
/** /**
* 元数据Mapper * 元数据Mapper
* @author Mazhicheng * @author Mazhicheng
* @version 2018/12/22 * @version v2.0
* Copyright © www.dibo.ltd * @date 2018/12/22
*/ */
public interface MetadataMapper extends BaseCrudMapper<Metadata> { public interface MetadataMapper extends BaseCrudMapper<Metadata> {

View File

@ -22,7 +22,21 @@ public class V {
* @return * @return
*/ */
public static boolean isEmpty(Object obj){ public static boolean isEmpty(Object obj){
return obj == null; if(obj instanceof String){
return isEmpty((String)obj);
}
else if(obj instanceof Collection){
return isEmpty((Collection)obj);
}
else if(obj instanceof Map){
return isEmpty((Map)obj);
}
else if(obj instanceof String[]){
return isEmpty((String[])obj);
}
else{
return obj == null;
}
} }
/*** /***
@ -67,7 +81,21 @@ public class V {
* @return * @return
*/ */
public static boolean notEmpty(Object obj){ public static boolean notEmpty(Object obj){
return obj != null; if(obj instanceof String){
return notEmpty((String)obj);
}
else if(obj instanceof Collection){
return notEmpty((Collection)obj);
}
else if(obj instanceof Map){
return notEmpty((Map)obj);
}
else if(obj instanceof String[]){
return notEmpty((String[])obj);
}
else{
return obj != null;
}
} }
/*** /***