2015062504 - StringUtils源码分析

    apache.common.lang3中的StringUtils 
    /*判断字符数组中存在至少一个数据为空的情况,即为null或者长度为0*/  
    /*Checks if any one of the CharSequences are empty ("") or null*/
    public static boolean isAnyEmpty(final CharSequence... css) {
        if (ArrayUtils.isEmpty(css)) {
            return true;
        }
        for (final CharSequence cs : css){
            if (isEmpty(cs)) {
                 return true;
            }
        }
        return false;
     }

     /*说明1:参数CharSequence... css是Java新特性,可变程度数据*/
     /*说明2:被final修饰的形式参数CharSequence... css的实际参数是不可改变的*/

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

     //StringUtils.isAnyEmpty(null) = true
     //StringUtils.isAnyEmpty(null, "foo") = true
     //StringUtils.isAnyEmpty("", "bar") = true
     //StringUtils.isAnyEmpty("bob", "") = true
     //StringUtils.isAnyEmpty("  bob  ", null) = true
     //StringUtils.isAnyEmpty(" ", "bar")  = false
     //StringUtils.isAnyEmpty("foo", "bar") = false

    /*判断字符串数组中任何数据都不为""或者null.都不为空返回true,否则返回false*/
    /*Checks if none of the CharSequences are empty ("") or null*/
    public static boolean isNoneEmpty(final CharSequence... css) {
         return !isAnyEmpty(css);
    }   
        


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值