非空判断常用方法

StringUtils

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.4</version>
        </dependency>
StringUtils.isNotBlank 判断字符串是否为空," " 返回 false
StringUtils.isNotEmpty 判断字符串是否为空," " 返回 true
StringUtils.isNumeric 判断字符串是否属于int, " " ,小数 返回 false
StringUtils.isNumericSpace 判断字符串是否属于int," " 返回 true ,小数 返回 false
<pre>
* StringUtils.isNotBlank(null)      = false
* StringUtils.isNotBlank("")        = false
* StringUtils.isNotBlank(" ")       = false
* StringUtils.isNotBlank("bob")     = true
* StringUtils.isNotBlank("  bob  ") = true
* </pre>
* <pre>
* StringUtils.isNotEmpty(null)      = false
* StringUtils.isNotEmpty("")        = false
* StringUtils.isNotEmpty(" ")       = true
* StringUtils.isNotEmpty("bob")     = true
* StringUtils.isNotEmpty("  bob  ") = true
* </pre>
* <pre>
* StringUtils.isNumeric(null)   = false
* StringUtils.isNumeric("")     = false
* StringUtils.isNumeric("  ")   = false
* StringUtils.isNumeric("123")  = true
* StringUtils.isNumeric("\u0967\u0968\u0969")  = true
* StringUtils.isNumeric("12 3") = false
* StringUtils.isNumeric("ab2c") = false
* StringUtils.isNumeric("12-3") = false
* StringUtils.isNumeric("12.3") = false
* StringUtils.isNumeric("-123") = false
* StringUtils.isNumeric("+123") = false
* </pre>
* <pre>
* StringUtils.isNumericSpace(null)   = false
* StringUtils.isNumericSpace("")     = true
* StringUtils.isNumericSpace("  ")   = true
* StringUtils.isNumericSpace("123")  = true
* StringUtils.isNumericSpace("12 3") = true
* StringUtils.isNumeric("\u0967\u0968\u0969")  = true
* StringUtils.isNumeric("\u0967\u0968 \u0969")  = true
* StringUtils.isNumericSpace("ab2c") = false
* StringUtils.isNumericSpace("12-3") = false
* StringUtils.isNumericSpace("12.3") = false
* </pre>

CollectUtils

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-collections4</artifactId>
            <version>4.1</version>
        </dependency>

CollectUtils.isNotEmpty() 判断集合是否为空

MapUtils.isNotEmpty() 判断map是否为空

java.util 下的 Objects.nonNull() 判断object是否为空

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值