Java Collection Empty isNotEmpty(final Collection c)

Here you can find the source of isNotEmpty(final Collection c)

Description

Check if a collection of a string is not empty.

License

Apache License

Parameter

Parameter Description
c a parameter

Declaration

public static boolean isNotEmpty(final Collection<String> c) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.Collection;

public class Main {
    /**/*from   ww  w. j a  va2  s.  c o  m*/
     * Check if a collection of a string is not empty.
     *
     * @param c
     * @return
     */
    public static boolean isNotEmpty(final Collection<String> c) {
        return !isEmpty(c);
    }

    /**
     * Check if a string is not empty.
     *
     * @param text
     * @return
     */
    public static final boolean isNotEmpty(final String text) {
        return !isEmpty(text);
    }

    /**
     * Check if a collection of a string is empty.
     *
     * @param c
     * @return
     */
    public static boolean isEmpty(final Collection<String> c) {
        if (c == null || c.isEmpty()) {
            return false;
        }
        for (final String text : c) {
            if (isNotEmpty(text)) {
                return false;
            }
        }
        return true;
    }

    /**
     * Check if a string is empty.
     *
     * @param text
     * @return
     */
    public static final boolean isEmpty(final String text) {
        return text == null || text.length() == 0;
    }
}

Related

  1. isNotEmpty(E collection)
  2. isNotEmpty(final Collection coll)
  3. isNotEmpty(final Collection collection)
  4. isNotEmpty(final Collection collection)
  5. isNotEmpty(final Collection collection)
  6. isNotEmpty(T collection, String exceptionMessage)
  7. isNotEmptyCollection(Collection collection)
  8. isNotEmptyCollection(Object[] objs)
  9. isNotEmptyException(Collection collection)