Java Utililty Methods List Null Empty

List of utility methods to do List Null Empty

Description

The list of methods to do List Null Empty are organized into topic(s).

Method

voidaddAllExceptNullValue(List list, V[] values)
add All Except Null Value
if (values == null) {
    return;
for (V value : values) {
    addIfValueNotNull(list, value);
booleanaddAllIfAllValuesNotNull(List list, V[] values)
add All If All Values Not Null
if (values == null) {
    return false;
for (V value : values) {
    if (value == null) {
        return false;
for (V value : values) {
    list.add(value);
return true;
booleanaddIfNotNull(final List list, final T value)
Adds to List if value is not null.
return value != null ? list.add(value) : false;
ListaddIfNotNull(List l, T o)
Add a value to a list if the value is not null.
if (o != null)
    l.add(o);
return l;
booleanaddIfValueNotNull(List list, V value)
add If Value Not Null
if (value == null) {
    return false;
return list.add(value);
ListaddIgnoreNull(final List list, final T... objects)
Adds the ignore null.
if (objects == null)
    return list;
for (final T object : objects)
    if (object != null)
        list.add(object);
return list;
booleanaddListNotNullValue(List sourceList, V value)
add List Not Null Value
return (sourceList != null && value != null) ? sourceList.add(value) : false;
voidaddNonEmpty(List list, String value)
add Non Empty
if (!isBlank(value)) {
    list.add(value.trim());
ListaddNotNull(List list, T t)
add Not Null
if (t != null)
    list.add(t);
return list;
intcountIgnoreNull(List list)
count Ignore Null
int cnt = 0;
for (Object i : list)
    if (i != null)
        cnt++;
return cnt;