public boolean allFieldIsNull(Object o) {
try {
for (Field field : o.getClass().getDeclaredFields()) {
field.setAccessible(true); // 把私有属性公有化
Object object = field.get(o);
if (object instanceof CharSequence) {
if (!ObjectUtils.isEmpty((String) object)) {
return false;
}
} else {
if (!ObjectUtils.isNull(object)) {
return false;
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return true;
}
判断对象的属性是不是都是null
最新推荐文章于 2024-01-23 21:27:09 发布
7719

被折叠的 条评论
为什么被折叠?



