java中判断对象中属性值是否为空的函数

public boolean checkObjFieldIsNull(Object obj) throws IllegalAccessException {

boolean flag = false;
for(Field f : obj.getClass().getDeclaredFields()){
f.setAccessible(true);
log.info(f.getName());
if(f.get(obj) == null){
flag = true;
return flag;
}
}
return flag;
}

原文地址:https://www.cnblogs.com/ggqzz/p/8421720.html