Is there any equivalent in google Guava for apache commons' CollectionUtils.isEmpty(list) to check if a collection is null or empty?
Asked
Active
Viewed 5,683 times
1 Answers
5
To check if Collection is both null and empty, you must do null check by yourself. Guava devs advocate not to use nulls for Collections at all - see IdeaGraveyard on Guava Wiki:
Prefer to return empty collections instead of null. Then a plain isEmpty check will suffice.
EDIT:
See this SO answer by Guava's lead dev.
Community
- 1
- 1
Grzegorz Rożniecki
- 27,415
- 11
- 90
- 112