List of utility methods to do List Null Empty
boolean | isNullOrEmpty(List> l) is Null Or Empty if (l == null) { return true; if (l.isEmpty()) { return true; return false; |
boolean | isNullOrEmptyAwareEqual(final List> targetOne, final List> targetTwo) Check if either both objects are null or List#isEmpty() empty . final boolean checkResult; if (targetOne == null || targetOne.isEmpty()) { checkResult = targetTwo == null || targetTwo.isEmpty(); } else { checkResult = targetOne.equals(targetTwo); return checkResult; |
boolean | isNullOrEmptyList(final List> list) is Null Or Empty List return list == null || list.size() == 0;
|
void | isNullOrEmptyList(List extends Object> list) is Null Or Empty List isNullOrEmptyList(list, "[Assertion failed] - this list is empty or null");
|
void | isNullOrEmptyList(String message, List> list) is Null Or Empty List if ((null == list) || (list.isEmpty())) { throw new IllegalArgumentException(message); |
boolean | isObjectListEmpty(List list) This method returns true if the input list is null or list is empty. return (list == null || list.isEmpty());
|
T | listToItemOrNull(List Transforms a list to a single item or to a null if the list has no item.
if (list == null) { return null; } else { switch (list.size()) { case 0: return null; case 1: return list.get(0); ... |
List | listWithoutNull(A... elements) list Without Null List<A> list = new ArrayList<A>(); for (A a : elements) { if (a != null) list.add(a); return list; |
List | listWithoutNull(final List Return a list without null elements. if (list == null) { return null; final List<E> result = new ArrayList<>(); for (E e : list) { if (e != null) { result.add(e); return result; |
List | maskNull(List mask Null return (pTypes == null) ? Collections.<String>emptyList() : pTypes;
|