package org.jeecg.modules.common.util;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.ArrayUtils;

import java.util.UUID;

public class StringUtilsExt {
    public static String trimToEmpty(String value,String defaultValue){
        String tmp=StringUtils.trimToEmpty(value);
        if("".equals(tmp)){
            tmp=defaultValue;
        }
        return tmp;
    }

    public static String getString(Object obj){
        if(obj==null){
            return "";
        }
        return StringUtils.trimToEmpty(obj.toString());
    }

    public static String getString(Object obj,String defaultValue){
        if(obj==null){
            return defaultValue;
        }
        String tmp= StringUtils.trimToEmpty(obj.toString());
        if("".equals(tmp)){
            tmp=defaultValue;
        }
        return tmp;
    }

    public static String guidToStr(){
        return UUID.randomUUID().toString().replace("-","").replace("{","").replace("}","");
    }

    public static boolean isAllBlank(CharSequence... css) {
        if (ArrayUtils.isEmpty(css)) {
            return true;
        } else {
            CharSequence[] var1 = css;
            int var2 = css.length;

            for(int var3 = 0; var3 < var2; ++var3) {
                CharSequence cs = var1[var3];
                if (org.apache.commons.lang3.StringUtils.isNotBlank(cs)) {
                    return false;
                }
            }

            return true;
        }
    }

    public static boolean isKong(Object obj){
        if(org.springframework.util.StringUtils.isEmpty(obj)){
            return true;
        }
        String str = String.valueOf(obj);
        if("null".equals(str) || "undefined".equals(obj) || "".equals(obj)){
            return false;
        }
        return false;
    }
}
