判断是否为空

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;


public class UtilHelper {
    private UtilHelper() {
    }


    public static String toTrimLowerCase(String value) {
        return value == null ? null : value.trim().toLowerCase();
    }


    public static String toTrimUpperCase(String value) {
        return value == null ? null : value.trim().toUpperCase();
    }


    public static String trim(String value) {
        return value == null ? null : value.trim();
    }


    public static String eliminateSpecialCharacter(String str) {
        return str == null ? null : str.replaceAll("[^A-Za-z0-9]", "");
    }


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


    public static boolean isEmpty(Object[] objects) {
        return objects == null || objects.length == 0;
    }


    public static boolean isNoEmpty(String s) {
        return !isEmpty(s);
    }


    public static boolean isEmpty(String s) {
        return s == null || "".equals(s.trim()) || "null".equalsIgnoreCase(s);
    }


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


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


    public static List<String> getList(String[] strArray) {
        return Arrays.asList(strArray);
    }


    public static String toChineseDigits(Double value) {
        if (value == 0.0D) {
            return null;
        } else {
            StringBuffer returnValue = new StringBuffer();
            String[] chineseDigits = new String[]{"零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"};
            String[] chineseUnits = new String[]{"圆", "拾", "佰", "仟", "万", "拾", "佰", "仟", "亿", "拾", "佰", "仟", "万", "拾", "佰", "仟"};
            BigDecimal bd = new BigDecimal(value);
            String tmp = bd.toString();
            String[] valueStrs = tmp.split("\\.");
            String integerValue = isEmpty((Object[])valueStrs) ? tmp : valueStrs[0];
            String var10000;
            if (valueStrs.length > 1) {
                var10000 = valueStrs[1];
            } else {
                var10000 = null;
            }


            if (integerValue != null) {
                int[] integers = new int[integerValue.length()];


                int length;
                for(length = 0; length < integerValue.length(); ++length) {
                    integers[length] = Integer.parseInt(integerValue.substring(length, length + 1));
                }


                length = integers.length;


                for(int i = 0; i < length; ++i) {
                    returnValue.append(chineseDigits[integers[i]]).append(chineseUnits[length - 1 - i]);
                }
            }


            return returnValue.toString();
        }
    }
}

猜你喜欢

转载自blog.csdn.net/qq_35781178/article/details/80900226