当前位置:网站首页>不同类型的字段、集合list/set/map、对象如何判空null
不同类型的字段、集合list/set/map、对象如何判空null
2022-07-23 01:12:00 【热爱生活的猴子】
String型:stringutils.isblank("xxx")
可判断是否为 null,是否为 "",是否为空字符串(引号中间有空格) 如: " "
Object型: objects.isNull(User)和objects.nonNull(User)
可以对对象做判空,相当于user==null,Java8中引入了lambda后,因此出现很多这样filter(Objects::isNull)这样的写法,显然比filter(x -> x == null). 方法更直观。
List/Set型:CollectionUtils.isEmpty()和CollectionUtils.isNotEmpty
方法可以检查null和长度为0的list/set
Map型:MapUtils.isEmpty(map)和MapUtils.isNotEmpty(map)
边栏推荐
猜你喜欢
随机推荐
In the era of Internet of everything, see how IOT test meets the challenge of "core"
Swin transformer object detection project installation tutorial
博途PLC信号处理系列之限幅消抖滤波
事件侦听和删除事件——event对象——默认事件——取消冒泡事件——事件委托——默认触发
Avantages de la salle des machines bgp
万物互联时代,看IoT测试如何应对“芯”挑战
免费屏幕录像机
[Huawei online battle service] how can new players make up frames when the client quits reconnection or enters the game halfway?
Internet download manager is simply a killer of downloaders
C语言实战之猜数游戏
【CANN训练营】学习笔记——Diffusion和GAN对比,Dalle2和Parti
超全PMP备考文档汇总
Const char* in vs2022 cannot assign char*
SQL Server database design -- select statement 2
La fosse Piétinée par l'homme vous dit d'éviter les 10 erreurs courantes dans les tests automatisés
Software testing interview ideas, skills and methods to share, learn is to earn
Amplitude limiting and deblocking filtering of botu PLC signal processing series
FasterRCNN示例代码测试1:令anchor_generator = None
SPSS Chi-Square
Vs Code shortcut key settings








