The list of methods to do Collection Null are organized into topic(s).
T
getItemAtPositionOrNull(Collection collection, int position) Returns the n-th item or null if collection is smaller.
if (position >= collection.size()) {
return null;
if (collection instanceof List) {
return ((List<T>) collection).get(position);
Iterator<T> iterator = collection.iterator();
T item = null;
...
int
getNextNullIndex(C collection) get Next Null Index
int output = -1;
int currentLoc = 0;
for (Object object : collection) {
if (object == null) {
output = currentLoc;
break;
currentLoc++;
...
E
getSingleElementOrNull(Collection collection) returns the one and only element of a collection or null if the collection is empty.
if (collection.isEmpty()) {
return null;
} else if (collection.size() > 1) {
throw new IllegalStateException("collection has more than one elements");
} else {
return collection.iterator().next();
boolean
hasAtLeastOneNotNullElement(Collection> collection) has At Least One Not Null Element
if (collection == null)
return false;
if (collection.isEmpty())
return false;
if (collection.contains(null))
return collection.size() > 1;
return collection.size() > 0;
boolean
hasCollectionNullItem(Collection collection) has Collection Null Item
boolean hasNull = false;
Iterator iterator = collection.iterator();
while (iterator.hasNext() && !hasNull) {
Object object = iterator.next();
if (object == null) {
hasNull = true;
return hasNull;
boolean
isAllNull(Collection values) is All Null
boolean status = true;
for (String value : values) {
if (value != null) {
status = false;
break;
return status;
...