package cn.com.ctop.common.module.utils;

import com.alibaba.fastjson.JSONArray;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;

import java.util.*;

@Slf4j
public class Check {
    private Check() {
    }

    public static boolean isNull(List<?> list) {
        return list == null || list.isEmpty();
    }

    public static boolean isNull(Long l) {
        return l == null || l == 0;
    }

    public static boolean isNull(Collection<?> collection) {
        return collection == null || collection.isEmpty();
    }

    public static boolean isNull(JSONArray jsonArray) {
        return jsonArray == null || jsonArray.isEmpty();
    }


    public static boolean isNull(String str) {
        return str == null || str.isEmpty();
    }

    public static boolean isNull(byte[] bytes) {
        return bytes == null || bytes.length == 0;
    }

    public static boolean hasNull(Object... objects) {
        for (Object obj : objects) {
            if (obj == null) {
                return true;
            }
        }
        return false;
    }

    public static boolean allEmpty(String... strs) {
        for (String str : strs) {
            if (StringUtils.isNotEmpty(str)) {
                return false;
            }
        }
        return true;
    }

    public static boolean isNull(Object object) {
        return object == null;
    }

    public static boolean isNullMap(Map<?, ?> map) {
        return map == null || map.isEmpty();
    }
}
