public class EmptyUtils {   PRivate EmptyUtils() {      throw new UnsupportedOperationException("UnsupportedOperation...");   }   /**    * 判斷對(duì)象是否為空    *    * @param obj 對(duì)象    * @return {@code true}: 為空<br>{@code false}: 不為空    */   public static boolean isEmpty(Object obj) {      if (obj == null) {         return true;      }      if (obj instanceof String && obj.toString().length() == 0) {         return true;      }      if (obj.getClass().isArray() && Array.getLength(obj) == 0) {         return true;      }      if (obj instanceof Collection && ((Collection) obj).isEmpty()) {         return true;      }      if (obj instanceof Map && ((Map) obj).isEmpty()) {         return true;      }      return false;   }   /**    * 判斷對(duì)象是否非空    *    * @param obj 對(duì)象    * @return {@code true}: 非空<br>{@code false}: 空    */   public static boolean isNotEmpty(Object obj) {      return !isEmpty(obj);   }}
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注