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


 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     }

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM