class ObjectIsEmptyUtil {
		public static boolean isEmpty(Object obj, String objProperty) throws Exception, IllegalAccessException {
		// 获取类对象
		Class<?> clazz = obj.getClass();
		// 得到属性集合
		Field[] fs = clazz.getDeclaredFields();
		// 遍历属性
		for (Field field : fs) {
			field.setAccessible(true);
			// 找到需要判断的属性名称
			if (field.getName().equalsIgnoreCase(objProperty)) {
				// 判断该对象是否为空
				if ((field.get(obj) == null || field.get(obj) == ""
						|| "null".equalsIgnoreCase(field.get(obj).toString()))) {
					return true;
				}
			}  
		}
		return false;
	}
}



版权声明:本文为weixin_37716758原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/weixin_37716758/article/details/84204783