Here you can find the source of isNullOrEmpty(Collection> list)
Parameter | Description |
---|---|
files | a parameter |
public static boolean isNullOrEmpty(Collection<?> list)
//package com.java2s; /*//w ww. ja v a 2 s. com * Copyright 2012 The Solmix Project * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.gnu.org/licenses/ * or see the FSF site: http://www.fsf.org. */ import java.util.Collection; import java.util.Map; public class Main { static public boolean isNullOrEmpty(String str) { return (str == null || str.trim().length() < 1); } /** * @param clause * @return */ public static boolean isNullOrEmpty(StringBuffer sb) { return !(sb != null && sb.length() > 0); } /** * @param files * @return */ public static boolean isNullOrEmpty(Collection<?> list) { return list == null || list.size() < 1; } public static <T> boolean isNullOrEmpty(T[] list) { return list == null || list.length < 1; } public static boolean isNullOrEmpty(Map<?, ?> map) { return map == null || map.isEmpty(); } /** * <p>Checks if a String is empty ("") or null.</p> * * <pre> * DataUtils.isEmpty(null) = true * DataUtils.isEmpty("") = true * DataUtils.isEmpty(" ") = false * DataUtils.isEmpty("bob") = false * DataUtils.isEmpty(" bob ") = false * </pre> * * <p>NOTE: This method changed in Lang version 2.0. * It no longer trims the String. * That functionality is available in isBlank().</p> */ public static boolean isEmpty(String str) { return str == null || str.length() == 0; } }