Java Collection Empty isEmptyString(Collection theCollection)

Here you can find the source of isEmptyString(Collection theCollection)

Description

Returns if the collection contains only empty objects (i.e.

License

Open Source License

Parameter

Parameter Description
theCollection collection to check

Return

does collection contain only empty objects

Declaration

public static <T> boolean isEmptyString(Collection<T> theCollection) 

Method Source Code

//package com.java2s;
/**/* w w w .  jav  a  2s .  c o m*/
 * Helpful methods for collections.
 * 
 * ## Legal stuff
 * 
 * Copyright 2014-2014 Ekkart Kleinod <ekleinod@edgesoft.de>
 * 
 * This file is part of edgeUtils.
 * 
 * edgeUtils is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * edgeUtils is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with edgeUtils.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * @author Ekkart Kleinod
 * @version 0.2
 * @since 0.2
 */

import java.util.Collection;

public class Main {
    /**
     * Returns if the collection contains only empty objects (i.e. every contained object.toString returns "").
     * 
     * @param theCollection collection to check
     * @return does collection contain only empty objects
     *  @retval true only empty objects
     *  @retval false at least one nonempty object
     * 
     * @version 0.2
     * @since 0.2
     */
    public static <T> boolean isEmptyString(Collection<T> theCollection) {
        if (theCollection == null) {
            return false;
        }

        boolean bReturn = true;

        for (T theObject : theCollection) {
            if (!theObject.toString().isEmpty()) {
                bReturn = false;
            }
        }

        return bReturn;
    }
}

Related

  1. isEmptyCollection(Collection collection)
  2. isEmptyCollection(Object obj)
  3. isEmptyCollection(Object object)
  4. isEmptyException(Collection collection)
  5. isEmptyNotesField(Collection col)
  6. isNonEmpty(Collection coll)
  7. isNonEmpty(final Collection values)
  8. isNotEmpty(@SuppressWarnings("rawtypes") Collection collection)
  9. isNotEmpty(Collection c)

  10. HOME | Copyright © www.java2s.com 2016