当前位置:网站首页>【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);
}
......
}
依照方式,优雅体现
边栏推荐
- Ruoyi interface permission verification
- Phpstudy setting items can be accessed by other computers on the LAN
- Selenium ide installation recording and local project maintenance
- How to scan when Canon c3120l is a network shared printer
- JMeter linked database
- Yolov3 learning notes
- Migrate data from Amazon aurora to tidb
- error C2017: 非法的转义序列
- 简易密码锁
- Luogu problem list: [mathematics 1] basic mathematics problems
猜你喜欢

ssh链接远程服务器 及 远程图形化界面的本地显示

Project summary --2 (basic use of jsup)

Interesting research on mouse pointer interaction

Yolov3 learning notes

Method of converting GPS coordinates to Baidu map coordinates

Kubesphere - build Nacos cluster

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

Click cesium to obtain three-dimensional coordinates (longitude, latitude and elevation)

IC_EDA_ALL虚拟机(丰富版):questasim、vivado、vcs、verdi、dc、pt、spyglass、icc2、synplify、INCISIVE、IC617、MMSIM、工艺库

Simple understanding of ThreadLocal
随机推荐
Project summary --04
Heap sort and priority queue
Use selenium to climb the annual box office of Yien
Install VM tools
Derivation of variance iteration formula
2022 cisp-pte (III) command execution
How matlab modifies default settings
Know flex box
Oracle database synonym creation
Redis cluster creation, capacity expansion and capacity reduction
Fluentd is easy to use. Combined with the rainbow plug-in market, log collection is faster
Decision tree of machine learning
Paper notes vsalm literature review "a comprehensive survey of visual slam algorithms"
. Net program configuration file operation (INI, CFG, config)
opencv
Use abp Zero builds a third-party login module (I): Principles
YOLOV1学习笔记
How to scan when Canon c3120l is a network shared printer
SQL implementation merges multiple rows of records into one row
Zhiniu stock -- 03