Java List Null Empty isListElementsEmpty(final List l)

Here you can find the source of isListElementsEmpty(final List l)

Description

Checks a list of elements to see if every element in the list is empty.

License

Apache License

Parameter

Parameter Description
l List of <String>

Return

boolean true when all elements are empty

Declaration

public static boolean isListElementsEmpty(final List l) 

Method Source Code

//package com.java2s;
/*//from  w w w  .j a  va 2 s  .c o  m
 * ObjectLab, http://www.objectlab.co.uk/open is supporting FlatPack.
 *
 * Based in London, we are world leaders in the design and development
 * of bespoke applications for the securities financing markets.
 *
 * <a href="http://www.objectlab.co.uk/open">Click here to learn more</a>
 *           ___  _     _           _   _          _
 *          / _ \| |__ (_) ___  ___| |_| |    __ _| |__
 *         | | | | '_ \| |/ _ \/ __| __| |   / _` | '_ \
 *         | |_| | |_) | |  __/ (__| |_| |__| (_| | |_) |
 *          \___/|_.__// |\___|\___|\__|_____\__,_|_.__/
 *                   |__/
 *
 *                     www.ObjectLab.co.uk
 *
 * $Id: ColorProvider.java 74 2006-10-24 22:19:05Z benoitx $
 *
 * Copyright 2006 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

import java.util.Iterator;
import java.util.List;

public class Main {
    /**
     * Checks a list of <String> elements to see if every element
     * in the list is empty.
     * 
     * @param l
     *          List of <String>
     * @return boolean
     *              true when all elements are empty
     */
    public static boolean isListElementsEmpty(final List l) {
        final Iterator it = l.iterator();
        while (it.hasNext()) {
            final String s = (String) it.next();
            if (s != null && s.trim().length() > 0) {
                return false;
            }
        }
        return true;
    }
}

Related

  1. isEmpty(List objList)
  2. isEmpty(List sourceList)
  3. isEmptyList(List inputList)
  4. isEmptyList(List list)
  5. isHelp(List args, boolean valOnEmpty)
  6. isListEmpty(final List list)
  7. isListEmpty(List oneList)
  8. isListEmpty(List list)
  9. isListNullOrEmpty(List lst)