当前位置:网站首页>【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);
}
......
}
依照方式,优雅体现
边栏推荐
- 100000 bonus is divided up. Come and meet the "sister who braves the wind and waves" among the winners
- Docker advanced learning (container data volume, MySQL installation, dockerfile)
- [system design] proximity service
- Heap sort and priority queue
- Print time Hahahahahaha
- Fluentd facile à utiliser avec le marché des plug - ins rainbond pour une collecte de journaux plus rapide
- 【C#/VB.NET】 将PDF转为SVG/Image, SVG/Image转PDF
- Example of joint use of ros+pytoch (semantic segmentation)
- How to scan when Canon c3120l is a network shared printer
- Ruoyi interface permission verification
猜你喜欢

How to scan when Canon c3120l is a network shared printer

SQL实现将多行记录合并成一行

YOLOV3学习笔记

Use abp Zero builds a third-party login module (I): Principles

【系统设计】邻近服务

Yolov1 learning notes
![[open source project recommendation colugomum] this group of undergraduates open source retail industry solutions based on the domestic deep learning framework paddlepadddle](/img/f8/0e3fbfd13bf06291a73200552ff17a.png)
[open source project recommendation colugomum] this group of undergraduates open source retail industry solutions based on the domestic deep learning framework paddlepadddle

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

Redis cluster creation, capacity expansion and capacity reduction

Paper notes vsalm literature review "a comprehensive survey of visual slam algorithms"
随机推荐
Kubesphere - build MySQL master-slave replication structure
Fluentd facile à utiliser avec le marché des plug - ins rainbond pour une collecte de journaux plus rapide
opencv
Method of converting GPS coordinates to Baidu map coordinates
深入解析kubernetes controller-runtime
Oracle Database Introduction
Decision tree of machine learning
Push box games C #
冒泡排序的简单理解
Interface test weather API
Cesium entity (entities) entity deletion method
Scripy learning
Tabbar settings
Selenium - 改变窗口大小,不同机型呈现的宽高长度会不一样
Interesting research on mouse pointer interaction
Nacos service installation
Time format record
DNS forward query:
论文笔记 VSALM 文献综述《A Comprehensive Survey of Visual SLAM Algorithms》
Printer related problem record