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

com.penglecode.common.util.CollectionUtils Maven / Gradle / Ivy

Go to download

commons is a little java tool to make your development easier in your work.

The newest version!
package com.penglecode.common.util;

import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
/**
 * 集合类型的工具类
 * 
 * @author	  	pengpeng
 * @date	  	2014年7月19日 下午3:38:21
 * @version  	1.0
 */
public class CollectionUtils {

	/**
	 * 

判断Collection集合是否为空

* * @param collection * @return */ public static boolean isEmpty(Collection collection){ return collection == null || collection.isEmpty(); } /** *

判断Map集合是否为空

* * @param map * @return */ public static boolean isEmpty(Map map){ return map == null || map.isEmpty(); } /** *

判断Collection集合中是否含有null元素

* * @param collection * @return */ public static boolean containsNull(Collection collection){ if(!isEmpty(collection)){ for(Object obj : collection){ if(obj == null){ return true; } } } return false; } /** *

过滤Collection集合中的null元素

* * @param collection */ public static void filterNull(Collection collection){ if(!isEmpty(collection)){ for(Iterator it = collection.iterator(); it.hasNext();){ if(it.next() == null){ it.remove(); } } } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy