参考:https://www.cnblogs.com/ldq2016/p/6834643.html
https://www.cnblogs.com/cuglkb/p/8463039.html
工具类:
public class ObjectUtils {
static public final Boolean allFieldsIsNull(Object object) {
Boolean ret = true;
Class clazz = (Class) object.getClass();
Field fields[] = clazz.getDeclaredFields();
for (Field field : fields) {
field.setAccessible(true);
Object fieldValue = null;
try {
fieldValue = field.get(object);
} catch (Exception e) {
throw new ServiceException("抛出异常!: " + e.getMessage());
}
if (null != fieldValue) {
ret = false;
break;
}
}
return ret;
}
}
标签:www,Java,field,object,ret,用法,Field,fieldValue
From: https://www.cnblogs.com/chenyi502/p/17071760.html