当前位置:网站首页>【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);
}
......
}
依照方式,优雅体现
边栏推荐
- Fluentd facile à utiliser avec le marché des plug - ins rainbond pour une collecte de journaux plus rapide
- Oracle database synonym creation
- [set theory] equivalence relation (concept of equivalence relation | examples of equivalence relation | equivalence relation and closure)
- Advanced technology management - do you know the whole picture of growth?
- 【无标题】
- Creating postgre enterprise database by ArcGIS
- Floating menu operation
- Code management tools
- The difference between CONDA and pip
- IE browser flash back, automatically open edge browser
猜你喜欢

Merge and migrate data from small data volume, sub database and sub table Mysql to tidb

ROS+Pytorch的联合使用示例(语义分割)

ruoyi接口权限校验

技术管理进阶——你了解成长的全貌吗?

数值法求解最优控制问题(一)——梯度法

Zhiniu stock project -- 05

Zhiniu stock -- 03

Fluentd is easy to use. Combined with the rainbow plug-in market, log collection is faster

Selenium ide installation recording and local project maintenance

SSH link remote server and local display of remote graphical interface
随机推荐
Unit test framework + Test Suite
Selenium - by changing the window size, the width, height and length of different models will be different
Fluentd facile à utiliser avec le marché des plug - ins rainbond pour une collecte de journaux plus rapide
有意思的鼠标指针交互探究
Exportation et importation de tables de bibliothèque avec binaires MySQL
ROS+Pytorch的联合使用示例(语义分割)
Time format record
[LeetCode]404. 左叶子之和
[untitled] 8 simplified address book
爬虫代码基础教学
100000 bonus is divided up. Come and meet the "sister who braves the wind and waves" among the winners
error C2017: 非法的转义序列
使用 Abp.Zero 搭建第三方登录模块(一):原理篇
Simple understanding of ThreadLocal
Zhiniu stock project -- 04
Example of joint use of ros+pytoch (semantic segmentation)
Cesium Click to obtain the longitude and latitude elevation coordinates (3D coordinates) of the model surface
【无标题】8 简易版通讯录
ssh链接远程服务器 及 远程图形化界面的本地显示
Simple password lock