判断该对象是否为空对象
import .hwqh.user.entity.model.User;import java.lang.reflect.Field;/***判断该对象是否: 返回ture表示所有属性为null 返回false表示不是所有属性都是null*/public class ObjIsUtil {//判断该对象是否: 返回ture表示所有属性为null 返回false表示不是所有属性都是nullpublic static boolean isAllFieldNull(Object obj) throws IllegalAccessException {Class<?> aClass = obj.getClass();Field[] fs = aClass.getDeclaredFields();boolean flag=true;for (Field f : fs) {f.setAccessible(true);Object o = f.get(obj);if (o!=null){flag=false;}}return flag;}public static void main(String[] args) {User user = new User();user.setIdentityType(1);try {boolean allFieldNull = ObjIsUtil.isAllFieldNull(user);System.out.println(allFieldNull);} catch (IllegalAccessException e) {e.printStackTrace();}}}