java 判断对象的所有属性是否为空解决方案
public static 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; }
posted on 2018-03-30 13:44 chengjunde 阅读(1843) 评论(0) 编辑 收藏 举报