Java Collection Null hasAtLeastOneNotNullElement(Collection collection)

Here you can find the source of hasAtLeastOneNotNullElement(Collection collection)

Description

has At Least One Not Null Element

License

Open Source License

Declaration

public static boolean hasAtLeastOneNotNullElement(Collection<?> collection) 

Method Source Code


//package com.java2s;
import java.util.Collection;

public class Main {
    public static boolean hasAtLeastOneNotNullElement(Collection<?> collection) {
        if (collection == null)
            return false;
        if (collection.isEmpty())
            return false;
        if (collection.contains(null))
            return collection.size() > 1;
        return collection.size() > 0;
    }//from   w  ww  . jav a2s  . c o  m
}

Related

  1. getItemAtPositionOrNull(Collection collection, int position)
  2. getNextNullIndex(C collection)
  3. getNumberOfNonNullElements(final Collection col)
  4. getSingleElementOrNull(Collection collection)
  5. getSizeNullSafe(final Collection collection)
  6. hasCollectionNullItem(Collection collection)
  7. isAllNull(Collection values)
  8. isEmplyOrNull(Collection collection)
  9. isNotNull(Collection collection)