public boolean isNullOrEmpty(Object o) {
if (o == null){
return true;
}
if (o instanceof String) {
if (((String) o).length() == 0) {
return true;
}
} else if (o instanceof Collection) {
if (((Collection) o).isEmpty()) {
return true;
}
} else if (o.getClass().isArray()) {
if (Array.getLength(o) == 0) {
return true;
}
} else if (o instanceof Map) {
if (((Map) o).isEmpty()) {
return true;
}
} else {
return false;
}
return false;
}
最全判空方法
最新推荐文章于 2023-06-28 17:54:05 发布