属性判空
import io.micrometer.core.instrument.util.StringUtils; import java.lang.reflect.Field; /** * @ClassName ObjFieldIsNullUtil * @Author ZhangRF * @CreateDate 2020/08/25 * @Decription 属性判空 */ public class ObjFieldIsNullUtil { /** * 判断对象中属性值是否全为空 * * @param object * @return */ public static boolean isAllNull(Object object) { if (null == object) { return true; } try { for (Field f : object.getClass().getDeclaredFields()) { f.setAccessible(true); if (f.get(object) != null && StringUtils.isNotBlank(f.get(object).toString())) { return false; } } } catch (Exception e) { e.printStackTrace(); } return true; }