package com.phlx.wool.util;

import java.math.BigDecimal;
import java.math.BigInteger;

/**
 * <pre>
 *     author : lei
 *     e-mail : 18600395998@163.com
 *     time   : 2020/04/16
 *     desc   :
 *     version: 1.0
 * </pre>
 */
public class StringUtil {

    private static String s36bit_const = "0123456789abcdefghijklmnopqrstuvwxyz";


    /**
     * 判断字符串是否为null或全为空白字符
     *
     * @param s 待校验字符串
     * @return {@code true}: null或全空白字符<br> {@code false}: 不为null且不全空白字符
     */
    public static boolean isSpace(final String s) {
        if (s == null)
            return true;
        for (int i = 0, len = s.length(); i < len; ++i) {
            if (!Character.isWhitespace(s.charAt(i))) {
                return false;
            }
        }
        return true;
    }

    public static String to32String(long i) {
        BigDecimal divide = new BigDecimal(32);
        BigDecimal decimal = new BigDecimal(i);
        String res = "";
        while (BigDecimal.ZERO.compareTo(decimal) != 0){
            BigDecimal[] divRes = decimal.divideAndRemainder(divide);
            decimal = divRes[0];
            res =  s36bit_const.charAt(divRes[1].intValue()) + res;
        }
        return res;
    }
}
