检查当前对象及内容是否全部为空
检查当前对象是否为空,当对象为NULL时,直接返回TRUE,否则通过反射遍历里面参数,有数据则返回FALSE.
1 /** 2 * Determine whether the attribute values in the object are all empty. 3 * 4 * @param object object 5 * @return boolean 6 */ 7 public static boolean checkObjAllFieldsIsNull(Object object) { 8 if (null == object) { 9 return true; 10 } 11 12 try { 13 for (Field f : object.getClass().getDeclaredFields()) { 14 f.setAccessible(true); 15 if (f.get(object) != null && StringUtils.isNotBlank(f.get(object).toString())) { 16 return false; 17 } 18 } 19 } catch (Exception e) { 20 e.printStackTrace(); 21 } 22 23 return true; 24 }