Java Collection Empty isEmpty(Collection collection)

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

Description

is Empty

License

Open Source License

Declaration

public static <T extends Collection<?>> boolean isEmpty(Collection<?> collection) 

Method Source Code

//package com.java2s;
/*/* w  ww . j av  a2s.  c o  m*/
 * Copyright (c) 2007, 2011-2013, 2015, 2016 Eike Stepper (Berlin, Germany) and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Eike Stepper - initial API and implementation
 *    Christian W. Damus (CEA LIST) - bug 418454
 */

import java.util.Collection;
import java.util.Map;

public class Main {
    /**
     * @since 3.1
     */
    public static <T> boolean isEmpty(T[] array) {
        return array == null || array.length == 0;
    }

    /**
     * @since 3.1
     */
    public static <T extends Map<?, ?>> boolean isEmpty(Map<?, ?> map) {
        return map == null || map.isEmpty();
    }

    /**
     * @since 3.1
     */
    public static <T extends Collection<?>> boolean isEmpty(Collection<?> collection) {
        return collection == null || collection.isEmpty();
    }

    /**
     * @since 3.1
     */
    public static boolean isEmpty(String string) {
        return string == null || string.length() == 0;
    }
}

Related

  1. isEmpty(Collection c)
  2. isEmpty(Collection c)
  3. isEmpty(Collection col)
  4. isEmpty(Collection col)
  5. isEmpty(Collection collection)
  6. isEmpty(Collection collection)
  7. isEmpty(Collection collection)
  8. isEmpty(Collection collection)
  9. isEmpty(Collection collection)