コレクションオブジェクトツールクラスCollectionUtil
1170 ワード
package com.example.util;
import java.util.Collection;
import java.util.Map;
/**
*
*
* @author [email protected] 2012-11-12
*
*/
public class CollectionUtil {
/**
*
*
* @param collection
*
* @return
*/
public static int size(Collection> collection) {
return isEmpty(collection) ? 0 : collection.size();
}
/**
*
*
* @param collection
*
* @return
*/
public static boolean isAvailable(Collection> collection, int index) {
if (isEmpty(collection))
return false;
return index >= 0 && index collection) {
return collection == null || collection.isEmpty();
}
/**
*
*
* @param array
*
* @return
*/
public static boolean isEmpty(Object[] array) {
return array == null || array.length == 0;
}
/**
* Map
*
* @param map
* Map
* @return
*/
public static boolean isEmpty(Map, ?> map) {
return map == null || map.isEmpty();
}
}