当前位置:网站首页>【code】if (list != null && list.size() > 0)优化,集合判空实现方式
【code】if (list != null && list.size() > 0)优化,集合判空实现方式
2022-07-03 06:30:00 【掘金者说】
写旧了,写高频,想换中口味…
就是这样: if(list != null && list.size() > 0) ===》 CollectionUtils.isNotEmpty(list);
if (list != null && list.size() > 0) {
//TODO 执行逻辑
}
//import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
if (CollectionUtils.isNotEmpty(list)) {
//TODO 执行逻辑
}
/** * Collection工具类 * * @author Caratacus * @since 2016-09-19 */
public class CollectionUtils {
/** * 校验集合是否为空 * * @param coll 入参 * @return boolean */
public static boolean isEmpty(Collection<?> coll) {
return (coll == null || coll.isEmpty());
}
/** * 校验集合是否不为空 * * @param coll 入参 * @return boolean */
public static boolean isNotEmpty(Collection<?> coll) {
return !isEmpty(coll);
}
......
}
依照方式,优雅体现
边栏推荐
猜你喜欢

【系统设计】邻近服务

Project summary --01 (addition, deletion, modification and query of interfaces; use of multithreading)

In depth analysis of kubernetes controller runtime
![[set theory] relational closure (relational closure solution | relational graph closure | relational matrix closure | closure operation and relational properties | closure compound operation)](/img/a4/00aca72b268f77fe4fb24ac06289f5.jpg)
[set theory] relational closure (relational closure solution | relational graph closure | relational matrix closure | closure operation and relational properties | closure compound operation)

Simple understanding of ThreadLocal

Scroll view specifies the starting position of the scrolling element

ThreadLocal的简单理解

.NET程序配置文件操作(ini,cfg,config)

Mysql

2022 CISP-PTE(三)命令执行
随机推荐
Difference between shortest path and minimum spanning tree
Cesium Click to obtain the longitude and latitude elevation coordinates (3D coordinates) of the model surface
Project summary --01 (addition, deletion, modification and query of interfaces; use of multithreading)
Zhiniu stock project -- 05
Advanced technology management - do you know the whole picture of growth?
JMeter performance automation test
Yolov1 learning notes
学习笔记 -- k-d tree 和 ikd-Tree 原理及对比
使用conda创建自己的深度学习环境
Tabbar settings
【开源项目推荐-ColugoMum】这群本科生基于国产深度学习框架PaddlePadddle开源了零售行业解决方案
C2338 Cannot format an argument. To make type T formattable provide a formatter<T> specialization:
Opencv mouse and keyboard events
Kubesphere - build Nacos cluster
Page text acquisition
Mysql5.7 group by error
In depth analysis of kubernetes controller runtime
ThreadLocal的简单理解
SQL implementation merges multiple rows of records into one row
IC_EDA_ALL虚拟机(丰富版):questasim、vivado、vcs、verdi、dc、pt、spyglass、icc2、synplify、INCISIVE、IC617、MMSIM、工艺库