2024-02-07 09:27:42 +08:00
|
|
|
package xyz.zhouxy.plusone.commons.collection;
|
2023-04-29 18:38:14 +08:00
|
|
|
|
|
|
|
import java.util.Collection;
|
2023-06-03 23:58:53 +08:00
|
|
|
import java.util.Map;
|
2023-04-29 18:38:14 +08:00
|
|
|
|
|
|
|
import javax.annotation.Nullable;
|
|
|
|
|
2024-02-07 09:27:42 +08:00
|
|
|
public class CollectionTools {
|
2023-06-03 23:58:53 +08:00
|
|
|
|
|
|
|
// isEmpty
|
|
|
|
|
2023-04-29 18:38:14 +08:00
|
|
|
public static boolean isEmpty(@Nullable Collection<?> collection) {
|
|
|
|
return collection == null || collection.isEmpty();
|
|
|
|
}
|
|
|
|
|
2023-06-03 23:58:53 +08:00
|
|
|
public static boolean isEmpty(@Nullable Map<?, ?> map) {
|
|
|
|
return map == null || map.isEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
// isNotEmpty
|
|
|
|
|
2023-04-29 18:38:14 +08:00
|
|
|
public static boolean isNotEmpty(@Nullable Collection<?> collection) {
|
|
|
|
return collection != null && !collection.isEmpty();
|
|
|
|
}
|
|
|
|
|
2023-06-03 23:58:53 +08:00
|
|
|
public static boolean isNotEmpty(@Nullable Map<?, ?> map) {
|
|
|
|
return map != null && !map.isEmpty();
|
|
|
|
}
|
|
|
|
|
2024-02-07 09:27:42 +08:00
|
|
|
private CollectionTools() {
|
2023-04-29 18:38:14 +08:00
|
|
|
throw new IllegalStateException("Utility class");
|
|
|
|
}
|
|
|
|
}
|