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

com.gitee.cliveyuan.tools.CollectionTools Maven / Gradle / Ivy

There is a newer version: 4.0.6
Show newest version
package com.gitee.cliveyuan.tools;

import java.util.Collection;
import java.util.Map;
import java.util.Objects;

/**
 * 集合工具类
 *
 * @author clive
 * Created on 2018/07/23
 * @since 1.0
 */
public class CollectionTools {

    private CollectionTools() {
    }

    /**
     * 集合是否为空
     *
     * @param collection 集合
     */
    public static boolean isEmpty(Collection collection) {
        return collection == null || collection.isEmpty();
    }

    /**
     * 集合是否不为空
     *
     * @param collection 集合
     */
    public static boolean isNotEmpty(Collection collection) {
        return !isEmpty(collection);
    }

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

    /**
     * map是否不为空
     *
     * @param map map
     */
    public static boolean isNotEmpty(Map map) {
        return !isEmpty(map);
    }

    /**
     * 数组是否空
     *
     * @param array 数组
     */
    public static boolean isEmpty(Object[] array) {
        return Objects.isNull(array) || array.length == 0;
    }

    /**
     * 数组不为空
     *
     * @param array 数组
     */
    public static boolean isNotEmpty(Object[] array) {
        return !isEmpty(array);
    }

    public static boolean isEmpty(int[] array) {
        return Objects.isNull(array) || array.length == 0;
    }

    public static boolean isNotEmpty(int[] array) {
        return !isEmpty(array);
    }

    public static boolean isEmpty(long[] array) {
        return Objects.isNull(array) || array.length == 0;
    }

    public static boolean isNotEmpty(long[] array) {
        return !isEmpty(array);
    }

    public static boolean isEmpty(float[] array) {
        return Objects.isNull(array) || array.length == 0;
    }

    public static boolean isNotEmpty(float[] array) {
        return !isEmpty(array);
    }

    public static boolean isEmpty(double[] array) {
        return Objects.isNull(array) || array.length == 0;
    }

    public static boolean isNotEmpty(double[] array) {
        return !isEmpty(array);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy