package cn.com.ctop.track.utils;

import com.alibaba.fastjson.JSONArray;

import java.util.Collection;
import java.util.List;
import java.util.Map;

public class Check {
    private Check() {
    }

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

    public static boolean isNotNull(List<?> list) {
        return !isNull(list);
    }

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

    public static boolean isNotNull(Long l) {
        return !isNull(l);
    }

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

    public static boolean isNotNull(Collection<?> collection) {
        return !isNull(collection);
    }

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

    public static boolean isNotNull(JSONArray jsonArray) {
        return !isNull(jsonArray);
    }


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

    public static boolean isNotNull(String str) {
        return !isNull(str);
    }

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

    public static boolean isNotNull(byte[] bytes) {
        return !isNull(bytes);
    }

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



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

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

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