判断对象是否为空 、 工具类

 1 /**
 2      * 判断对象是否为空
 3      */
 4     public static boolean isEmpty(Object obj) {
 5         if (obj == null)
 6             return true;
 7 
 8         if (obj instanceof String)
 9             return StringUtils.isEmptyOrWhitespaceOnly((String) obj);
10         if (obj instanceof Collection && ((Collection<?>) obj).isEmpty())
11             return true;
12         if (obj.getClass().isArray() && Array.getLength(obj) == 0)
13             return true;
14         if (obj instanceof Map && ((Map<?, ?>) obj).isEmpty())
15             return true;
16 
17         return false;
18     }
原文地址:https://www.cnblogs.com/xjbBill/p/5891946.html