Class CollectionUtils


  • public class CollectionUtils
    extends Object
    • Method Detail

      • isEmpty

        public static <T> boolean isEmpty​(Collection<T> c)
        Check if a collection is null or empty.
        Type Parameters:
        T - the type
        Parameters:
        c - the collection
        Returns:
        true if the collection is empty or null
      • containsOnlyOne

        public static <T> boolean containsOnlyOne​(Collection<T> c)
        Check if a collection is not null and contains exactly one element
        Type Parameters:
        T - the type
        Parameters:
        c - the collection
        Returns:
        true if the collection is not null and contains only one element
      • checkSize

        public static <T> boolean checkSize​(Collection<T> c,
                                            int size)
        Check if a collection is not null and has the given size
        Type Parameters:
        T - the type
        Parameters:
        c - the collection
        size - size to check
        Returns:
        true if the collection is not null and contains only one element
      • addIfNotNull

        public static <T> boolean addIfNotNull​(Collection<T> c,
                                               T current)