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

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())

 

posted @ 2021-01-05 17:05  Zhentiw  阅读(55)  评论(0编辑  收藏  举报