Here you can find the source of isNotEmpty(Collection
Parameter | Description |
---|---|
collection | Collection to check |
public static <T> boolean isNotEmpty(Collection<T> collection)
//package com.java2s; /*// w w w. j av a2 s . c om * Copyright 2015 52?North Initiative for Geospatial Open Source * Software GmbH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.util.Collection; import java.util.Map; public class Main { /** * Check if collection is not null and not empty * * @param collection * Collection to check * * @return empty or not */ public static <T> boolean isNotEmpty(Collection<T> collection) { return !isEmptyOrNull(collection); } /** * Check if collection is not null and not empty * * * @param map * Map to check * * @return <tt>false</tt>, if map is <tt>null</tt> or empty, else * <tt>true</tt>. */ public static <K, V> boolean isNotEmpty(Map<K, V> map) { return map != null && !map.isEmpty(); } public static <T> boolean isEmptyOrNull(Collection<T> collection) { return collection == null || collection.isEmpty(); } /** * Check if collection is not <tt>null</tt> and empty * * @param collection * Collection to check * * @return <tt>true</tt>, if collection is not null and empty, else * <tt>false</tt> */ public static <T> boolean isEmpty(Collection<T> collection) { return collection != null && collection.isEmpty(); } /** * Check if map is not <tt>null</tt> and empty * * @param map * map to check * * @return <tt>true</tt>, if map is not null and empty, else <tt>false</tt> */ public static <K, V> boolean isEmpty(Map<K, V> map) { return map != null && map.isEmpty(); } }