废话不多说,直接上代码:
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 || f.get(obj).equals("")){
flag = true;
return flag;
}
}
return flag;
}
可以封装到一个工具类中,作为公共方法。