cn.hippo4j.common.toolkit.CollectionUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hippo4j-common Show documentation
Show all versions of hippo4j-common Show documentation
HIPPO4J、HIPPO4J-CORE 公共代码库.
package cn.hippo4j.common.toolkit;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* Collection util.
*
* @author chen.ma
* @date 2021/12/22 20:43
*/
public class CollectionUtil {
/**
* Get first.
*
* @param iterable
* @param
* @return
*/
public static T getFirst(Iterable iterable) {
Iterator iterator;
if (iterable != null && (iterator = iterable.iterator()) != null && iterator.hasNext()) {
return iterator.next();
}
return null;
}
/**
* Is empty.
*
* @param list
* @return
*/
public static boolean isEmpty(List> list) {
return list == null || list.isEmpty();
}
/**
* Is not empty.
*
* @param list
* @return
*/
public static boolean isNotEmpty(List> list) {
return !isEmpty(list);
}
/**
* Is empty.
*
* @param map
* @return
*/
public static boolean isEmpty(Map, ?> map) {
return map == null || map.isEmpty();
}
/**
* Is not empty.
*
* @param map
* @return
*/
public static boolean isNotEmpty(Map, ?> map) {
return !isEmpty(map);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy