当前位置:网站首页>【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);
}
......
}
依照方式,优雅体现
边栏推荐
- Mysql
- Learning notes -- principles and comparison of k-d tree and IKD tree
- 輕松上手Fluentd,結合 Rainbond 插件市場,日志收集更快捷
- Advanced technology management - do you know the whole picture of growth?
- Project summary --01 (addition, deletion, modification and query of interfaces; use of multithreading)
- IE browser flash back, automatically open edge browser
- 使用conda创建自己的深度学习环境
- Use selenium to climb the annual box office of Yien
- Create your own deep learning environment with CONDA
- After the Chrome browser is updated, lodop printing cannot be called
猜你喜欢

Scroll view specifies the starting position of the scrolling element

2022 cisp-pte (III) command execution

“我为开源打榜狂”第一周榜单公布,160位开发者上榜

Yolov2 learning and summary

Create your own deep learning environment with CONDA

IE browser flash back, automatically open edge browser

JMeter linked database

论文笔记 VSALM 文献综述《A Comprehensive Survey of Visual SLAM Algorithms》

轻松上手Fluentd,结合 Rainbond 插件市场,日志收集更快捷

In depth analysis of kubernetes controller runtime
随机推荐
MySQL帶二進制的庫錶導出導入
Characteristics and isolation level of database
Yolov2 learning and summary
Cesium Click to obtain the longitude and latitude elevation coordinates (3D coordinates) of the model surface
数值法求解最优控制问题(一)——梯度法
有意思的鼠标指针交互探究
Heap sort and priority queue
Derivation of variance iteration formula
UNI-APP中条件注释 实现跨段兼容、导航跳转 和 传参、组件创建使用和生命周期函数
【系统设计】邻近服务
Simple password lock
Unit test framework + Test Suite
Advanced technology management - do you know the whole picture of growth?
Time format record
Support vector machine for machine learning
error C2017: 非法的转义序列
Mysql
Local rviz call and display of remote rostopic
Judge whether the date time exceeds 31 days
【无标题】8 简易版通讯录