java反射机制判断对象所有属性是否全部为空

来源:互联网 发布:秒杀软件利剑 编辑:程序博客网 时间:2024/05/20 18:41
private boolean checkObjFieldIsNotNull(Object obj){    try {        for (Field f : obj.getClass().getDeclaredFields()) {            f.setAccessible(true);            if (f.get(obj) != null) {                return true;            }        }    }catch (IllegalAccessException e){    }    return false;}
原创粉丝点击