zl程序教程

您现在的位置是:首页 >  后端

当前栏目

[Java] Check a Database call return value is empty list

JAVADatabaseList is value call check return
2023-09-14 08:59:13 时间

Code to improve:

final Collection<DiscussionTopics> topics = s.getTopics();
final boolean anyTopics = topics != null && !topics.isEmpty();

 

Change to:

import org.apache.commons.collections.CollectionUtils;
!CollectionUtils.isEmpty(s.getTopics())