Here you can find the source of isNullOrEmpty(Collection collection)
Parameter | Description |
---|---|
collection | collection object to test. |
public static boolean isNullOrEmpty(Collection collection)
//package com.java2s; /*//from w w w.j av a2s . c om * Jinx is Copyright 2010-2014 by Jeremy Brooks and Contributors * * Jinx is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Jinx 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Jinx. If not, see <http://www.gnu.org/licenses/>. */ import java.util.Collection; public class Main { /** * Test a string for empty or null. * * @param s string to test. * @return true if the string is null or has a trimmed length of 0. */ public static boolean isNullOrEmpty(String s) { return s == null || s.trim().length() == 0; } /** * Test a Collection for empty or null. * * @param collection collection object to test. * @return true if the collection is null or if the collection has no objects. */ public static boolean isNullOrEmpty(Collection collection) { return collection == null || collection.size() == 0; } }