Collection Utilities
Pat Ripley edited this page Mar 30, 2023
·
1 revision
A utility class that handles simple collection functions, such as null safe isEmpty()
/isNotEmpty()
, and a simple
list creation method to avoid unnecessary imports.
Example Usage:
import com.mpfthprblmtq.commons.utils.CollectionUtils;
public class Main {
public static void main(String[] args) {
List<String> stringList = getStringList();
if (CollectionUtils.isEmpty(stringList)) {
// handle an empty (or null) list
log.debug("stringList is empty!");
}
// create a list from given values
List<String> createdStringList = CollectionUtils.createList("1", "deux", "three");
assertEquals(3, createdStringList.size());
}
}
© Pat Ripley 2023