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     }

 

相关文章:

  • 2021-10-19
  • 2022-01-13
  • 2022-01-06
  • 2021-10-12
  • 2021-05-22
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-02
  • 2021-09-24
  • 2021-06-14
  • 2022-12-23
  • 2021-11-27
相关资源
相似解决方案