package com.base.orbit.utils;


import com.base.orbit.Exception.AssertException;

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

/**
 * @author elqeb
 * @version v1.0
 * @ClassName NonemptyUtils
 * @Description 非空判断
 * @Time: 2023/5/10 - 9:46
 */
public class NonEmptyUtils {
    public static void objectNotNull(Object object){
        if(object == null){
            throw new AssertException("对象为null");
        }
        Class<?> objectClass = object.getClass();
        System.out.println(object.getClass());
        if(String.class.isAssignableFrom(objectClass) && "".equals(object)){
            throw new AssertException("string为空");
        }

        if(Collection.class.isAssignableFrom(objectClass) && ((Collection<?>) object).size() ==0){
                throw new AssertException("Collection为空");
        }
        if(Map.class.isAssignableFrom(objectClass) && ((Map<?,?>) object).size() ==0){
            throw new AssertException("Map为空");
        }


    }
}