集合工具类

类名: CollectionUtil

isNotEmpty

/**
* Return {@code true} if the supplied Collection is not {@code null} or empty.
* Otherwise, return {@code false}.
*
* @param collection the Collection to check
* @return whether the given Collection is not empty
*/
CollectionUtil.isNotEmpty(Collection<?> collection);

isNotEmpty

/**
* Return {@code true} if the supplied Map is not {@code null} or empty.
* Otherwise, return {@code false}.
*
* @param map the Map to check
* @return whether the given Map is not empty
*/
CollectionUtil.isNotEmpty(Map<?,?> map);

contains

/**
* Check whether the given Array contains the given element.
*
* @param array the Array to check
* @param element the element to look for
* @param <T> The generic tag
* @return {@code true} if found, {@code false} else
*/
CollectionUtil.contains(T[] array, T element);

concat

/**
* Concatenates 2 arrays
*
* @param one 数组1
* @param other 数组2
* @return 新数组
*/
CollectionUtil.concat(String[] one, String[] other);

concat

/**
* Concatenates 2 arrays
*
* @param one 数组1
* @param other 数组2
* @param clazz 数组类
* @return 新数组
*/
CollectionUtil.concat(T[] one, T[] other, Class<T> clazz);

ofImmutableSet

/**
* 不可变 Set
*
* @param es 对象
* @param <E> 泛型
* @return 集合
*/
CollectionUtil.ofImmutableSet(E es);

ofImmutableList

/**
* 不可变 List
*
* @param es 对象
* @param <E> 泛型
* @return 集合
*/
CollectionUtil.ofImmutableList(E es);

toList

/**
* Iterable 转换为List集合
*
* @param elements Iterable
* @param <E> 泛型
* @return 集合
*/
CollectionUtil.toList(Iterable<E> elements);

toMap

/**
* 将key value 数组转为 map
*
* @param keysValues key value 数组
* @param <K> key
* @param <V> value
* @return map 集合
*/
CollectionUtil.toMap(Object keysValues);

partition

/**
* list 分片
*
* @param list List
* @param size 分片大小
* @param <T> 泛型
* @return List 分片
*/
CollectionUtil.partition(List<T> list, int size);

get

/**
*/
CollectionUtil collectionUtil = new CollectionUtil();
collectionUtil.get(int index);

size

/**
*/
CollectionUtil collectionUtil = new CollectionUtil();
collectionUtil.size();

isEmpty

/**
*/
CollectionUtil collectionUtil = new CollectionUtil();
collectionUtil.isEmpty();

微信 vs 公众号

如梦技术

精彩内容每日推荐!!!