All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jdroid.java.collections.CollectionUtils Maven / Gradle / Ivy

The newest version!
package com.jdroid.java.collections;

import java.util.Collection;

/**
 * A set of useful functions used against a Collection
 */
public abstract class CollectionUtils {
	
	protected CollectionUtils() {
		// Helper class
	}
	
	/**
	 * Null-safe check if the specified collection is empty.
	 * 

* Null returns true. * * @param coll the collection to check, may be null * @return true if empty or null */ public static boolean isEmpty(Collection coll) { return (coll == null) || coll.isEmpty(); } public static boolean isEmptyCollection(Object object) { if (object instanceof Collection) { Collection collection = (Collection)object; return isEmpty(collection); } else { return false; } } /** * Null-safe check if the specified collection is not empty. *

* Null returns false. * * @param coll the collection to check, may be null * @return true if non-null and non-empty */ public static boolean isNotEmpty(Collection coll) { return !CollectionUtils.isEmpty(coll); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy